blob: 89e72b265d5b3f6d23bd7fe4a59afcf20ded4389 [file] [log] [blame]
Alex Lighta02094f2018-12-11 10:41:52 -08001#!/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
23if [[ -z $ANDROID_BUILD_TOP ]]; then
24 pushd .
25else
26 pushd $ANDROID_BUILD_TOP
27fi
28
29if [ ! -d art ]; then
30 echo "Script needs to be run at the root of the android tree"
31 exit 1
32fi
33
34source 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.
Alex Lightba2add12020-03-09 13:48:20 -070038# Lunch since it seems we cannot find the build-number otherwise.
39lunch aosp_x86-eng
Andreas Gampedb265692019-07-15 16:11:20 -070040build/soong/soong_ui.bash --make-mode nothing
Alex Lighta6ea6022019-01-29 11:02:03 -080041
Alex Lighta02094f2018-12-11 10:41:52 -080042if [ $? != 0 ]; then
43 exit 1
44fi
45
46out_dir=$(get_build_var OUT_DIR)
47host_out=$(get_build_var HOST_OUT)
48
49# TODO(b/31559095) Figure out a better way to do this.
50#
51# There is no good way to force soong to generate host-bionic builds currently
52# so this is a hacky workaround.
53tmp_soong_var=$(mktemp --tmpdir soong.variables.bak.XXXXXX)
Alex Lightba2add12020-03-09 13:48:20 -070054tmp_build_number=$(cat ${out_dir}/soong/build_number.txt)
Alex Lighta02094f2018-12-11 10:41:52 -080055
56cat $out_dir/soong/soong.variables > ${tmp_soong_var}
Alex Lightcefcbc02018-12-21 09:45:03 -080057
Alex Lighta6ea6022019-01-29 11:02:03 -080058# See comment above about b/123645297 for why we cannot just do m clean. Clear
59# out all files except for intermediates and installed files.
60find $out_dir/ -maxdepth 1 -mindepth 1 \
61 -not -name soong \
62 -not -name host \
63 -not -name target | xargs -I '{}' rm -rf '{}'
64find $out_dir/soong/ -maxdepth 1 -mindepth 1 \
65 -not -name .intermediates \
66 -not -name host \
67 -not -name target | xargs -I '{}' rm -rf '{}'
Alex Lighta02094f2018-12-11 10:41:52 -080068
69python3 <<END - ${tmp_soong_var} ${out_dir}/soong/soong.variables
70import json
71import sys
72x = json.load(open(sys.argv[1]))
73x['Allow_missing_dependencies'] = True
74x['HostArch'] = 'x86_64'
75x['CrossHost'] = 'linux_bionic'
76x['CrossHostArch'] = 'x86_64'
77if 'CrossHostSecondaryArch' in x:
78 del x['CrossHostSecondaryArch']
Colin Cross092f7992019-05-14 11:20:49 -070079if 'DexpreoptGlobalConfig' in x:
80 del x['DexpreoptGlobalConfig']
Alex Lighta02094f2018-12-11 10:41:52 -080081json.dump(x, open(sys.argv[2], mode='w'))
82END
83
84rm $tmp_soong_var
85
Alex Light3cddf452019-05-22 11:22:31 -070086# Write a new build-number
Alex Lightba2add12020-03-09 13:48:20 -070087echo ${tmp_build_number}_SOONG_ONLY_BUILD > ${out_dir}/soong/build_number.txt
Alex Light3cddf452019-05-22 11:22:31 -070088
Alex Lighta02094f2018-12-11 10:41:52 -080089build/soong/soong_ui.bash --make-mode --skip-make $@