1#!/bin/bash -eux
2#
3# Script to run some local APEX tests while APEX support is WIP and not easily testable on CI
4
5set -o pipefail
6
7source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../make/shell_utils.sh
8require_top
9
10
11# Generate BUILD files into out/soong/bp2build
12"${TOP}/build/soong/soong_ui.bash" --make-mode BP2BUILD_VERBOSE=1 bp2build --skip-soong-tests
13
14BUILD_FLAGS_LIST=(
15  --color=no
16  --curses=no
17  --show_progress_rate_limit=5
18  --config=bp2build
19)
20BUILD_FLAGS="${BUILD_FLAGS_LIST[@]}"
21
22TEST_FLAGS_LIST=(
23  --keep_going
24  --test_output=errors
25)
26TEST_FLAGS="${TEST_FLAGS_LIST[@]}"
27
28BUILD_TARGETS_LIST=(
29  //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal
30  //system/timezone/apex:com.android.tzdata
31)
32BUILD_TARGETS="${BUILD_TARGETS_LIST[@]}"
33
34echo "Building APEXes with Bazel..."
35${TOP}/build/bazel/bin/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_x86 -k ${BUILD_TARGETS}
36${TOP}/build/bazel/bin/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_x86_64 -k ${BUILD_TARGETS}
37${TOP}/build/bazel/bin/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_arm -k ${BUILD_TARGETS}
38${TOP}/build/bazel/bin/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_arm64 -k ${BUILD_TARGETS}
39
40set +x
41echo
42echo "All tests passed, you are awesome!"
43