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