openthread-br: fix actually building
[feed/packages.git] / lang / rust / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2023 Luca Barbato and Donald Hoskins
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=rust
8 PKG_VERSION:=1.72.0
9 PKG_RELEASE:=2
10
11 PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
12 PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
13 PKG_HASH:=ea9d61bbb51d76b6ea681156f69f0e0596b59722f04414b01c6e100b4b5be3a1
14 HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src
15
16 PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
17 PKG_LICENSE:=Apache-2.0 MIT
18 PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT
19
20 HOST_BUILD_DEPENDS:=python3/host
21 PKG_HOST_ONLY:=1
22
23 include $(INCLUDE_DIR)/host-build.mk
24 include $(INCLUDE_DIR)/package.mk
25 include ./rust-values.mk
26
27 define Package/rust
28 SECTION:=lang
29 CATEGORY:=Languages
30 SUBMENU:=Rust
31 TITLE:=Rust Programming Language Compiler
32 URL:=https://www.rust-lang.org/
33 DEPENDS:=$(RUST_ARCH_DEPENDS)
34 BUILDONLY:=1
35 endef
36
37 define Package/rust/description
38 Rust is a multi-paradigm, general-purpose programming language designed for performance
39 and safety, especially safe concurrency. Rust is syntactically similar to C++, but can
40 guarantee memory safety by using a borrow checker to validate references.
41 endef
42
43 # Rust-lang has an uninstall script
44 RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh
45
46 # Target Flags
47 TARGET_CONFIGURE_ARGS = \
48 --set=target.$(RUSTC_TARGET_ARCH).ar=$(TARGET_AR) \
49 --set=target.$(RUSTC_TARGET_ARCH).cc=$(TARGET_CC_NOCACHE) \
50 --set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \
51 --set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \
52 --set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) \
53 $(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR))
54
55 # CARGO_HOME is an environmental
56 HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)"
57
58 # Rust Configuration Arguments
59 HOST_CONFIGURE_ARGS = \
60 --build=$(RUSTC_HOST_ARCH) \
61 --target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \
62 --host=$(RUSTC_HOST_ARCH) \
63 --prefix=$(CARGO_HOME) \
64 --bindir=$(CARGO_HOME)/bin \
65 --libdir=$(CARGO_HOME)/lib \
66 --sysconfdir=$(CARGO_HOME)/etc \
67 --datadir=$(CARGO_HOME)/share \
68 --mandir=$(CARGO_HOME)/man \
69 --dist-compression-formats=xz \
70 --enable-missing-tools \
71 --disable-sanitizers \
72 --release-channel=stable \
73 --enable-cargo-native-static \
74 --set=llvm.download-ci-llvm=true \
75 $(TARGET_CONFIGURE_ARGS)
76
77 define Host/Uninstall
78 # Call the Uninstall script
79 [ -f $(RUST_UNINSTALL) ] && \
80 $(BASH) $(RUST_UNINSTALL) || echo No Uninstall
81 endef
82
83 define Host/Compile
84 ( \
85 cd $(HOST_BUILD_DIR) ; \
86 $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
87 rustc rust-std rust-src ; \
88 )
89 endef
90
91 define Host/Install
92 ( \
93 cd $(HOST_BUILD_DIR)/build/dist ; \
94 find -iname "*.xz" -exec tar -xJf {} \; ; \
95 find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; ; \
96 \
97 sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
98 -e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
99 $(CURDIR)/files/cargo-config > $(CARGO_HOME)/config.toml ; \
100 )
101 endef
102
103 $(eval $(call HostBuild))
104 $(eval $(call BuildPackage,rust))