From fdf89cd57521bfe45df6ad7d2caefcb1fa5b7438 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 5 Feb 2016 18:24:17 -0800 Subject: [PATCH] Disable java when JAVA_NOT_REQUIRED is set Change-Id: Id3056cde93302be20000bf7af33aeed0fa8fdf52 --- core/config.mk | 8 ++++++++ core/main.mk | 10 +++++----- core/no_java_path/jar | 1 + core/no_java_path/jarsigner | 1 + core/no_java_path/java | 4 ++++ core/no_java_path/javac | 1 + core/no_java_path/keytool | 1 + 7 files changed, 21 insertions(+), 5 deletions(-) create mode 120000 core/no_java_path/jar create mode 120000 core/no_java_path/jarsigner create mode 100755 core/no_java_path/java create mode 120000 core/no_java_path/javac create mode 120000 core/no_java_path/keytool diff --git a/core/config.mk b/core/config.mk index 0034c4324..5485fe2f5 100644 --- a/core/config.mk +++ b/core/config.mk @@ -844,4 +844,12 @@ endif RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20 RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13 +ifeq ($(JAVA_NOT_REQUIRED),true) +# Remove java and tools from our path so that we make sure nobody uses them. +unexport ANDROID_JAVA_HOME +unexport JAVA_HOME +export ANDROID_BUILD_PATHS:=$(abspath $(BUILD_SYSTEM)/no_java_path):$(ANDROID_BUILD_PATHS) +export PATH:=$(abspath $(BUILD_SYSTEM)/no_java_path):$(PATH) +endif + include $(BUILD_SYSTEM)/dumpvar.mk diff --git a/core/main.mk b/core/main.mk index 923e677f2..ac71867fa 100644 --- a/core/main.mk +++ b/core/main.mk @@ -57,9 +57,6 @@ TOPDIR := BUILD_SYSTEM := $(TOPDIR)build/core -# Ensure JAVA_NOT_REQUIRED is not set externally. -JAVA_NOT_REQUIRED := false - # This is the default target. It must be the first declared target. .PHONY: droid DEFAULT_GOAL := droid @@ -148,8 +145,9 @@ include $(BUILD_SYSTEM)/cleanbuild.mk -include vendor/google/build/config.mk VERSION_CHECK_SEQUENCE_NUMBER := 6 +JAVA_NOT_REQUIRED_CHECKED := -include $(OUT_DIR)/versions_checked.mk -ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED)) +ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER)$(JAVA_NOT_REQUIRED),$(VERSIONS_CHECKED)$(JAVA_NOT_REQUIRED_CHECKED)) $(info Checking build tools versions...) @@ -180,7 +178,7 @@ $(warning ************************************************************) $(error Directory names containing spaces not supported) endif -ifeq ($(JAVA_NOT_REQUIRED), false) +ifneq ($(JAVA_NOT_REQUIRED),true) java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1) javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1) @@ -271,6 +269,8 @@ $(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \ > $(OUT_DIR)/versions_checked.mk) $(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \ >> $(OUT_DIR)/versions_checked.mk) +$(shell echo 'JAVA_NOT_REQUIRED_CHECKED := $(JAVA_NOT_REQUIRED)' \ + >> $(OUT_DIR)/versions_checked.mk) endif # These are the modifier targets that don't do anything themselves, but diff --git a/core/no_java_path/jar b/core/no_java_path/jar new file mode 120000 index 000000000..858639778 --- /dev/null +++ b/core/no_java_path/jar @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/core/no_java_path/jarsigner b/core/no_java_path/jarsigner new file mode 120000 index 000000000..858639778 --- /dev/null +++ b/core/no_java_path/jarsigner @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/core/no_java_path/java b/core/no_java_path/java new file mode 100755 index 000000000..f3422f330 --- /dev/null +++ b/core/no_java_path/java @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Error: JAVA_NOT_REQUIRED=true, $(basename $0) is unavailable." 1>&2 +exit 1 diff --git a/core/no_java_path/javac b/core/no_java_path/javac new file mode 120000 index 000000000..858639778 --- /dev/null +++ b/core/no_java_path/javac @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/core/no_java_path/keytool b/core/no_java_path/keytool new file mode 120000 index 000000000..858639778 --- /dev/null +++ b/core/no_java_path/keytool @@ -0,0 +1 @@ +java \ No newline at end of file