dev-util/ply: Fix SRC_URI
[gentoo.git] / dev-util / bazel / bazel-0.22.0.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit bash-completion-r1 java-pkg-2 multiprocessing
7
8 DESCRIPTION="Fast and correct automated build system"
9 HOMEPAGE="https://bazel.build/"
10
11 SRC_URI="https://github.com/bazelbuild/bazel/releases/download/${PV}/${P}-dist.zip"
12
13 LICENSE="Apache-2.0"
14 SLOT="0"
15 KEYWORDS="amd64"
16 IUSE="examples tools"
17 # strip corrupts the bazel binary
18 RESTRICT="strip"
19 RDEPEND="virtual/jdk:1.8"
20 DEPEND="${RDEPEND}
21         app-arch/unzip
22         app-arch/zip"
23
24 S="${WORKDIR}"
25 QA_FLAGS_IGNORED="usr/bin/bazel"
26
27 bazel-get-flags() {
28         local i fs=()
29         for i in ${CFLAGS}; do
30                 fs+=( "--copt=${i}" "--host_copt=${i}" )
31         done
32         for i in ${CXXFLAGS}; do
33                 fs+=( "--cxxopt=${i}" "--host_cxxopt=${i}" )
34         done
35         for i in ${CPPFLAGS}; do
36                 fs+=( "--copt=${i}" "--host_copt=${i}" )
37                 fs+=( "--cxxopt=${i}" "--host_cxxopt=${i}" )
38         done
39         for i in ${LDFLAGS}; do
40                 fs+=( "--linkopt=${i}" "--host_linkopt=${i}" )
41         done
42         echo "${fs[*]}"
43 }
44
45 pkg_setup() {
46         echo ${PATH} | grep -q ccache && \
47                 ewarn "${PN} usually fails to compile with ccache, you have been warned"
48         java-pkg-2_pkg_setup
49 }
50
51 src_unpack() {
52         # Only unpack the main distfile
53         unpack ${P}-dist.zip
54 }
55
56 src_prepare() {
57         default
58
59         # F: fopen_wr
60         # S: deny
61         # P: /proc/self/setgroups
62         # A: /proc/self/setgroups
63         # R: /proc/24939/setgroups
64         # C: /usr/lib/systemd/systemd
65         addpredict /proc
66
67         # Use standalone strategy to deactivate the bazel sandbox, since it
68         # conflicts with FEATURES=sandbox.
69         cat > "${T}/bazelrc" <<-EOF || die
70                 build --verbose_failures
71                 build --spawn_strategy=standalone --genrule_strategy=standalone
72
73                 build --distdir="${S}/derived/distdir/"
74                 build --jobs=$(makeopts_jobs) $(bazel-get-flags)
75
76                 test --verbose_failures --verbose_test_summary
77                 test --spawn_strategy=standalone --genrule_strategy=standalone
78                 EOF
79 }
80
81 src_compile() {
82         export EXTRA_BAZEL_ARGS="--jobs=$(makeopts_jobs) --host_javabase=@local_jdk//:jdk"
83         VERBOSE=yes ./compile.sh || die
84
85         ./scripts/generate_bash_completion.sh \
86                 --bazel=output/bazel \
87                 --output=bazel-complete.bash \
88                 --prepend=scripts/bazel-complete-header.bash \
89                 --prepend=scripts/bazel-complete-template.bash
90 }
91
92 src_test() {
93         output/bazel test \
94                 --verbose_failures \
95                 --spawn_strategy=standalone \
96                 --genrule_strategy=standalone \
97                 --verbose_test_summary \
98                 examples/cpp:hello-success_test || die
99         output/bazel shutdown
100 }
101
102 src_install() {
103         dobin output/bazel
104         newbashcomp bazel-complete.bash ${PN}
105         bashcomp_alias ${PN} ibazel
106         insinto /usr/share/zsh/site-functions
107         doins scripts/zsh_completion/_bazel
108
109         if use examples; then
110                 docinto examples
111                 dodoc -r examples/*
112                 docompress -x /usr/share/doc/${PF}/examples
113         fi
114         # could really build tools but I don't know which ones
115         # are actually used
116         if use tools; then
117                 docinto tools
118                 dodoc -r tools/*
119                 docompress -x /usr/share/doc/${PF}/tools
120         fi
121 }