1#!/bin/bash
2# Script to run Bazel in AOSP.
3#
4# This script sets up startup and environment variables to run Bazel with the
5# AOSP JDK.
6#
7# Usage: bazel.sh [<startup options>] <command> [<args>]
8
9set -eo pipefail
10
11SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
12
13JDK_PATH="${SCRIPT_DIR}"/prebuilts/jdk/jdk17/linux-x86
14BAZEL_BINARY="${SCRIPT_DIR}"/prebuilts/bazel/linux-x86_64/bazel
15
16PROCESS_PATH="${JDK_PATH}"/bin:"${PATH}"
17
18JAVA_HOME="${JDK_PATH}" \
19PATH="${PROCESS_PATH}" \
20  "${BAZEL_BINARY}" \
21  --server_javabase="${JDK_PATH}" \
22  "$@"
23