Merge "STT: combined build supports more targets to build" into main

This commit is contained in:
Treehugger Robot
2023-08-23 06:11:12 +00:00
committed by Gerrit Code Review

View File

@@ -15,11 +15,11 @@
# limitations under the License. # limitations under the License.
usage() { usage() {
echo "usage: ${0} -t TARGET -v VARIANT [-d DIST_OUT] [-a ALTER_TARGET] [-c] [-o] [-r] [GOALS ...]" echo "usage: ${0} -t TARGET -v VARIANT [-d DIST_OUT] [[-a ALTER_TARGET] ...] [-c] [-o] [-r] [GOALS ...]"
echo " -t TARGET : Primay target to build" echo " -t TARGET : Primay target to build"
echo " -v VARIANT : Build variant (ex. user, userdebug)" echo " -v VARIANT : Build variant (ex. user, userdebug)"
echo " -d DIST_OUT : Path for dist out" echo " -d DIST_OUT : Path for dist out"
echo " -a ALTER_TARGET: The secondary target that shares the build artifacts with the primary target" echo " -a ALTER_TARGET: Alternative targets that share the build artifacts with the primary target"
echo " -c : Run the target build again after installclean for reference" echo " -c : Run the target build again after installclean for reference"
echo ' -o : Write build time results to "build_time_results.txt" file in "${OUT_DIR}" or "${DIST_OUT}/logs" if -d defined' echo ' -o : Write build time results to "build_time_results.txt" file in "${OUT_DIR}" or "${DIST_OUT}/logs" if -d defined'
echo " -r : Dryrun to see the commands without actually building the targets" echo " -r : Dryrun to see the commands without actually building the targets"
@@ -31,7 +31,7 @@ while getopts ha:cd:ort:v: opt; do
usage usage
;; ;;
a) a)
alter_target="${OPTARG}" alter_targets+=("${OPTARG}")
;; ;;
c) c)
installclean="true" installclean="true"
@@ -67,6 +67,10 @@ if [[ -z "${variant}" ]]; then
usage usage
exit 1 exit 1
fi fi
if [ "${#alter_targets[@]}" -eq 1 ]; then
# test for a-b-a builds
alter_targets+=("${target}")
fi
goals="${@:OPTIND}" goals="${@:OPTIND}"
@@ -84,7 +88,7 @@ if [[ -n "${dist_dir}" ]]; then
fi fi
run_command() { run_command() {
echo "Running: ${1}" echo "**Running: ${1}"
if [[ -z "${dry_run}" ]]; then if [[ -z "${dry_run}" ]]; then
eval "${1}" eval "${1}"
fi fi
@@ -111,40 +115,36 @@ if [[ -n "${result_out}" ]]; then
fi fi
# Build the target first. # Build the target first.
echo "Initial build..." echo; echo "Initial build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} ${goals}" run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} ${goals}"
if [[ -n "${installclean}" ]]; then if [[ -n "${installclean}" ]]; then
# Run the same build after installclean # Run the same build after installclean
echo "Installclean..." echo; echo "Installclean for incremental build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} installclean" run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} installclean"
echo "Build the same initial build..." echo "Build the same initial build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}" run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}"
get_build_trace "build_${target}_installclean.trace.gz" get_build_trace "build_${target}_installclean.trace.gz"
echo "Installclean to prepare for the next build..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} installclean"
fi fi
if [[ -n "${alter_target}" ]]; then count=0
# Building two targets with a single artifacts # Building the next targets in sequence
echo "Installclean for the alternative target..." for alter_target in "${alter_targets[@]}"; do
run_command "${base_command} TARGET_PRODUCT=${alter_target} TARGET_BUILD_VARIANT=${variant} installclean" count=$((${count}+1))
if [[ -n "${dist_dir}" ]]; then echo; echo "Build ${alter_target}...(${count})"
# Remove target-specific dist artifacts from the previous build
run_command "rm -f ${dist_dir}/${target}*"
fi
echo "Build the alternative target..."
run_command "${base_command} TARGET_PRODUCT=${alter_target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}" run_command "${base_command} TARGET_PRODUCT=${alter_target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}"
get_build_trace "build_${alter_target}_ab.trace.gz" get_build_trace "build_${alter_target}_ab${count}.trace.gz"
echo "Installclean for ${alter_target}..."
run_command "${base_command} TARGET_PRODUCT=${alter_target} TARGET_BUILD_VARIANT=${variant} installclean"
echo "Installclean for the primary target..."
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} installclean"
if [[ -n "${dist_dir}" ]]; then if [[ -n "${dist_dir}" ]]; then
# Remove target-specific dist artifacts from the previous build # Remove target-specific dist artifacts
run_command "rm -f ${dist_dir}/${alter_target}*" run_command "rm -f ${dist_dir}/${alter_target}*"
fi fi
echo "Build the primary target again..." done
run_command "${base_command} TARGET_PRODUCT=${target} TARGET_BUILD_VARIANT=${variant} NINJA_ARGS=\"-d explain\" ${goals}"
get_build_trace "build_${target}_aba.trace.gz"
fi
if [[ -n "${dist_dir}" ]]; then if [[ -n "${dist_dir}" ]]; then
# Remove some dist artifacts to save disk space # Remove some dist artifacts to save disk space