summaryrefslogtreecommitdiff
path: root/user/rust/APKBUILD
blob: e855f770fd7b3df1a6833a2ca9ef71334afe3504 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Shiz <hi@shiz.me>
# Contributor: Jeizsm <jeizsm@gmail.com>
# Maintainer: Samuel Holland <samuel@sholland.org>
pkgname=rust
pkgver=1.33.0
_bootcargover=0.33.0
_bootver=1.32.0
_llvmver=8
pkgrel=0
pkgdesc="The Rust Programming Language"
url="https://www.rust-lang.org"
arch="all"
license="(Apache-2.0 OR MIT) AND (NCSA OR MIT) AND BSD-2-Clause AND BSD-3-Clause"
depends="$pkgname-stdlib=$pkgver-r$pkgrel gcc musl-dev"
makedepends="
	curl-dev
	libgit2-dev
	libssh2-dev
	llvm$_llvmver-dev
	llvm$_llvmver-test-utils
	openssl-dev
	python3
	zlib-dev
	"
subpackages="
	$pkgname-dbg
	$pkgname-stdlib
	$pkgname-analysis
	$pkgname-doc
	$pkgname-gdb::noarch
	$pkgname-lldb::noarch
	$pkgname-src::noarch
	cargo
	cargo-clippy:_cargo_clippy
	cargo-fmt:_cargo_fmt
	cargo-doc:_cargo_doc:noarch
	cargo-bash-completion:_cargo_bashcomp:noarch
	cargo-zsh-completion:_cargo_zshcomp:noarch
	rls
	rustfmt
	"
source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.xz
	https://distfiles.adelielinux.org/source/rust/cargo-$_bootcargover-$CBUILD.tar.xz
	https://distfiles.adelielinux.org/source/rust/rust-std-$_bootver-$CBUILD.tar.xz
	https://distfiles.adelielinux.org/source/rust/rustc-$_bootver-$CBUILD.tar.xz
	0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
	0002-Fix-LLVM-build.patch
	0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
	0004-Require-static-native-libraries-when-linking-static-.patch
	0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
	0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
	0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
	0008-test-enum-debug-Correct-minimum-LLVM-version.patch
	0009-test-use-extern-for-plugins-Don-t-assume-multilib.patch
	0010-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
	0011-Ignore-broken-and-non-applicable-tests.patch
	0012-Link-stage-2-tools-dynamically-to-libstd.patch
	0013-Move-debugger-scripts-to-usr-share-rust.patch
	0014-Add-foxkit-target-specs.patch
	0030-libc-linkage.patch
	0040-rls-atomics.patch
	0050-LLVM-8.0-compatibility.patch
	"
builddir="$srcdir/rustc-$pkgver-src"
_rlibdir="/usr/lib/rustlib/$CTARGET/lib"

prepare() {
	cd "$builddir"

	default_prepare

	$srcdir/cargo-$_bootcargover-$CBUILD/install.sh \
		--destdir=$srcdir/prebuilt \
		--prefix=/ \
		--disable-ldconfig
	$srcdir/rust-std-$_bootver-$CBUILD/install.sh \
		--destdir=$srcdir/prebuilt \
		--prefix=/ \
		--disable-ldconfig
	$srcdir/rustc-$_bootver-$CBUILD/install.sh \
		--destdir=$srcdir/prebuilt \
		--prefix=/ \
		--disable-ldconfig
}

build() {
	cd "$builddir"

	cat > config.toml <<- EOF
		[build]
		build = "$CBUILD"
		host = [ "$CHOST" ]
		target = [ "$CTARGET" ]
		cargo = "$srcdir/prebuilt/bin/cargo"
		rustc = "$srcdir/prebuilt/bin/rustc"
		submodules = false
		python = "python3"
		locked-deps = true
		vendor = true
		extended = true
		tools = [ "analysis", "cargo", "clippy", "rls", "rustfmt", "src" ]
		[install]
		prefix = "/usr"
		[rust]
		codegen-units = 1
		debuginfo = true
		debuginfo-lines = true
		debuginfo-only-std = true
		debuginfo-tools = true
		backtrace = true
		channel = "stable"
		rpath = false
		jemalloc = false
		[target.$CTARGET]
		cc = "$CTARGET-gcc"
		cxx = "$CTARGET-g++"
		linker = "$CTARGET-gcc"
		llvm-config = "/usr/lib/llvm$_llvmver/bin/llvm-config"
		crt-static = false
	EOF

	LIBGIT2_SYS_USE_PKG_CONFIG=1 \
	LLVM_LINK_SHARED=1 \
	RUST_BACKTRACE=1 \
	python3 x.py build -j ${JOBS:-2}
}

check() {
	cd "$builddir"

	RUST_BACKTRACE=1 \
	python3 x.py test -j ${JOBS:-2} --no-doc --no-fail-fast \
		src/test/codegen \
		src/test/codegen-units \
		src/test/compile-fail \
		src/test/incremental \
		src/test/mir-opt \
		src/test/pretty \
		src/test/run-fail \
		src/test/run-fail/pretty \
		src/test/run-fail-fulldeps \
		src/test/run-fail-fulldeps/pretty \
		src/test/run-make \
		src/test/run-make-fulldeps \
		src/test/run-pass \
		src/test/run-pass/pretty \
		src/test/run-pass-fulldeps \
		src/test/run-pass-fulldeps/pretty \
		src/test/ui \
		src/test/ui-fulldeps
}

package() {
	cd "$builddir"

	DESTDIR="$pkgdir" python3 x.py install

	rm "$pkgdir"/usr/lib/*.so \
	   "$pkgdir"/usr/lib/rustlib/components \
	   "$pkgdir"/usr/lib/rustlib/install.log \
	   "$pkgdir"/usr/lib/rustlib/manifest-* \
	   "$pkgdir"/usr/lib/rustlib/rust-installer-version \
	   "$pkgdir"/usr/lib/rustlib/uninstall.sh \
	   "$pkgdir"/usr/share/doc/rust/*.old
}

stdlib() {
	pkgdesc="Standard library for Rust"
	depends="musl-utils"

	_mv "$pkgdir"$_rlibdir/*.so "$subpkgdir"$_rlibdir

	mkdir -p "$subpkgdir"/etc/ld.so.conf.d
	echo "$_rlibdir" > "$subpkgdir"/etc/ld.so.conf.d/$pkgname.conf
}

analysis() {
	pkgdesc="Compiler analysis data for the Rust standard library"
	depends="$pkgname=$pkgver-r$pkgrel $pkgname-stdlib=$pkgver-r$pkgrel"

	_mv "$pkgdir"${_rlibdir%/*}/analysis "$subpkgdir"${_rlibdir%/*}
}

gdb() {
	pkgdesc="GDB pretty printers for Rust"
	license="Apache-2.0 OR MIT"
	depends="$pkgname gdb"
	install_if="$pkgname=$pkgver-r$pkgrel gdb"

	_mv "$pkgdir"/usr/bin/rust-gdb "$subpkgdir"/usr/bin
	_mv "$pkgdir"/usr/share/rust/gdb_*.py "$subpkgdir"/usr/share/rust || true
}

lldb() {
	pkgdesc="LLDB pretty printers for Rust"
	license="Apache-2.0 OR MIT"
	depends="$pkgname lldb py3-lldb"
	install_if="$pkgname=$pkgver-r$pkgrel lldb"

	_mv "$pkgdir"/usr/bin/rust-lldb "$subpkgdir"/usr/bin
	_mv "$pkgdir"/usr/share/rust/lldb_*.py "$subpkgdir"/usr/share/rust || true
}

src() {
	pkgdesc="$pkgdesc (source code)"
	depends=""

	_mv "$pkgdir"/usr/lib/rustlib/src/rust "$subpkgdir"/usr/src
	rmdir -p "$pkgdir"/usr/lib/rustlib/src 2>/dev/null || true

	mkdir -p "$subpkgdir"/usr/lib/rustlib/src
	ln -s ../../../src/rust "$subpkgdir"/usr/lib/rustlib/src/rust
}

cargo() {
	pkgdesc="The Rust package manager"
	depends="$pkgname-stdlib=$pkgver-r$pkgrel $pkgname"

	_mv "$pkgdir"/usr/bin/cargo "$subpkgdir"/usr/bin
}

_cargo_clippy() {
	pkgdesc="A collection of Rust lints (cargo plugin)"
	depends="$pkgname-stdlib=$pkgver-r$pkgrel cargo"

	_mv "$pkgdir"/usr/bin/cargo-clippy \
	    "$pkgdir"/usr/bin/clippy-driver \
	    "$subpkgdir"/usr/bin
}

_cargo_fmt() {
	pkgdesc="Format Rust code (cargo plugin)"
	depends="$pkgname-stdlib=$pkgver-r$pkgrel cargo rustfmt"
	install_if="cargo=$pkgver-r$pkgrel rustfmt=$pkgver-r$pkgrel"

	_mv "$pkgdir"/usr/bin/cargo-fmt "$subpkgdir"/usr/bin
}

_cargo_bashcomp() {
	pkgdesc="Bash completion for cargo"
	license="Apache-2.0 OR MIT"
	depends=""
	install_if="cargo=$pkgver-r$pkgrel bash-completion"

	_mv "$pkgdir"/etc/bash_completion.d/cargo \
	    "$subpkgdir"/usr/share/bash-completion/completions
	rmdir -p "$pkgdir"/etc/bash_completion.d 2>/dev/null || true
}

_cargo_zshcomp() {
	pkgdesc="ZSH completion for cargo"
	license="Apache-2.0 OR MIT"
	depends=""
	install_if="cargo=$pkgver-r$pkgrel zsh"

	_mv "$pkgdir"/usr/share/zsh/site-functions/_cargo \
	    "$subpkgdir"/usr/share/zsh/site-functions/_cargo
	rmdir -p "$pkgdir"/usr/share/zsh/site-functions 2>/dev/null || true
}

_cargo_doc() {
	pkgdesc="The Rust package manager (documentation)"
	license="Apache-2.0 OR MIT"
	depends=""
	install_if="cargo=$pkgver-r$pkgrel docs"

	# XXX: This is hackish!
	_mv "$pkgdir"/../$pkgname-doc/usr/share/man/man1/cargo* \
	    "$subpkgdir"/usr/share/man/man1
}

rls() {
	pkgdesc="The Rust language server"
	license="Apache-2.0 OR MIT"
	depends="$pkgname-stdlib=$pkgver-r$pkgrel"

	_mv "$pkgdir"/usr/bin/rls "$subpkgdir"/usr/bin
}

rustfmt() {
	pkgdesc="Format Rust code"
	depends="$pkgname-stdlib=$pkgver-r$pkgrel"

	_mv "$pkgdir"/usr/bin/rustfmt "$subpkgdir"/usr/bin
}

_mv() {
	local dest; for dest; do true; done  # get last argument
	mkdir -p "$dest"
	mv "$@"
}
sha512sums="3291e4e19f75f44c81e6fcf4c01edc7c9d326eca43722381231abcf2e99f4314059ba59a29b79f5511ad9421c358c45e8fe18584d6954d17fe2aabad0f9d9147  rustc-1.33.0-src.tar.xz
24caa7730dd41f61b97bb909d499f928cebab948e814b786e7d3836e92188ef27da48147532e063b3cec424e41a4374581274f21dc79bb95cf310f92c8609579  cargo-0.33.0-powerpc64-foxkit-linux-musl.tar.xz
c6d237d6daaae1e8a342691917bdc76fa6a59f5bd99a1df38baebf6d5c1ddc6f8460ac6e1db8168120accb9c5f90f652ea013b4d865c486c72e90244be753ebd  rust-std-1.32.0-powerpc64-foxkit-linux-musl.tar.xz
8ff3bca961e146593f17e1581d20eaeae99768a4fac65258cf5ef80ef69b427a4980fd345b69b831028ca3e882d52d2ebd42a2eccab2c812da09e2bc28960ffe  rustc-1.32.0-powerpc64-foxkit-linux-musl.tar.xz
a5e03a091b224b9cd3cd6d8a0b1ac70389f374c95ff09f55b01e739b3a98a8551d2208b2750137ebaacbb8628d1bb54a96aaeb938c961e4eb33a071594bce1dc  0001-Don-t-pass-CFLAGS-to-the-C-compiler.patch
bf387aad3d117e30621bd1914c3a713a710db0639413d57802c3a9bba49bf422dedf5e03b4a3073ec1efbd571cbcd10b6a0b3f98f2b019555581db5599b84f44  0002-Fix-LLVM-build.patch
b931204afaf3ac4c73f41c29586b0cebdb06867bf401717a473c2367ebf25be1a42827f7ccccea50c15006c744cb73fc7ea9627816d0a2b53421546a4e478436  0003-Allow-rustdoc-to-work-when-cross-compiling-on-musl.patch
da362880f89a2df8223ed255d44803e9d7d8115666946fe3a4fe4a78030cd8ee40d6aabc1ceaab110e62e9a67af7631729348f71f2d514458ef0a60e6decff3b  0004-Require-static-native-libraries-when-linking-static-.patch
1bdc441cb068697c7f6984e16bdde28bdd17b7a2517c33b666851d55f1d987a76e4d7f034b7221538c663c0a33603d8ac1f60ffb167a4a5d01677a7b214ab21d  0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
03580acc8391a7b32fb2a7880c6a924838803e8ce4771e465f24b7a09263b9b0ca7ae4fd84770c262cf25734d49ab0f838d57104b181224b901e26f25dc9d2e9  0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
8e06768d0723aca0dd292942381255061b83505da89bc45c8c8c280dcaf3184e1b05b3744559fc3ed576f9a726bd593d892a71e8fd81bfebee62bb86d62f5531  0007-runtest-Fix-proc-macro-tests-on-musl-hosts.patch
52138d4cc238ee44eafabfe281e3378298d510c9ffd9f123a5934f33b7e68b6fa262605c044bfce5943b18983d0145bdf33b9c168e030fee892247ef7ce4ec19  0008-test-enum-debug-Correct-minimum-LLVM-version.patch
34be92c7ce327f488b7a933e7232890615b3d07c08a09028d712c01aa53f89025b47aaaccdc5c2e1d52948eb967b40ea2c576b29b0102feadc7153d6d9984f79  0009-test-use-extern-for-plugins-Don-t-assume-multilib.patch
47b025edccb7e2d7c42353c3a8665714a3b5661a7d832a9bd71bf9bff75ffe7c6e90a9d55b765dadec54ce29c2539fa894801487718ac1053bd4528b413a487d  0010-test-sysroot-crates-are-unstable-Fix-test-when-rpath.patch
c32c5d807ec23f5e88f47f83220a117ff3f048cec4731e50d0cae082c971ea03993a6e4f95225046a0b06b406608ee97fb85671ad8f86e5da4970bba210388d6  0011-Ignore-broken-and-non-applicable-tests.patch
6b089c21b3b756d5d8b3198f4a914d8a2f90216ce25d491f7caeb0a637d0f729e9e5184dfa3e07b50570df5791576d1aa4bf2a1f33183c67bc2ba6ba36c0752e  0012-Link-stage-2-tools-dynamically-to-libstd.patch
d9568a3e21b60831b193c4a9554756d0be77d0c63d06d6c3ff1c7fd35822aaa3b2e2cf8acd29fe07eb698ebf48673245e052a6ddfa4d39bb687eea8c4c236e50  0013-Move-debugger-scripts-to-usr-share-rust.patch
f1269241ccddf4594752b97e6856dad98ca987d2491b1bd95f6123352eec52f3acb3f17dae1c2a42be55e25db4a7e0d6bb1fb2b468cc139ad14559e0753a4c87  0014-Add-foxkit-target-specs.patch
7197503a3bf1cdd6cb5ff3350add2682cc64f7d33f7a4b270c53321401e439de5c24ddb2f7c5a76bb3488c8b766237f674fedaa9202c480f53595d7837214f0f  0030-libc-linkage.patch
41ab9d6f361ee2fba267c9836c1a382dc86101d1bfb59cd942be8e8fc526ad65d845c9395cba7f760808d345d107f32e75af9057d67c450b8fbdd8a73636fb2e  0040-rls-atomics.patch
ba39acb52fb65eb203ad08735b5d1c9150e49f9d0abd5e87a849d40c22e5847043521154cbb529fb3cc39005b309cafda5422fbd5a3598dac519db4456f6c571  0050-LLVM-8.0-compatibility.patch"