Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
Martin Stjernholm | 040e044 | 2021-06-07 23:18:56 +0100 | [diff] [blame] | 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. |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 6 | # |
Martin Stjernholm | 040e044 | 2021-06-07 23:18:56 +0100 | [diff] [blame] | 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 | |
| 18 | if [ ! -e build/soong/soong_ui.bash ]; then |
| 19 | echo "$0 must be run from the top of the tree" |
| 20 | exit 1 |
| 21 | fi |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 22 | |
| 23 | export OUT_DIR=${OUT_DIR:-out} |
| 24 | |
| 25 | if [ -e ${OUT_DIR}/soong/.soong.kati_enabled ]; then |
Colin Cross | 34d60c9 | 2021-10-28 16:19:40 -0700 | [diff] [blame^] | 26 | # If ${OUT_DIR} has been created without --soong-only, Soong will create an |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 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 |
Colin Cross | 34d60c9 | 2021-10-28 16:19:40 -0700 | [diff] [blame^] | 29 | # "m --soong-only" below. We therefore default to a different out dir |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 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} |
| 34 | fi |
| 35 | |
Martin Stjernholm | 040e044 | 2021-06-07 23:18:56 +0100 | [diff] [blame] | 36 | mkdir -p ${OUT_DIR}/soong |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 37 | |
Martin Stjernholm | 040e044 | 2021-06-07 23:18:56 +0100 | [diff] [blame] | 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. |
| 41 | vars="$(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. |
| 45 | eval $vars |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 46 | |
| 47 | # Some Soong build rules may require this, and the failure mode if it's missing |
| 48 | # is confusing (b/172548608). |
Martin Stjernholm | 040e044 | 2021-06-07 23:18:56 +0100 | [diff] [blame] | 49 | echo -n ${BUILD_NUMBER} > ${OUT_DIR}/soong/build_number.txt |
Pete Bentley | 237de41 | 2021-01-29 15:14:42 +0000 | [diff] [blame] | 50 | |
Martin Stjernholm | 040e044 | 2021-06-07 23:18:56 +0100 | [diff] [blame] | 51 | build/soong/soong_ui.bash --make-mode --soong-only "$@" |