Use TARGET_BUILD_UNBUNDLED in ART test builds.

This is the way to disable assumptions in the build system that a full
system image is to be built.

Test: rm -rf out && \
      art/test/testrunner/run_build_test_target.py art-linux-bionic-x64
Test: art/test/testrunner/testrunner.py --target --64 --optimizing && \
      art/tools/run-gtests.sh
  in test chroot on device
Test: art/tools/golem/build-target.sh --machine-type=android-armv8 --golem=art-jit
Bug: 157549171
Change-Id: I053d38985a9a840cac36cabc0bb5e1f945e9ca7f
diff --git a/tools/build_linux_bionic.sh b/tools/build_linux_bionic.sh
index 89e72b2..5dc38e2 100755
--- a/tools/build_linux_bionic.sh
+++ b/tools/build_linux_bionic.sh
@@ -31,13 +31,15 @@
   exit 1
 fi
 
+soong_args="TARGET_BUILD_UNBUNDLED=true"
+
 source build/envsetup.sh >&/dev/null # for get_build_var
 # Soong needs a bunch of variables set and will not run if they are missing.
 # The default values of these variables is only contained in make, so use
 # nothing to create the variables then remove all the other artifacts.
 # Lunch since it seems we cannot find the build-number otherwise.
 lunch aosp_x86-eng
-build/soong/soong_ui.bash --make-mode nothing
+build/soong/soong_ui.bash --make-mode $soong_args nothing
 
 if [ $? != 0 ]; then
   exit 1
@@ -86,4 +88,4 @@
 # Write a new build-number
 echo ${tmp_build_number}_SOONG_ONLY_BUILD > ${out_dir}/soong/build_number.txt
 
-build/soong/soong_ui.bash --make-mode --skip-make $@
+build/soong/soong_ui.bash --make-mode --skip-make $soong_args $@
diff --git a/tools/build_linux_bionic_tests.sh b/tools/build_linux_bionic_tests.sh
index c834dd5..2c1084c 100755
--- a/tools/build_linux_bionic_tests.sh
+++ b/tools/build_linux_bionic_tests.sh
@@ -26,6 +26,8 @@
   exit 1
 fi
 
+soong_args="TARGET_BUILD_UNBUNDLED=true"
+
 source build/envsetup.sh >&/dev/null # for get_build_var
 
 out_dir=$(get_build_var OUT_DIR)
@@ -38,7 +40,7 @@
 
 # First build all the targets still in .mk files (also build normal glibc host
 # targets so we know what's needed to run the tests).
-build/soong/soong_ui.bash --make-mode "$@" test-art-host-run-test-dependencies build-art-host-tests
+build/soong/soong_ui.bash --make-mode $soong_args "$@" test-art-host-run-test-dependencies build-art-host-tests
 if [ $? != 0 ]; then
   exit 1
 fi
@@ -88,7 +90,7 @@
 
 echo building ${bionic_targets[*]}
 
-build/soong/soong_ui.bash --make-mode --skip-make "$@" ${bionic_targets[*]}
+build/soong/soong_ui.bash --make-mode --skip-make $soong_args "$@" ${bionic_targets[*]}
 ret=$?
 
 mv $tmp_soong_var $out_dir/soong/soong.variables
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index dde156d..fd6c6ca 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -63,7 +63,7 @@
 done
 
 # Allow to build successfully in master-art.
-extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true"
+extra_args="SOONG_ALLOW_MISSING_DEPENDENCIES=true TARGET_BUILD_UNBUNDLED=true"
 
 apexes=(
   "com.android.art.testing"
diff --git a/tools/golem/build-target.sh b/tools/golem/build-target.sh
index 45c9125..3219cc2 100755
--- a/tools/golem/build-target.sh
+++ b/tools/golem/build-target.sh
@@ -269,6 +269,8 @@
   execute lunch "$lunch_target"
   # Golem uses master-art repository which is missing a lot of other libraries.
   setenv SOONG_ALLOW_MISSING_DEPENDENCIES true
+  # Let the build system know we're not aiming to do a full platform build.
+  setenv TARGET_BUILD_UNBUNDLED true
   # Golem may be missing tools such as javac from its path.
   setenv_escape PATH "/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH" '/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH'
 else