package/rustc: install cargo config as toolchain post-install hook
authorArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Fri, 7 Feb 2020 18:08:20 +0000 (19:08 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 27 Jul 2020 11:30:59 +0000 (13:30 +0200)
The cargo config file is much like the cmake and meson configuration
files, something that tells the cargo build system how the
cross-toolchain is configured.

It is currently installed by the cargo package, but this package is
about to be removed as cargo is now built as part of rust
itself. Therefore, install the cargo config file as a toolchain
post-install hook, just like we do for cmake and meson.

However, we don't have a pkg-cargo infrastructure (yet) so we can't
put it there. Therefore, put it in the rustc package - any cargo
package will need rustc.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: David Pierret <david.pierret@smile.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/cargo/cargo.mk
package/cargo/config.in [deleted file]
package/rustc/cargo-config.in [new file with mode: 0644]
package/rustc/rustc.mk

index a387281b4c10d92f2226428baefa4106ff0edb8b..3f6646d027c2b07e3fd8e69e3723854b38462a7e 100644 (file)
@@ -80,12 +80,6 @@ endef
 
 define HOST_CARGO_INSTALL_CMDS
        $(INSTALL) -D -m 0755 $(@D)/target/release/cargo $(HOST_DIR)/bin/cargo
-       $(INSTALL) -D package/cargo/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
 
 $(eval $(host-generic-package))
diff --git a/package/cargo/config.in b/package/cargo/config.in
deleted file mode 100644 (file)
index 47fad02..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-[target.@RUSTC_TARGET_NAME@]
-linker = "@CROSS_PREFIX@gcc"
diff --git a/package/rustc/cargo-config.in b/package/rustc/cargo-config.in
new file mode 100644 (file)
index 0000000..47fad02
--- /dev/null
@@ -0,0 +1,2 @@
+[target.@RUSTC_TARGET_NAME@]
+linker = "@CROSS_PREFIX@gcc"
index 6eea9b4fc50e25691c031d91dd88fe02cbe13ccf..35ffc36106831a3e5dab078cd86377af11cdb6c9 100644 (file)
@@ -20,3 +20,15 @@ endif
 RUSTC_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu
 
 $(eval $(host-virtual-package))
+
+ifeq ($(BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS),y)
+define RUSTC_INSTALL_CARGO_CONFIG
+       mkdir -p $(HOST_DIR)/share/cargo
+       sed -e 's/@RUSTC_TARGET_NAME@/$(RUSTC_TARGET_NAME)/' \
+               -e 's/@CROSS_PREFIX@/$(notdir $(TARGET_CROSS))/' \
+               package/rustc/cargo-config.in \
+               > $(HOST_DIR)/share/cargo/config
+endef
+# check-package disable TypoInPackageVariable - TOOLCHAIN intended
+TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += RUSTC_INSTALL_CARGO_CONFIG
+endif