Create the hiddenapi files if frameworks/base is missing.

This is required to build ART for target with the master-art
manifest.

Change-Id: I9666aa0966a17199b6d33ae75591dfc15ae6731a
diff --git a/Android.mk b/Android.mk
index 0a90a0b..361ceec 100644
--- a/Android.mk
+++ b/Android.mk
@@ -447,6 +447,19 @@
 include $(BUILD_PHONY_PACKAGE)
 endif
 
+# Create dummy hidden API lists which are normally generated by the framework
+# but which we do not have in the master-art manifest.
+# We need to execute this now to ensure Makefile rules depending on these files can
+# be constructed.
+define build-art-hiddenapi
+$(shell if [ ! -d frameworks/base ]; then \
+  mkdir -p ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING; \
+	touch ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-{blacklist,dark-greylist,light-greylist}.txt; \
+  fi;)
+endef
+
+$(eval $(call build-art-hiddenapi))
+
 ########################################################################
 # "m build-art" for quick minimal build
 .PHONY: build-art
@@ -460,6 +473,7 @@
 
 ########################################################################
 # Phony target for only building what go/lem requires for pushing ART on /data.
+
 .PHONY: build-art-target-golem
 # Also include libartbenchmark, we always include it when running golem.
 # libstdc++ is needed when building for ART_TARGET_LINUX.
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index 8956e98..a201755 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -74,14 +74,7 @@
   make_command+=" dx-tests"
   mode_suffix="-host"
 elif [[ $mode == "target" ]]; then
-  # Create dummy hidden API lists which are normally generated by the framework
-  # but which we do not have in the buildbot manifest. These are empty because
-  # we do not want to enforce these rules in the buildbots anyway.
-  hiddenapi_out_dir=${out_dir}/target/common/obj/PACKAGING
-  make_command="mkdir -p ${hiddenapi_out_dir} && "
-  make_command+="touch ${hiddenapi_out_dir}/hiddenapi-{blacklist,dark-greylist,light-greylist}.txt && "
-
-  make_command+="make $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
+  make_command="make $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
   make_command+=" libjavacrypto-target libnetd_client-target linker toybox toolbox sh"
   make_command+=" ${out_dir}/host/linux-x86/bin/adb libstdc++ "
   make_command+=" ${out_dir}/target/product/${TARGET_PRODUCT}/system/etc/public.libraries.txt"