rust: remove useless tarball package
authorTianling Shen <cnsztl@immortalwrt.org>
Sun, 19 Mar 2023 05:39:55 +0000 (13:39 +0800)
committerTianling Shen <cnsztl@gmail.com>
Thu, 23 Mar 2023 18:08:47 +0000 (02:08 +0800)
These tarball cannot be reused, so simply drop them.

Also move cargo config to a file instead of using echo command.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
lang/rust/Makefile
lang/rust/files/cargo-config [new file with mode: 0644]

index 2b247069a8fa2aba3baeda83d7a60e7c542e9b31..104bb85108efcb3a19bed02ee1bf4eda2f2ed14c 100644 (file)
@@ -11,7 +11,7 @@ PKG_RELEASE:=1
 PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
 PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
 PKG_HASH:=eaf4d8b19f23a232a4770fb53ab5e7acdedec11da1d02b0e5d491ca92ca96d62
-HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/rustc-$(PKG_VERSION)-src/
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/rustc-$(PKG_VERSION)-src
 
 PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
 PKG_LICENSE:=Apache-2.0 MIT
@@ -22,15 +22,23 @@ PKG_HOST_ONLY:=1
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/host-build.mk
-
-# rust environment variables
 include ./rust-host.mk
 
-# Rust Temp Directory
-RUST_TMP_DIR:=$(TMP_DIR)/rust-install
+define Package/rust
+  SECTION:=lang
+  CATEGORY:=Languages
+  SUBMENU:=Rust
+  TITLE:=Rust Programming Language Compiler
+  URL:=https://www.rust-lang.org/
+  DEPENDS:=$(RUST_ARCH_DEPENDS) \
+    +pkg-config +libunwind +libopenssl +liblzma +libc
+endef
 
-RUST_INSTALL_HOST_FILENAME:=$(PKG_NAME)-$(PKG_VERSION)-$(RUSTC_HOST_ARCH)-install.tar.xz
-RUST_INSTALL_TARGET_FILENAME:=$(PKG_NAME)-$(PKG_VERSION)-$(RUSTC_TARGET_ARCH)-install.tar.xz
+define Package/rust/description
+  Rust is a multi-paradigm, general-purpose programming language designed for performance
+  and safety, especially safe concurrency. Rust is syntactically similar to C++, but can
+  guarantee memory safety by using a borrow checker to validate references.
+endef
 
 # Rust-lang has an uninstall script
 RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh
@@ -68,71 +76,33 @@ HOST_CONFIGURE_ARGS = \
        --enable-cargo-native-static \
        $(TARGET_CONFIGURE_ARGS)
 
-define Host/Prepare
-       # Ensure rust temp directory
-       [ -d $(RUST_TMP_DIR) ] || \
-         mkdir -p $(RUST_TMP_DIR)
-
-       $(call Host/Prepare/Default)
-endef
-
 define Host/Uninstall
        # Call the Uninstall script
        [ -f $(RUST_UNINSTALL) ] && \
-         $(BASH) $(RUST_UNINSTALL) || echo No Uninstall
-
-       rm -rf $(RUST_TMP_DIR)
+               $(BASH) $(RUST_UNINSTALL) || echo No Uninstall
 endef
 
-# Makes and then packages the dist artifacts
 define Host/Compile
-       cd $(HOST_BUILD_DIR) && \
-         $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
-           rustc rust-std rust-src
-
-       $(call Host/PackageDist)
+       ( \
+               cd $(HOST_BUILD_DIR) ; \
+               $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
+                       rustc rust-std rust-src ; \
+       )
 endef
 
-# Distribution Artifacts are packaged by Host/PackageDist
-# We just need to extract and install
 define Host/Install
-       $(TAR) -C $(RUST_TMP_DIR) -xJf $(DL_DIR)/$(RUST_INSTALL_HOST_FILENAME) && \
-       $(TAR) -C $(RUST_TMP_DIR) -xJf $(DL_DIR)/$(RUST_INSTALL_TARGET_FILENAME)
-
-       cd $(RUST_TMP_DIR) && \
-         find -iname "*.xz" -exec tar -xJf {} ";" && \
-         find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \;
-
-       echo -e "[target.$(RUSTC_TARGET_ARCH)]\nlinker = \"$(TARGET_CC_NOCACHE)\"\nrustflags = [\"-Ctarget-feature=-crt-static\", \"-Clink-args=$(RUSTC_LDFLAGS)\"]" > $(CARGO_HOME)/config
-       echo -e "\n[profile.stripped]\ninherits = \"release\"\nopt-level = \"s\"\nstrip = true" >> $(CARGO_HOME)/config
-endef
-
-# Packages the Distribution Artifacts into HOST and TARGET bundles.
-define Host/PackageDist
        ( \
                cd $(HOST_BUILD_DIR)/build/dist ; \
-               $(TAR) -cJf $(DL_DIR)/$(RUST_INSTALL_TARGET_FILENAME) \
-                       rust-*-$(RUSTC_TARGET_ARCH).tar.xz ; \
-               $(TAR) -cJf $(DL_DIR)/$(RUST_INSTALL_HOST_FILENAME) \
-                       --exclude rust-*-$(RUSTC_TARGET_ARCH).tar.xz *.xz ; \
+               find -iname "*.xz" -exec tar -xJf {} \; ; \
+               find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; ; \
+               \
+               sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
+                   -e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
+                   -e 's|@RUSTC_LDFLAGS@|$(RUSTC_LDFLAGS)|g' \
+                       $(CURDIR)/files/cargo-config > $(CARGO_HOME)/config ; \
        )
 endef
 
-define Package/rust
-  SECTION:=lang
-  CATEGORY:=Languages
-  TITLE:=Rust Programming Language Compiler
-  URL:=https://www.rust-lang.org/
-  DEPENDS:=$(RUST_ARCH_DEPENDS) \
-    +pkg-config +libunwind +libopenssl +liblzma +libc
-endef
-
-define Package/rust/description
-  Rust is a multi-paradigm, general-purpose programming language designed for performance
-  and safety, especially safe concurrency. Rust is syntactically similar to C++, but can
-  guarantee memory safety by using a borrow checker to validate references.
-endef
-
 define Package/rust/config
        source "$(SOURCE)/Config.in"
 endef
diff --git a/lang/rust/files/cargo-config b/lang/rust/files/cargo-config
new file mode 100644 (file)
index 0000000..2ed5129
--- /dev/null
@@ -0,0 +1,8 @@
+[target.@RUSTC_TARGET_ARCH@]
+linker = "@TARGET_CC_NOCACHE@"
+rustflags = ["-Ctarget-feature=-crt-static", "-Clink-args=@RUSTC_LDFLAGS@"]
+
+[profile.stripped]
+inherits = "release"
+opt-level = "s"
+strip = true