rust-1.38.0.recipe revision 7e9510b8
1SUMMARY="Modern and safe systems programming language"
2DESCRIPTION="Rust is a systems programming language that runs blazingly fast, \
3prevents almost all crashes*, and eliminates data races."
4HOMEPAGE="https://www.rust-lang.org/"
5COPYRIGHT="2018 The Rust Project Developers"
6LICENSE="MIT"
7REVISION="1"
8cargoVersion="0.39.0"
9rlsVersion="1.38.0"
10rustfmtVersion="1.4.4"
11clippyVersion="0.0.212"
12SOURCE_URI="https://static.rust-lang.org/dist/rustc-$portVersion-src.tar.xz"
13CHECKSUM_SHA256="3a7991aa4cb44ef941d71636e45a95468b520dc6fc7cf725364925bd3e3d3a34"
14SOURCE_DIR="rustc-$portVersion-src"
15PATCHES="rust-$portVersion.patchset"
16
17ARCHITECTURES="!x86_gcc2 ?x86 ?x86_64"
18SECONDARY_ARCHITECTURES="?x86"
19
20PROVIDES="
21	rust_bin$secondaryArchSuffix = $portVersion
22	cmd:rustc$secondaryArchSuffix = $portVersion
23	cmd:rustdoc$secondaryArchSuffix = $portVersion
24	cmd:rustfmt$secondaryArchSuffix = $portVersion
25	cmd:rust_gdb$secondaryArchSuffix = $portVersion
26	cmd:rust_lldb$secondaryArchSuffix = $portVersion
27	cmd:cargo$secondaryArchSuffix = $cargoVersion
28	cmd:cargo_clippy$secondaryArchSuffix = $clippyVersion
29	cmd:cargo_fmt$secondaryArchSuffix = $cargoVersion
30	cmd:clippy_driver$secondaryArchSuffix = $clippyVersion
31	cmd:rls$secondaryArchSuffix = $rlsVersion
32	cmd:rustfmt = $rustfmtVersion
33	"
34REQUIRES="
35	haiku$secondaryArchSuffix
36	lib:libcrypto$secondaryArchSuffix
37	lib:libcurl$secondaryArchSuffix
38	lib:libssl$secondaryArchSuffix
39	lib:libz$secondaryArchSuffix
40	"
41
42BUILD_REQUIRES="
43	haiku${secondaryArchSuffix}_devel
44	devel:libcurl$secondaryArchSuffix
45	devel:libssl$secondaryArchSuffix
46	devel:libz$secondaryArchSuffix
47	"
48BUILD_PREREQUIRES="
49	cmd:cargo$secondaryArchSuffix == $cargoVersion
50	cmd:cmake
51	cmd:cmp
52	cmd:file
53	cmd:find
54	cmd:gcc$secondaryArchSuffix
55	cmd:git
56	cmd:grep
57	cmd:ld$secondaryArchSuffix
58	cmd:make
59	cmd:pkg_config$secondaryArchSuffix
60	cmd:python
61	cmd:rustc$secondaryArchSuffix == $portVersion
62	cmd:sed
63	cmd:tar
64	cmd:which
65	cmd:xargs
66	"
67
68relativeInstallDir="develop/tools$secondaryArchSubDir/rust"
69installDir="$prefix/$relativeInstallDir"
70
71BUILD()
72{
73	# write the build configuration
74	tr -d '\t' >config.toml <<- EOL
75		[llvm]
76		targets = "X86"
77		experimental-targets = ""
78
79		[build]
80		cargo = "/$relativeBinDir/cargo"
81		rustc = "/$relativeBinDir/rustc"
82		submodules = false
83		extended = true
84		tools = ["cargo", "clippy", "rls", "rustfmt", "analysis"]
85
86		[install]
87		prefix = "$installDir"
88		libdir = "$installDir/bin/lib"
89		mandir = "$manDir"
90		docdir = "$developDocDir"
91		sysconfdir = "$dataDir"
92
93		[rust]
94		channel = "stable"
95		rpath = false
96		deny-warnings = false
97		dist-src = false
98
99		[dist]
100		src-tarball = false
101EOL
102	# Disable ASLR: compiling stage 1 rustc requires a lot of RAM (about 1.5
103	# GB). Haiku has a per-process limit of 2GB on 32 bit systems. ASLR makes
104	# the available space even smaller. Disabling it will give us the space to
105	# compile Rust
106	export DISABLE_ASLR=1
107
108	# now build rust and cargo
109	./x.py dist
110}
111
112INSTALL()
113{
114	# we will manually invoke the install scripts
115	if [ $effectiveTargetArchitecture = x86 ]; then
116		architecture="i686-unknown-haiku"
117	fi
118	if [ $effectiveTargetArchitecture = x86_64 ]; then
119		architecture="x86_64-unknown-haiku"
120	fi
121
122	# let's install the packages one by one
123	cd $sourceDir/build/tmp/dist/
124	for module in "rust-docs-$srcGitRev-$architecture"     \
125	              "rust-std-$srcGitRev-$architecture"      \
126	              "rustc-$srcGitRev-$architecture"         \
127	              "rust-analysis-$srcGitRev-$architecture" \
128	              "cargo-$cargoVersion-$architecture"      \
129	              "clippy-$clippyVersion-$architecture"    \
130	              "rls-$rlsVersion-$architecture"          \
131	              "rustfmt-$rustfmtVersion-$architecture"
132	do
133		./$module/install.sh                               \
134				--prefix=$installDir                       \
135				--docdir=$developDocDir                    \
136				--mandir=$manDir                           \
137				--sysconfdir=$dataDir                      \
138				--disable-ldconfig
139	done
140
141	# move zsh data to the datadir
142	mv $installDir/share/zsh $dataDir
143	rm -rf $installDir/share
144
145	# clean out unneccesary files created by the rust installer
146	rm $installDir/lib/rustlib/components
147	rm $installDir/lib/rustlib/install.log
148	rm $installDir/lib/rustlib/manifest-*
149	rm $installDir/lib/rustlib/rust-installer-version
150	rm $installDir/lib/rustlib/uninstall.sh
151
152	# link the binaries in $binDir
153	mkdir -p $binDir
154	for f in cargo cargo-clippy cargo-fmt clippy-driver rls rust-gdb \
155	         rust-lldb rustc rustdoc rustfmt; do
156		symlinkRelative -sfn $installDir/bin/$f $binDir
157	done
158
159	# make sure runtime_loader can find the libraries in the lib dir relative
160	# to the binaries
161	symlinkRelative -sfn $installDir/lib $installDir/bin/lib
162}
163
164TEST()
165{
166	./x.py test
167}
168