Alex Light | a02094f | 2018-12-11 10:41:52 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2018 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # This will build a target using linux_bionic. It can be called with normal make |
| 18 | # flags. |
| 19 | # |
| 20 | # TODO This runs a 'm clean' prior to building the targets in order to ensure |
| 21 | # that obsolete kati files don't mess up the build. |
| 22 | |
| 23 | if [[ -z $ANDROID_BUILD_TOP ]]; then |
| 24 | pushd . |
| 25 | else |
| 26 | pushd $ANDROID_BUILD_TOP |
| 27 | fi |
| 28 | |
| 29 | if [ ! -d art ]; then |
| 30 | echo "Script needs to be run at the root of the android tree" |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | source build/envsetup.sh >&/dev/null # for get_build_var |
| 35 | # Soong needs a bunch of variables set and will not run if they are missing. |
| 36 | # The default values of these variables is only contained in make, so use |
| 37 | # nothing to create the variables then remove all the other artifacts. |
| 38 | build/soong/soong_ui.bash --make-mode nothing |
| 39 | if [ $? != 0 ]; then |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | out_dir=$(get_build_var OUT_DIR) |
| 44 | host_out=$(get_build_var HOST_OUT) |
Alex Light | cefcbc0 | 2018-12-21 09:45:03 -0800 | [diff] [blame^] | 45 | mk_product_out=$(get_build_var PRODUCT_OUT) |
Alex Light | a02094f | 2018-12-11 10:41:52 -0800 | [diff] [blame] | 46 | |
| 47 | # TODO(b/31559095) Figure out a better way to do this. |
| 48 | # |
| 49 | # There is no good way to force soong to generate host-bionic builds currently |
| 50 | # so this is a hacky workaround. |
| 51 | tmp_soong_var=$(mktemp --tmpdir soong.variables.bak.XXXXXX) |
| 52 | |
| 53 | cat $out_dir/soong/soong.variables > ${tmp_soong_var} |
| 54 | build/soong/soong_ui.bash --make-mode clean |
| 55 | mkdir -p $out_dir/soong |
Alex Light | cefcbc0 | 2018-12-21 09:45:03 -0800 | [diff] [blame^] | 56 | mkdir -p $mk_product_out |
| 57 | |
| 58 | # TODO(b/31559095) Soong will panic if this file isn't present. It contains |
| 59 | # information from MAKE needed to let soong handle the invocation of dex2oat. |
| 60 | # This would be great to have but for now isn't needed. |
| 61 | echo "{}" > $mk_product_out/dexpreopt.config |
Alex Light | a02094f | 2018-12-11 10:41:52 -0800 | [diff] [blame] | 62 | |
| 63 | python3 <<END - ${tmp_soong_var} ${out_dir}/soong/soong.variables |
| 64 | import json |
| 65 | import sys |
| 66 | x = json.load(open(sys.argv[1])) |
| 67 | x['Allow_missing_dependencies'] = True |
| 68 | x['HostArch'] = 'x86_64' |
| 69 | x['CrossHost'] = 'linux_bionic' |
| 70 | x['CrossHostArch'] = 'x86_64' |
| 71 | if 'CrossHostSecondaryArch' in x: |
| 72 | del x['CrossHostSecondaryArch'] |
| 73 | json.dump(x, open(sys.argv[2], mode='w')) |
| 74 | END |
| 75 | |
| 76 | rm $tmp_soong_var |
| 77 | |
| 78 | build/soong/soong_ui.bash --make-mode --skip-make $@ |