diff --git a/lang/rust/Makefile b/lang/rust/Makefile index 2b247069a..104bb8510 100644 --- a/lang/rust/Makefile +++ b/lang/rust/Makefile @@ -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 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,69 +76,31 @@ 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) -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 ; \ + cd $(HOST_BUILD_DIR) ; \ + $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \ + rustc rust-std rust-src ; \ ) 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. +define Host/Install + ( \ + cd $(HOST_BUILD_DIR)/build/dist ; \ + 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/config diff --git a/lang/rust/files/cargo-config b/lang/rust/files/cargo-config new file mode 100644 index 000000000..2ed512931 --- /dev/null +++ b/lang/rust/files/cargo-config @@ -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