summaryrefslogtreecommitdiffstats
path: root/package/rust-bin/rust-bin.mk
diff options
context:
space:
mode:
authorEric Le Bihan <eric.le.bihan.dev@free.fr>2018-02-04 19:07:41 +0100
committerPeter Korsgaard <peter@korsgaard.com>2018-02-05 14:57:47 +0100
commit194bcaeae336b18c267ec393c55993bd13d4165c (patch)
tree9d85aac45ec4173d6b33310402ee1eee33bb06d9 /package/rust-bin/rust-bin.mk
parent40e6e08d0b1a241ae4175952d4b2a22fdde5a48d (diff)
downloadbuildroot-194bcaeae336b18c267ec393c55993bd13d4165c.tar.gz
buildroot-194bcaeae336b18c267ec393c55993bd13d4165c.zip
rust-bin: new package
This package provides a pre-built version of rustc, the compiler for the Rust programming language, fetched from the upstream project. A pre-built version of the standard library for the host as well as one for the chosen target are also fetched and installed. Only the host variant is provided to allow the user to cross-compile Rust programs and run them on the target. This package could also be used to provide a bootstrap compiler when building Rust from source. So, in order to add it as a build dependency, the compiler and standard libraries are only installed in $(HOST_DIR) if the package is explicitly selected. The menuconfig entry for rustc is also updated to expose this provider. Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'package/rust-bin/rust-bin.mk')
-rw-r--r--package/rust-bin/rust-bin.mk61
1 files changed, 61 insertions, 0 deletions
diff --git a/package/rust-bin/rust-bin.mk b/package/rust-bin/rust-bin.mk
new file mode 100644
index 0000000000..255573e582
--- /dev/null
+++ b/package/rust-bin/rust-bin.mk
@@ -0,0 +1,61 @@
+################################################################################
+#
+# rust-bin
+#
+################################################################################
+
+RUST_BIN_VERSION = 1.23.0
+RUST_BIN_SITE = https://static.rust-lang.org/dist
+RUST_BIN_LICENSE = Apache-2.0 or MIT
+RUST_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+HOST_RUST_BIN_PROVIDES = host-rustc
+
+HOST_RUST_BIN_SOURCE = rustc-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz
+
+HOST_RUST_BIN_EXTRA_DOWNLOADS = \
+ rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz \
+ rust-std-$(RUST_BIN_VERSION)-$(RUST_TARGET_NAME).tar.xz
+
+HOST_RUST_BIN_LIBSTD_HOST_PREFIX = rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME)/rust-std-$(RUST_HOST_NAME)
+
+define HOST_RUST_BIN_LIBSTD_EXTRACT
+ mkdir -p $(@D)/std
+ $(foreach f,$(HOST_RUST_BIN_EXTRA_DOWNLOADS), \
+ $(call suitable-extractor,$(f)) $(DL_DIR)/$(f) | \
+ $(TAR) -C $(@D)/std $(TAR_OPTIONS) -
+ )
+ cd $(@D)/rustc/lib/rustlib; \
+ ln -sf ../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUST_HOST_NAME)
+endef
+
+HOST_RUST_BIN_POST_EXTRACT_HOOKS += HOST_RUST_BIN_LIBSTD_EXTRACT
+
+HOST_RUST_BIN_INSTALL_OPTS = \
+ --prefix=$(HOST_DIR) \
+ --disable-ldconfig
+
+ifeq ($(BR2_PACKAGE_HOST_RUST_BIN),y)
+define HOST_RUST_BIN_INSTALL_RUSTC
+ (cd $(@D); \
+ ./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
+endef
+
+define HOST_RUST_BIN_INSTALL_LIBSTD_HOST
+ (cd $(@D)/std/rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME); \
+ ./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
+endef
+
+define HOST_RUST_BIN_INSTALL_LIBSTD_TARGET
+ (cd $(@D)/std/rust-std-$(RUST_BIN_VERSION)-$(RUST_TARGET_NAME); \
+ ./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
+endef
+endif
+
+define HOST_RUST_BIN_INSTALL_CMDS
+ $(HOST_RUST_BIN_INSTALL_RUSTC)
+ $(HOST_RUST_BIN_INSTALL_LIBSTD_HOST)
+ $(HOST_RUST_BIN_INSTALL_LIBSTD_TARGET)
+endef
+
+$(eval $(host-generic-package))
OpenPOWER on IntegriCloud