aboutsummaryrefslogtreecommitdiffstats
path: root/testing/bazel3/APKBUILD
blob: e1e67661625e6bf6462e79bed2a207f27cac6ea9 (plain)
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
# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=bazel3
pkgver=3.5.0
pkgrel=0
pkgdesc="A fast, scalable, multi-language and extensible build system"
url="https://bazel.build/"
arch="all"
arch="$arch !x86 !s390x" # fatal error: jni_md.h: No such file or directory
arch="$arch !armhf !armv7" # java virtual machine runs out of resources
arch="$arch !ppc64le" # build timeouts in CI
arch="$arch !mips !mips64" # no jvm
license="Apache-2.0"
depends="bash libarchive openjdk8 zip unzip"
makedepends="python3 linux-headers protobuf coreutils"
options="!strip"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="https://github.com/bazelbuild/bazel/releases/download/$pkgver/bazel-$pkgver-dist.zip"

build() {
	# based on
	# https://github.com/vbatts/copr-build-bazel/blob/master/bazel.spec

	export JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
	export EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk --sandbox_debug --verbose_failures"

	case "$CARCH" in
		aarch64)
			export EXTRA_BAZEL_ARGS="$EXTRA_BAZEL_ARGS --nokeep_state_after_build --notrack_incremental_state --nokeep_state_after_build" ;;
		arm*)
			# increase heap size to addess arm* build failures
			export BAZEL_JAVAC_OPTS="-J-Xmx2g -J-Xms512m" ;;
		s390x)
			# increase heap size to addess s390x build failures
			export BAZEL_JAVAC_OPTS="-J-Xmx4g -J-Xms512m" ;;
	esac

	# horrible of horribles, just to have python in the PATH
	# https://github.com/bazelbuild/bazel/issues/8665
	mkdir -p ./bin-hack
	ln -s /usr/bin/python3 ./bin-hack/python
	export PATH=$(pwd)/bin-hack:$PATH

	bash ./compile.sh

	./output/bazel shutdown

	./scripts/generate_bash_completion.sh \
		--bazel=output/bazel \
		--output=output/bazel-complete.bash \
		--prepend=scripts/bazel-complete-header.bash \
		--prepend=scripts/bazel-complete-template.bash

	echo startup --server_javabase=$JAVA_HOME \
		>> scripts/packages/bazel.bazelrc
}

check() {
	./output/bazel test \
		--verbose_failures \
		--spawn_strategy=standalone \
		--genrule_strategy=standalone \
		--verbose_test_summary \
		--test_verbose_timeout_warnings \
		examples/cpp:hello-success_test

	./output/bazel shutdown
}

package() {
	install -Dm755 ./scripts/packages/bazel.sh "$pkgdir"/usr/bin/bazel
	install -Dm755 ./output/bazel "$pkgdir"/usr/bin/bazel-real
	install -Dm755 ./scripts/packages/bazel.bazelrc \
		"$pkgdir"/etc/bazel.bazelrc

	install -m644 -D -t "$pkgdir"/usr/share/doc/$pkgname README.md

	mkdir -p "$pkgdir"/usr/share/bash-completion/completions
	mv "$builddir"/output/bazel-complete.bash \
		"$pkgdir"/usr/share/bash-completion/completions/bazel

	mkdir -p "$pkgdir"/usr/share/zsh/site-functions
	mv "$builddir"/scripts/zsh_completion/_bazel \
		"$pkgdir"/usr/share/zsh/site-functions/_bazel
}

unpack() {
	mkdir -p "$builddir"
	unzip "$srcdir"/bazel-$pkgver-dist.zip -d "$builddir" > /dev/null
}

sha512sums="d9e1bac8422b48474709cae5b5a1cba2d71780e2666594d397d874bb86bb13e53b4b953800b4eb50c2a02385fa576bf7b4c2a71534bf13fbdb03d8b96a481f6a  bazel-3.5.0-dist.zip"