diff mbox series

[v3,01/10] package/rustc: install cargo config as toolchain post-install hook

Message ID 20200207180829.165689-2-arnout@mind.be
State Accepted
Headers show
Series Merge rust and cargo | expand

Commit Message

Arnout Vandecappelle Feb. 7, 2020, 6:08 p.m. UTC
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 can be used not only with our own
host-cargo package, but also with a pre-installed cargo.

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. The cargo
package itself will be removed soon, so that's not appropriate either.
Therefore, put it in the rustc package - any cargo package will need
rustc.

Remove the config handling from the cargo package.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/cargo/cargo.mk                             |  6 ------
 package/{cargo/config.in => rustc/cargo-config.in} |  0
 package/rustc/rustc.mk                             | 12 ++++++++++++
 3 files changed, 12 insertions(+), 6 deletions(-)
 rename package/{cargo/config.in => rustc/cargo-config.in} (100%)

Comments

David PIERRET March 27, 2020, 10:42 a.m. UTC | #1
Hi,
Working on a new package using rust, this patch suite have resolved my
issue with rust version successfully.

Regards,
David

On Fri, Feb 7, 2020 at 7:08 PM Arnout Vandecappelle (Essensium/Mind)
<arnout@mind.be> wrote:
>
> 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 can be used not only with our own
> host-cargo package, but also with a pre-installed cargo.
>
> 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. The cargo
> package itself will be removed soon, so that's not appropriate either.
> Therefore, put it in the rustc package - any cargo package will need
> rustc.
>
> Remove the config handling from the cargo package.
>
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: David Pierret <david.pierret@smile.fr>
> ---
>  package/cargo/cargo.mk                             |  6 ------
>  package/{cargo/config.in => rustc/cargo-config.in} |  0
>  package/rustc/rustc.mk                             | 12 ++++++++++++
>  3 files changed, 12 insertions(+), 6 deletions(-)
>  rename package/{cargo/config.in => rustc/cargo-config.in} (100%)
>
> diff --git a/package/cargo/cargo.mk b/package/cargo/cargo.mk
> index a387281b4c..3f6646d027 100644
> --- a/package/cargo/cargo.mk
> +++ b/package/cargo/cargo.mk
> @@ -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/rustc/cargo-config.in
> similarity index 100%
> rename from package/cargo/config.in
> rename to package/rustc/cargo-config.in
> diff --git a/package/rustc/rustc.mk b/package/rustc/rustc.mk
> index 6eea9b4fc5..35ffc36106 100644
> --- a/package/rustc/rustc.mk
> +++ b/package/rustc/rustc.mk
> @@ -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
> --
> 2.24.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Patrick Havelange May 18, 2020, 10:51 a.m. UTC | #2
Hello all,

What about merging this patch series and then the 2nd improvement 
http://patchwork.ozlabs.org/project/buildroot/list/?series=159771 (for 
an unknown reason the 02/10 has not been picked up by patchwork)
?

There has been some remarks that in some cases the proposed patch series 
is not sufficient, however I think these are some edge cases and could 
be improved later once those patches are applied.

I'm also seeing some issues being fixed recently on the old version of 
rust, and I fear it will lead to duplicate efforts the more we wait for 
merging those 2 patch series (as a bugfix should be done in the context 
of the new version, or it might even not be needed, with a bit of luck).

Unless there are some blocking issues that I missed..


Regards,

Patrick H.


On 2020-02-07 19:08, Arnout Vandecappelle (Essensium/Mind) wrote:
> 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 can be used not only with our own
> host-cargo package, but also with a pre-installed cargo.
> 
> 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. The cargo
> package itself will be removed soon, so that's not appropriate either.
> Therefore, put it in the rustc package - any cargo package will need
> rustc.
> 
> Remove the config handling from the cargo package.
> 
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> ---
>   package/cargo/cargo.mk                             |  6 ------
>   package/{cargo/config.in => rustc/cargo-config.in} |  0
>   package/rustc/rustc.mk                             | 12 ++++++++++++
>   3 files changed, 12 insertions(+), 6 deletions(-)
>   rename package/{cargo/config.in => rustc/cargo-config.in} (100%)
> 
> diff --git a/package/cargo/cargo.mk b/package/cargo/cargo.mk
> index a387281b4c..3f6646d027 100644
> --- a/package/cargo/cargo.mk
> +++ b/package/cargo/cargo.mk
> @@ -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/rustc/cargo-config.in
> similarity index 100%
> rename from package/cargo/config.in
> rename to package/rustc/cargo-config.in
> diff --git a/package/rustc/rustc.mk b/package/rustc/rustc.mk
> index 6eea9b4fc5..35ffc36106 100644
> --- a/package/rustc/rustc.mk
> +++ b/package/rustc/rustc.mk
> @@ -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
>
Thomas Petazzoni July 27, 2020, 11:49 a.m. UTC | #3
On Fri,  7 Feb 2020 19:08:20 +0100
"Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be> wrote:

> 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 can be used not only with our own
> host-cargo package, but also with a pre-installed cargo.

I'm not sure what you meant by a "pre-installed cargo". We certainly
don't support using a "cargo" installed on the host distribution. I've
reworded the commit log to explain a bit more clearly what we are doing
here.

Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/cargo/cargo.mk b/package/cargo/cargo.mk
index a387281b4c..3f6646d027 100644
--- a/package/cargo/cargo.mk
+++ b/package/cargo/cargo.mk
@@ -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/rustc/cargo-config.in
similarity index 100%
rename from package/cargo/config.in
rename to package/rustc/cargo-config.in
diff --git a/package/rustc/rustc.mk b/package/rustc/rustc.mk
index 6eea9b4fc5..35ffc36106 100644
--- a/package/rustc/rustc.mk
+++ b/package/rustc/rustc.mk
@@ -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