Allow builds with costum toolchains.
Android bundles an OpenJDK-derived toolchain to avoid issues with
unsupported toolchains. For development / experiment purposes, this
CL the toolchain to be overridden via OVERRIDE_ANDROID_JAVA_HOME.
It is an error for OVERRIDE_ANDROID_JAVA_HOME to be set but not
point to a valid toolchain, but this error is not explicitly
checked for.
Bug: 38177295
Test: Treehugger
Change-Id: I72f641f560501e498f9c86a4380f19941fca11ad
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index 36ac2aa..7d19279 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -16,7 +16,12 @@
common_jdk_flags := -Xmaxerrs 9999999
+ifeq ($(OVERRIDE_ANDROID_JAVA_HOME),)
ANDROID_JAVA_HOME := prebuilts/jdk/jdk8/$(HOST_PREBUILT_TAG)
+else
+# Use this build toolchain instead of the bundled one.
+ANDROID_JAVA_HOME := $(OVERRIDE_ANDROID_JAVA_HOME)
+endif
ANDROID_JAVA_TOOLCHAIN := $(ANDROID_JAVA_HOME)/bin
export JAVA_HOME := $(abspath $(ANDROID_JAVA_HOME))