1#!/bin/bash -e 2 3# This script is similar to "m" but builds in --soong-only mode, and handles 4# special cases to make that mode work. All arguments are passed on to 5# build/soong/soong_ui.bash. 6# 7# --soong-only bypasses the kati step and hence the make logic that e.g. doesn't 8# handle more than two device architectures. It is particularly intended for use 9# with TARGET_PRODUCT=mainline_sdk to build 'sdk' and 'module_export' Soong 10# modules in TARGET_ARCH_SUITE=mainline_sdk mode so that they get all four 11# device architectures (artifacts get installed in $OUT_DIR/soong/mainline-sdks 12# - cf PathForMainlineSdksInstall in android/paths.go). 13# 14# TODO(b/174315599): Replace this script completely with a 'soong_ui.bash 15# --soong-only' invocation. For now it is still necessary to set up 16# build_number.txt. 17 18if [ ! -e build/soong/soong_ui.bash ]; then 19 echo "$0 must be run from the top of the tree" 20 exit 1 21fi 22 23export OUT_DIR=${OUT_DIR:-out} 24 25if [ -e ${OUT_DIR}/soong/.soong.kati_enabled ]; then 26 # If ${OUT_DIR} has been created without --skip-make, Soong will create an 27 # ${OUT_DIR}/soong/build.ninja that leaves out many targets which are 28 # expected to be supplied by the .mk files, and that might cause errors in 29 # "m --skip-make" below. We therefore default to a different out dir 30 # location in that case. 31 AML_OUT_DIR=out/aml 32 echo "Avoiding in-make OUT_DIR '${OUT_DIR}' - building in '${AML_OUT_DIR}' instead" 33 OUT_DIR=${AML_OUT_DIR} 34fi 35 36mkdir -p ${OUT_DIR}/soong 37 38# The --dumpvars-mode invocation will run Soong in normal make mode where it 39# creates .soong.kati_enabled. That would clobber our real out directory, so we 40# need to use a different OUT_DIR. 41vars="$(OUT_DIR=${OUT_DIR}/dumpvars_mode build/soong/soong_ui.bash \ 42 --dumpvars-mode --vars=BUILD_NUMBER)" 43# Assign to a variable and eval that, since bash ignores any error status 44# from the command substitution if it's directly on the eval line. 45eval $vars 46 47# Some Soong build rules may require this, and the failure mode if it's missing 48# is confusing (b/172548608). 49echo -n ${BUILD_NUMBER} > ${OUT_DIR}/soong/build_number.txt 50 51build/soong/soong_ui.bash --make-mode --soong-only "$@" 52