rust: Install to $(STAGING_DIR)/host
authorJeffery To <jeffery.to@gmail.com>
Fri, 22 Sep 2023 16:02:01 +0000 (00:02 +0800)
committerJeffery To <jeffery.to@gmail.com>
Thu, 12 Oct 2023 05:59:53 +0000 (13:59 +0800)
This allows rustc/cargo/etc to be called without having to set PATH, as
$(STAGING_DIR)/host/bin is already in PATH.

This also fixes CARGO_HOME not being set during Host/Configure and
Host/Compile.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
(cherry picked from commit 49aaf19c65a35c37725ead7a438684411b512d6f)

lang/python/python3-host.mk
lang/python/python3-package.mk
lang/rust/Makefile
lang/rust/rust-host-build.mk
lang/rust/rust-package.mk

index ca5cb64baacc31e607eca4fe56ca4047a0866924..6ca002587c957897230507bfe83288def558df95 100644 (file)
@@ -78,8 +78,7 @@ HOST_PYTHON3_VARS = \
        CFLAGS="$(HOST_CFLAGS)" \
        CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
        LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib" \
-       CARGO_HOME="$(CARGO_HOME)" \
-       PATH="$(CARGO_HOME)/bin:$(PATH)"
+       CARGO_HOME="$(CARGO_HOME)"
 
 # $(1) => directory of python script
 # $(2) => python script and its arguments
index 0693d21ee0694f3361e0111cdf2e9db0e62547d1..fcb1d06b3a52d3d51341231931ea61a47d027295 100644 (file)
@@ -47,7 +47,6 @@ PYTHON3_VARS = \
        _python_exec_prefix="/usr" \
        CARGO_BUILD_TARGET="$(RUSTC_TARGET_ARCH)" \
        CARGO_HOME="$(CARGO_HOME)" \
-       PATH="$(CARGO_HOME)/bin:$(PATH)" \
        PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)" \
        RUSTFLAGS="$(CARGO_RUSTFLAGS)"
 
index b27c2fc09e036ed66c4931355e37732aa2550d83..67513d1800b7f620c6da69702115d01a43a33a13 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=rust
 PKG_VERSION:=1.72.0
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
 PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
@@ -40,7 +40,7 @@ define Package/rust/description
 endef
 
 # Rust-lang has an uninstall script
-RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh
+RUST_UNINSTALL:=$(STAGING_DIR)/host/lib/rustlib/uninstall.sh
 
 # Target Flags
 TARGET_CONFIGURE_ARGS = \
@@ -52,19 +52,19 @@ TARGET_CONFIGURE_ARGS = \
        $(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR))
 
 # CARGO_HOME is an environmental
-HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)"
+HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)"
 
 # Rust Configuration Arguments
 HOST_CONFIGURE_ARGS = \
        --build=$(RUSTC_HOST_ARCH) \
        --target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \
        --host=$(RUSTC_HOST_ARCH) \
-       --prefix=$(CARGO_HOME) \
-       --bindir=$(CARGO_HOME)/bin \
-       --libdir=$(CARGO_HOME)/lib \
-       --sysconfdir=$(CARGO_HOME)/etc \
-       --datadir=$(CARGO_HOME)/share \
-       --mandir=$(CARGO_HOME)/man \
+       --prefix=$(STAGING_DIR)/host \
+       --bindir=$(STAGING_DIR)/host/bin \
+       --libdir=$(STAGING_DIR)/host/lib \
+       --sysconfdir=$(STAGING_DIR)/host/etc \
+       --datadir=$(STAGING_DIR)/host/share \
+       --mandir=$(STAGING_DIR)/host/man \
        --dist-compression-formats=gz \
        --enable-missing-tools \
        --disable-sanitizers \
@@ -82,6 +82,7 @@ endef
 define Host/Compile
        ( \
                cd $(HOST_BUILD_DIR) ; \
+               CARGO_HOME=$(CARGO_HOME) \
                OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
                $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
                        rustc rust-std rust-src ; \
@@ -95,7 +96,7 @@ define Host/Install
                        $(STAGING_DIR_HOST)/bin/libdeflate-gzip -dc "$$$$targz" | tar -xf - ; \
                done ; \
                find . -mindepth 2 -maxdepth 2 -type f -name install.sh \
-                       -execdir bash '{}' --prefix=$(CARGO_HOME) --disable-ldconfig \; ; \
+                       -execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \
                \
                sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
                    -e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
index 39bee072eb8d19cad546c6345a02c1ff0f8212e5..29ecc42a5e32a39e2ab8f96c0b19987ac97aecc1 100644 (file)
@@ -20,7 +20,6 @@ include $(RUST_INCLUDE_DIR)/rust-values.mk
 define Host/Compile/Cargo
        ( \
                cd $(HOST_BUILD_DIR) ; \
-               export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \
                CARGO_HOME=$(CARGO_HOME) \
                CC=$(HOSTCC_NOCACHE) \
                cargo install -v \
@@ -34,7 +33,6 @@ endef
 define Host/Uninstall/Cargo
        ( \
                cd $(HOST_BUILD_DIR) ; \
-               export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \
                CARGO_HOME=$(CARGO_HOME) \
                CC=$(HOSTCC_NOCACHE) \
                cargo uninstall -v \
index 8d30ee86ce680c37401635c720977538bfe4356b..231828bab6245a6006b5319e9f3d0872adb90083 100644 (file)
@@ -20,7 +20,6 @@ include $(RUST_INCLUDE_DIR)/rust-values.mk
 define Build/Compile/Cargo
        ( \
                cd $(PKG_BUILD_DIR) ; \
-               export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \
                CARGO_HOME=$(CARGO_HOME) \
                TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" \
                TARGET_CC=$(TARGET_CC_NOCACHE) \