2023-09-29 19:32:42 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#
|
|
|
|
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
|
|
|
|
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
|
|
|
PKG_NAME:=rust
|
2024-02-11 18:24:14 +00:00
|
|
|
|
2024-10-16 10:12:09 +00:00
|
|
|
PKG_VERSION:=1.81.0
|
2024-02-11 18:24:14 +00:00
|
|
|
|
2024-06-09 17:10:37 +00:00
|
|
|
PKG_RELEASE:=2
|
2023-09-29 19:32:42 +00:00
|
|
|
|
|
|
|
PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
|
|
|
|
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
|
2024-10-16 10:12:09 +00:00
|
|
|
PKG_HASH:=872448febdff32e50c3c90a7e15f9bb2db131d13c588fe9071b0ed88837ccfa7
|
2024-02-11 18:24:14 +00:00
|
|
|
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src
|
2023-09-29 19:32:42 +00:00
|
|
|
|
|
|
|
PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
|
|
|
|
PKG_LICENSE:=Apache-2.0 MIT
|
|
|
|
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT
|
|
|
|
|
|
|
|
PKG_HOST_ONLY:=1
|
2024-02-11 18:24:14 +00:00
|
|
|
PKG_BUILD_FLAGS:=no-mips16
|
2023-09-29 19:32:42 +00:00
|
|
|
|
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
include $(INCLUDE_DIR)/package.mk
|
2024-02-11 18:24:14 +00:00
|
|
|
include ./rust-values.mk
|
2023-09-29 19:32:42 +00:00
|
|
|
|
|
|
|
define Package/rust
|
|
|
|
SECTION:=lang
|
|
|
|
CATEGORY:=Languages
|
|
|
|
SUBMENU:=Rust
|
|
|
|
TITLE:=Rust Programming Language Compiler
|
|
|
|
URL:=https://www.rust-lang.org/
|
2024-02-11 18:24:14 +00:00
|
|
|
DEPENDS:=$(RUST_ARCH_DEPENDS) @!(LINUX_5_4)
|
2023-09-29 19:32:42 +00:00
|
|
|
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
|
|
|
|
|
2024-02-11 18:24:14 +00:00
|
|
|
define Package/rust/config
|
|
|
|
source "$(SOURCE)/Config.in"
|
|
|
|
endef
|
|
|
|
|
2023-09-29 19:32:42 +00:00
|
|
|
# Rust-lang has an uninstall script
|
2024-02-11 18:24:14 +00:00
|
|
|
RUST_UNINSTALL:=$(STAGING_DIR)/host/lib/rustlib/uninstall.sh
|
2023-09-29 19:32:42 +00:00
|
|
|
|
|
|
|
# Target Flags
|
|
|
|
TARGET_CONFIGURE_ARGS = \
|
|
|
|
--set=target.$(RUSTC_TARGET_ARCH).ar=$(TARGET_AR) \
|
|
|
|
--set=target.$(RUSTC_TARGET_ARCH).cc=$(TARGET_CC_NOCACHE) \
|
|
|
|
--set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \
|
|
|
|
--set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \
|
|
|
|
--set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) \
|
2024-02-11 18:24:14 +00:00
|
|
|
--set=target.$(RUSTC_TARGET_ARCH).crt-static=false \
|
2023-09-29 19:32:42 +00:00
|
|
|
$(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR))
|
|
|
|
|
|
|
|
# CARGO_HOME is an environmental
|
2024-02-11 18:24:14 +00:00
|
|
|
HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)"
|
2023-09-29 19:32:42 +00:00
|
|
|
|
|
|
|
# Rust Configuration Arguments
|
|
|
|
HOST_CONFIGURE_ARGS = \
|
|
|
|
--build=$(RUSTC_HOST_ARCH) \
|
|
|
|
--target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \
|
|
|
|
--host=$(RUSTC_HOST_ARCH) \
|
2024-02-11 18:24:14 +00:00
|
|
|
--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 \
|
2023-09-29 19:32:42 +00:00
|
|
|
--disable-sanitizers \
|
|
|
|
--release-channel=stable \
|
|
|
|
--enable-cargo-native-static \
|
2024-06-09 17:10:37 +00:00
|
|
|
--bootstrap-cache-path=$(DL_DIR)/rustc \
|
2024-02-11 18:24:14 +00:00
|
|
|
--set=llvm.download-ci-llvm=true \
|
2023-09-29 19:32:42 +00:00
|
|
|
$(TARGET_CONFIGURE_ARGS)
|
|
|
|
|
|
|
|
define Host/Uninstall
|
|
|
|
# Call the Uninstall script
|
|
|
|
[ -f $(RUST_UNINSTALL) ] && \
|
|
|
|
$(BASH) $(RUST_UNINSTALL) || echo No Uninstall
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Compile
|
2024-02-11 18:24:14 +00:00
|
|
|
$(RUST_SCCACHE_VARS) \
|
|
|
|
CARGO_HOME=$(CARGO_HOME) \
|
|
|
|
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
|
|
|
|
OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
|
|
|
|
$(PYTHON) $(HOST_BUILD_DIR)/x.py \
|
|
|
|
--build-dir $(HOST_BUILD_DIR)/build \
|
|
|
|
--config $(HOST_BUILD_DIR)/config.toml \
|
|
|
|
dist build-manifest cargo llvm-tools rustc rust-std rust-src
|
2023-09-29 19:32:42 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Install
|
|
|
|
( \
|
|
|
|
cd $(HOST_BUILD_DIR)/build/dist ; \
|
2024-06-12 18:16:20 +00:00
|
|
|
find -iname "*.tar.gz" -exec tar -xzf {} \; ; \
|
2024-02-11 18:24:14 +00:00
|
|
|
find . -mindepth 2 -maxdepth 2 -type f -name install.sh \
|
|
|
|
-execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \
|
2023-09-29 19:32:42 +00:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call HostBuild))
|
|
|
|
$(eval $(call BuildPackage,rust))
|