Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [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 | |
| 18 | if [[ -z $ANDROID_BUILD_TOP ]]; then |
| 19 | pushd . |
| 20 | else |
| 21 | pushd $ANDROID_BUILD_TOP |
| 22 | fi |
| 23 | |
| 24 | if [ ! -d art ]; then |
| 25 | echo "Script needs to be run at the root of the android tree" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
Martin Stjernholm | 6906910 | 2020-06-16 13:26:40 +0100 | [diff] [blame] | 29 | soong_args="" |
| 30 | |
| 31 | # Switch the build system to unbundled mode in the reduced manifest branch. |
Martin Stjernholm | 6906910 | 2020-06-16 13:26:40 +0100 | [diff] [blame] | 32 | if [ ! -d frameworks/base ]; then |
| 33 | soong_args="$soong_args TARGET_BUILD_UNBUNDLED=true" |
| 34 | fi |
| 35 | |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 36 | source build/envsetup.sh >&/dev/null # for get_build_var |
| 37 | |
| 38 | out_dir=$(get_build_var OUT_DIR) |
Alex Light | cbc64c8 | 2018-11-19 05:09:47 -0800 | [diff] [blame] | 39 | host_out=$(get_build_var HOST_OUT) |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 40 | |
| 41 | # TODO(b/31559095) Figure out a better way to do this. |
| 42 | # |
| 43 | # There is no good way to force soong to generate host-bionic builds currently |
| 44 | # so this is a hacky workaround. |
| 45 | |
| 46 | # First build all the targets still in .mk files (also build normal glibc host |
| 47 | # targets so we know what's needed to run the tests). |
Martin Stjernholm | 6906910 | 2020-06-16 13:26:40 +0100 | [diff] [blame] | 48 | build/soong/soong_ui.bash --make-mode $soong_args "$@" test-art-host-run-test-dependencies build-art-host-tests |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 49 | if [ $? != 0 ]; then |
| 50 | exit 1 |
| 51 | fi |
| 52 | |
| 53 | tmp_soong_var=$(mktemp --tmpdir soong.variables.bak.XXXXXX) |
| 54 | |
| 55 | echo "Saving soong.variables to " $tmp_soong_var |
| 56 | cat $out_dir/soong/soong.variables > ${tmp_soong_var} |
| 57 | python3 <<END - ${tmp_soong_var} ${out_dir}/soong/soong.variables |
| 58 | import json |
| 59 | import sys |
| 60 | x = json.load(open(sys.argv[1])) |
| 61 | x['Allow_missing_dependencies'] = True |
| 62 | x['HostArch'] = 'x86_64' |
| 63 | x['CrossHost'] = 'linux_bionic' |
| 64 | x['CrossHostArch'] = 'x86_64' |
| 65 | if 'CrossHostSecondaryArch' in x: |
| 66 | del x['CrossHostSecondaryArch'] |
| 67 | json.dump(x, open(sys.argv[2], mode='w')) |
| 68 | END |
| 69 | if [ $? != 0 ]; then |
| 70 | mv $tmp_soong_var $out_dir/soong/soong.variables |
| 71 | exit 2 |
| 72 | fi |
| 73 | |
| 74 | soong_out=$out_dir/soong/host/linux_bionic-x86 |
| 75 | declare -a bionic_targets |
| 76 | # These are the binaries actually used in tests. Since some of the files are |
| 77 | # java targets or 32 bit we cannot just do the same find for the bin files. |
| 78 | # |
| 79 | # We look at what the earlier build generated to figure out what to ask soong to |
| 80 | # build since we cannot use the .mk defined phony targets. |
| 81 | bionic_targets=( |
| 82 | $soong_out/bin/dalvikvm |
| 83 | $soong_out/bin/dalvikvm64 |
| 84 | $soong_out/bin/dex2oat |
| 85 | $soong_out/bin/dex2oatd |
| 86 | $soong_out/bin/profman |
| 87 | $soong_out/bin/profmand |
| 88 | $soong_out/bin/hiddenapi |
| 89 | $soong_out/bin/hprof-conv |
Andreas Gampe | 148c160 | 2019-06-10 16:47:46 -0700 | [diff] [blame] | 90 | $soong_out/bin/signal_dumper |
Ivan Lozano | e3de71c | 2020-02-18 15:52:56 -0500 | [diff] [blame] | 91 | $soong_out/lib64/libclang_rt.ubsan_standalone-x86_64-android.so |
David Srbecky | 0c0f302 | 2020-02-13 15:53:01 +0000 | [diff] [blame] | 92 | $(find $host_out/apex/com.android.art.host.zipapex -type f | sed "s:$host_out:$soong_out:g") |
Alex Light | cbc64c8 | 2018-11-19 05:09:47 -0800 | [diff] [blame] | 93 | $(find $host_out/lib64 -type f | sed "s:$host_out:$soong_out:g") |
| 94 | $(find $host_out/nativetest64 -type f | sed "s:$host_out:$soong_out:g")) |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 95 | |
| 96 | echo building ${bionic_targets[*]} |
| 97 | |
Colin Cross | 0a42f1e | 2021-10-28 16:31:03 -0700 | [diff] [blame] | 98 | build/soong/soong_ui.bash --make-mode --skip-config --soong-only $soong_args "$@" ${bionic_targets[*]} |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 99 | ret=$? |
| 100 | |
| 101 | mv $tmp_soong_var $out_dir/soong/soong.variables |
| 102 | |
| 103 | # Having built with host-bionic confuses soong somewhat by making it think the |
| 104 | # linux_bionic targets are needed for art phony targets like |
| 105 | # test-art-host-run-test-dependencies. To work around this blow away all |
| 106 | # ninja files in OUT_DIR. The build system is smart enough to not need to |
| 107 | # rebuild stuff so this should be fine. |
| 108 | rm -f $OUT_DIR/*.ninja $OUT_DIR/soong/*.ninja |
| 109 | |
| 110 | popd |
| 111 | |
| 112 | exit $ret |