[RFC,1/7] package/rust: build and install cargo
diff mbox series

Message ID 20191105211259.27673-2-eric.le.bihan.dev@free.fr
State New
Headers show
Series
  • Rust: drop cargo package
Related show

Commit Message

Eric Le Bihan Nov. 5, 2019, 9:12 p.m. UTC
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@free.fr>
---
 package/rust/config.in |  2 ++
 package/rust/rust.mk   | 25 ++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 package/rust/config.in

Patch
diff mbox series

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.@RUSTC_TARGET_NAME@]
+linker = "@CROSS_PREFIX@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))