summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 46118f89072cb156ec05292f36616fc7bbecdc38 (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
# Maintainer: Kenneth Endfinger <kaendfinger@gmail.com>
pkgname=bazel-git
pkgver=r24502.9ec89b9194
pkgrel=1
pkgdesc="Correct, reproducible, and fast builds for everyone"
arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64')
url="http://bazel.io/"
license=('Apache')
depends=('java-environment=11' 'libarchive' 'zip' 'unzip')
makedepends=('git' 'protobuf' 'python' 'bazel-bootstrap')
options=('!distcc' '!strip' '!ccache')
provides=('bazel')
source=("${pkgname}::git+https://github.com/google/bazel.git")
sha512sums=('SKIP')

pkgver() {
  cd "${pkgname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "${srcdir}/${pkgname}"

  EXTRA_BAZEL_ARGS=()

  CCACHE_DIR="${HOME}/.ccache"

  if command -v ccache > /dev/null
  then
    CCACHE_DIR="$(ccache -k cache_dir)"
  fi

  if [ -d "${CCACHE_DIR}" ]
  then
    EXTRA_BAZEL_ARGS+=("--sandbox_writable_path" "${CCACHE_DIR}")
  fi

  /opt/bazel-bootstrap/bin/bazel build //src:bazel scripts:bazel-complete.bash "${EXTRA_BAZEL_ARGS[@]}"
  /opt/bazel-bootstrap/bin/bazel shutdown
}

package() {
  cd "${srcdir}/${pkgname}"

  install -Dm755 scripts/packages/bazel.sh "${pkgdir}/usr/bin/bazel"
  install -Dm755 bazel-bin/src/bazel "${pkgdir}/usr/bin/bazel-real"
  install -Dm644 bazel-bin/scripts/bazel-complete.bash "${pkgdir}/usr/share/bash-completion/completions/bazel"
  install -Dm644 scripts/zsh_completion/_bazel "${pkgdir}/usr/share/zsh/site-functions/_bazel"
  mkdir -p "${pkgdir}/opt/bazel"
  for d in examples third_party tools; do
    cp -r "${d}" "${pkgdir}/opt/bazel/"
  done
}