aboutsummaryrefslogtreecommitdiff
path: root/ci/test_build.sh
blob: f6a49772d97f59cef6c676970f20e4a0fdea7277 (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
#!/bin/bash
set -eu

################################################################################
# This script is intended to be a test to verify that the orchestrator still
# works for others (assuming that they use a similar workflow.)
#
# NOT INTENDED to be used for general building and development, since it removes
# out/ and does other semi-hardcoded things.
################################################################################

# Typical usage:
#
# orchestrator/test_build.sh
#   This builds the default target
# orchestrator/test_build.sh vendor/nothing
#   Build "vendor/nothing", rather than the default target.
#
# Environment variables that affect this script:
#   OUT_DIR: Output directory.  We assume "out" if not set.
#   MCOMBO_DIR: Directory with (test) mcombo files.
#   MCOMBO_FILE: Mcombo file to use.  Default: aosp_cf_arm64_phone.mcombo
#
# Any arguments passed to the script are passed to multitree_build.

TOP="$(repo --show-toplevel || git rev-parse --show-toplevel || echo .)"
if [[ ${TOP} != . ]]; then
  echo "running build in ${TOP}" >&2
  cd "${TOP}"
fi

: ${MCOMBO_DIR:=orchestrator/build/orchestrator/multitree_combos/}
# Force a trailing /
MCOMBO_DIR="${MCOMBO_DIR%%/}/"
: ${MCOMBO_FILE:=aosp_cf_arm64_phone.mcombo}

# In aosp/2328802, build/make/core/envsetup.mk must exist under the top of the
# workspace. For now, make {WORKSPACE}/build a symlink to orchestrator/build.
if [[ ! -d build/ ]]; then
  ln -s orchestrator/build build
fi

(
  set +u # envsetup has unset variable references.
  . orchestrator/build/make/envsetup.sh
  multitree_lunch "${MCOMBO_DIR}${MCOMBO_FILE}" userdebug
  rm -rf "${OUT_DIR:-out}"
  multitree_build "$@"
)