buildroot/package/rust-bin/rust-bin.mk
Sam Voss 025b863e6f rust: modify Rust packaging to be usable as host-tool only
This commit modifies the host-rust virtual package to default to
host-rust-bin when no other selection has been made, as long as the
host supports rust. This allows host only tools to still use rust when
the target architecture does not support it.

Add target-specific variable which is used to differentiate host and
target arch requirements (BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS).

A target package shall depend on this variable where a host package will
use the previously defined BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS. The new
"target" version is selectable for the same set of architectures as
before, but now depends on the host variant.

Signed-off-by: Sam Voss <sam.voss@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-09-12 23:44:57 +02:00

65 lines
1.9 KiB
Makefile

################################################################################
#
# rust-bin
#
################################################################################
RUST_BIN_VERSION = 1.27.2
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)-$(RUSTC_HOST_NAME).tar.xz
HOST_RUST_BIN_EXTRA_DOWNLOADS = \
rust-std-$(RUST_BIN_VERSION)-$(RUSTC_HOST_NAME).tar.xz
ifeq ($(BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS),y)
HOST_RUST_BIN_EXTRA_DOWNLOADS += rust-std-$(RUST_BIN_VERSION)-$(RUSTC_TARGET_NAME).tar.xz
endif
HOST_RUST_BIN_LIBSTD_HOST_PREFIX = rust-std-$(RUST_BIN_VERSION)-$(RUSTC_HOST_NAME)/rust-std-$(RUSTC_HOST_NAME)
define HOST_RUST_BIN_LIBSTD_EXTRACT
mkdir -p $(@D)/std
$(foreach f,$(HOST_RUST_BIN_EXTRA_DOWNLOADS), \
$(call suitable-extractor,$(f)) $(HOST_RUST_BIN_DL_DIR)/$(f) | \
$(TAR) -C $(@D)/std $(TAR_OPTIONS) -
)
cd $(@D)/rustc/lib/rustlib/$(RUSTC_HOST_NAME); \
ln -sf ../../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUSTC_HOST_NAME)/lib
endef
HOST_RUST_BIN_POST_EXTRACT_HOOKS += HOST_RUST_BIN_LIBSTD_EXTRACT
HOST_RUST_BIN_INSTALL_OPTS = \
--prefix=$(HOST_DIR) \
--disable-ldconfig
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)-$(RUSTC_HOST_NAME); \
./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
endef
ifeq ($(BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS),y)
define HOST_RUST_BIN_INSTALL_LIBSTD_TARGET
(cd $(@D)/std/rust-std-$(RUST_BIN_VERSION)-$(RUSTC_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))