aboutsummaryrefslogtreecommitdiffstats
path: root/testing/bazel2/APKBUILD
blob: d18244a5de4fc996c6656176d2fece2b4d7d6a48 (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
# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=bazel2
pkgver=2.2.0
pkgrel=0
pkgdesc="A fast, scalable, multi-language and extensible build system"
url="https://bazel.build/"
arch="x86_64"
license="Apache-2.0"
depends="bash libarchive openjdk8 zip unzip"
makedepends="python3 linux-headers protobuf coreutils"
options="!strip"
replaces="bazel"
provides="bazel=$pkgver-r$pkgrel"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-examples::noarch
	"
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"

	# 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

	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

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

examples() {
	mkdir -p "$subpkgdir"/usr/share/doc/"$pkgname"
	for d in examples third_party tools; do
		mv "$builddir/$d" "$subpkgdir/usr/share/doc/$pkgname"
	done
}

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

sha512sums="67011c3a045c0fd74cdcb98eef1c3ead6902a3bd65a629fe49911f9dbb4c39508bd91eb63c1fae68284136ad4994afb42a01c7f10983614e432f8be22a1c566e  bazel-2.2.0-dist.zip"