[Buildroot] [PATCH v2 1/9] package/rust: build and install cargo

Patrick Havelange patrick.havelange at essensium.com
Wed Jan 15 13:26:09 UTC 2020


From: Eric Le Bihan <eric.le.bihan.dev at free.fr>

Cargo source code is not provided anymore as a separate tarball but is
now built along with the Rust compiler.

So update rust host variant to build Cargo and install the
cross-compilation configuration file.

Signed-off-by: Eric Le Bihan <eric.le.bihan.dev at free.fr>
Signed-off-by: Patrick Havelange <patrick.havelange at essensium.com>
---
 package/rust/config.in |  2 ++
 package/rust/rust.mk   | 25 ++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 package/rust/config.in

diff --git a/package/rust/config.in b/package/rust/config.in
new file mode 100644
index 0000000000..47fad026be
--- /dev/null
+++ b/package/rust/config.in
@@ -0,0 +1,2 @@
+[target. at RUSTC_TARGET_NAME@]
+linker = "@CROSS_PREFIX at gcc"
diff --git a/package/rust/rust.mk b/package/rust/rust.mk
index 5d14fc6682..901995c203 100644
--- a/package/rust/rust.mk
+++ b/package/rust/rust.mk
@@ -47,11 +47,14 @@ define HOST_RUST_CONFIGURE_CMDS
 		echo 'python = "$(HOST_DIR)/bin/python2"'; \
 		echo 'submodules = false'; \
 		echo 'vendor = true'; \
+		echo 'extended = true'; \
+		echo 'tools = ["cargo"]'; \
 		echo 'compiler-docs = false'; \
 		echo 'docs = false'; \
 		echo 'verbose = $(HOST_RUST_VERBOSITY)'; \
 		echo '[install]'; \
 		echo 'prefix = "$(HOST_DIR)"'; \
+		echo 'sysconfdir = "$(HOST_DIR)/etc"'; \
 		echo '[rust]'; \
 		echo 'channel = "stable"'; \
 		echo '[target.$(RUSTC_TARGET_NAME)]'; \
@@ -64,9 +67,29 @@ define HOST_RUST_BUILD_CMDS
 	cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py build
 endef
 
-define HOST_RUST_INSTALL_CMDS
+define HOST_RUST_INSTALL_RUST_BIN
 	cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py dist
 	cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py install
 endef
 
+define HOST_RUST_INSTALL_CARGO_BIN
+	find $(@D)/build/tmp/dist -maxdepth 2 -wholename '*cargo*/install.sh' \
+		-exec {} --prefix=$(HOST_DIR) --disable-ldconfig \;
+endef
+
+define HOST_RUST_INSTALL_CARGO_CONFIG
+	$(INSTALL) -D package/rust/config.in \
+		$(HOST_DIR)/share/cargo/config
+	$(SED) 's/@RUSTC_TARGET_NAME@/$(RUSTC_TARGET_NAME)/' \
+		$(HOST_DIR)/share/cargo/config
+	$(SED) 's/@CROSS_PREFIX@/$(notdir $(TARGET_CROSS))/' \
+		$(HOST_DIR)/share/cargo/config
+endef
+
+define HOST_RUST_INSTALL_CMDS
+	$(HOST_RUST_INSTALL_RUST_BIN)
+	$(HOST_RUST_INSTALL_CARGO_BIN)
+	$(HOST_RUST_INSTALL_CARGO_CONFIG)
+endef
+
 $(eval $(host-generic-package))
-- 
2.17.1



More information about the buildroot mailing list