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 7# TODO: Refactor build/make/envsetup.sh to make gettop() available elsewhere 8function gettop 9{ 10 # Function uses potentially uninitialzied variables 11 set +u 12 13 local TOPFILE=build/bazel/bazel.sh 14 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then 15 # The following circumlocution ensures we remove symlinks from TOP. 16 (cd "$TOP"; PWD= /bin/pwd) 17 else 18 if [ -f $TOPFILE ] ; then 19 # The following circumlocution (repeated below as well) ensures 20 # that we record the true directory name and not one that is 21 # faked up with symlink names. 22 PWD= /bin/pwd 23 else 24 local HERE=$PWD 25 local T= 26 while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do 27 \cd .. 28 T=`PWD= /bin/pwd -P` 29 done 30 \cd "$HERE" 31 if [ -f "$T/$TOPFILE" ]; then 32 echo "$T" 33 fi 34 fi 35 fi 36 37 set -u 38} 39 40AOSP_ROOT=`gettop` 41 42# Generate BUILD files into out/soong/bp2build 43"${AOSP_ROOT}/build/soong/soong_ui.bash" --make-mode BP2BUILD_VERBOSE=1 bp2build --skip-soong-tests 44 45BUILD_FLAGS_LIST=( 46 --color=no 47 --curses=no 48 --show_progress_rate_limit=5 49 --config=bp2build 50) 51BUILD_FLAGS="${BUILD_FLAGS_LIST[@]}" 52 53TEST_FLAGS_LIST=( 54 --keep_going 55 --test_output=errors 56) 57TEST_FLAGS="${TEST_FLAGS_LIST[@]}" 58 59BUILD_TARGETS_LIST=( 60 //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal 61 //system/timezone/apex:com.android.tzdata 62) 63BUILD_TARGETS="${BUILD_TARGETS_LIST[@]}" 64 65echo "Building APEXes with Bazel..." 66${AOSP_ROOT}/tools/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_x86 -k ${BUILD_TARGETS} 67${AOSP_ROOT}/tools/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_x86_64 -k ${BUILD_TARGETS} 68${AOSP_ROOT}/tools/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_arm -k ${BUILD_TARGETS} 69${AOSP_ROOT}/tools/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_arm64 -k ${BUILD_TARGETS} 70 71set +x 72echo 73echo "All tests passed, you are awesome!" 74