Remove Java PATH check, deprecate using PATH in Kati

The Java PATH fixup is now handled within soong_ui, along with the
values of ANDROID_JAVA_HOME based on OVERRIDE_ANDROID_JAVA_HOME /
EXPERIMENTAL_USE_OPENJDK9.

Mark PATH as deprecated, so that any reads/writes will cause warnings.
This will be switched to obsolete once it's verified that there are no
more users.

Using PATH within Kati means that we've got to rebuild the ninja files
whenever your PATH changes, which is not ideal, especially since some of
the envsetup functions can change your PATH. In most cases you only need
to use PATH within the bash portions of the build rules ($${PATH}), which
isn't treated as a make variable, so won't produce an error.

I'm also planning on replacing PATH in a future change with our own
directory that has placeholders for everything in your PATH. This will
let us remove tools that shouldn't be used from the build.

Test: m nothing
Test: build/soong/build_test.bash on AOSP and internal master
Change-Id: I18d8d19cfba313ff9176345bf73ac34e8dbebfbb
This commit is contained in:
Dan Willemsen 2017-10-30 13:41:53 -07:00
parent 90879f50ea
commit 2ec3e4a257
2 changed files with 3 additions and 27 deletions

View File

@ -1,10 +1,6 @@
# Selects a Java compiler.
#
# Inputs:
# OVERRIDE_ANDROID_JAVA_HOME -- alternate location to use for jdk
#
# Outputs:
# ANDROID_JAVA_HOME -- Directory that contains JDK
# ANDROID_JAVA_TOOLCHAIN -- Directory that contains javac and other java tools
#
@ -16,19 +12,7 @@ ifdef TARGET_BUILD_APPS
endif
endif
ifneq ($(OVERRIDE_ANDROID_JAVA_HOME),)
# Use this build toolchain instead of the bundled one.
ANDROID_JAVA_HOME := $(OVERRIDE_ANDROID_JAVA_HOME)
else # !OVERRIDE_ANDROID_JAVA_HOME
ifneq ($(EXPERIMENTAL_USE_OPENJDK9),)
ANDROID_JAVA_HOME := prebuilts/jdk/jdk9/$(HOST_PREBUILT_TAG)
else
ANDROID_JAVA_HOME := prebuilts/jdk/jdk8/$(HOST_PREBUILT_TAG)
endif
endif
ANDROID_JAVA_TOOLCHAIN := $(ANDROID_JAVA_HOME)/bin
export JAVA_HOME := $(abspath $(ANDROID_JAVA_HOME))
# TODO(ccross): remove this, it is needed for now because it is used by
# config.mk before makevars from soong are loaded

View File

@ -58,6 +58,9 @@ backslash := $(patsubst %a,%,$(backslash))
# If a rule fails, delete $@.
.DELETE_ON_ERROR:
# Mark variables deprecated/obsolete
$(KATI_deprecated_var PATH,Do not use PATH directly)
# Used to force goals to build. Only use for conditionally defined goals.
.PHONY: FORCE
FORCE:
@ -860,17 +863,6 @@ else
APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
endif
# Put java first on the path
# TODO(ccross): remove this once tools run during the build no longer depend on
# finding java in the path
ifeq (,$(strip $(CALLED_FROM_SETUP)))
ifneq ($(shell which java),$(abspath $(ANDROID_JAVA_TOOLCHAIN)/java))
$(warning Found incorrect java $(shell which java) in $$PATH)
$(warning Adding $(abspath $(ANDROID_JAVA_TOOLCHAIN)) to $$PATH)
export PATH:=$(abspath $(ANDROID_JAVA_TOOLCHAIN)):$(PATH)
endif
endif
# Projects clean of compiler warnings should be compiled with -Werror.
# If most modules in a directory such as external/ have warnings,
# the directory should be in ANDROID_WARNING_ALLOWED_PROJECTS list.