Files
build/core/combo/javac.mk
Colin Cross 3a1544ab1a Make JAVA_HOME absolute inside build
Export JAVA_HOME as an absolute path to commands running inside
a build.

Should fix errors invoking gradle from inside a build:
ERROR: JAVA_HOME is set to an invalid directory: prebuilts/jdk/jdk8/linux-x86
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Test: treehugger
Change-Id: I16e4482b2d74ede0843715be3b08c65ce33cf403
2017-07-24 19:27:31 -07:00

50 lines
1.3 KiB
Makefile

# Selects a Java compiler.
#
# Inputs:
# CUSTOM_JAVA_COMPILER -- "eclipse", "openjdk". or nothing for the system
# default
# ALTERNATE_JAVAC -- the alternate java compiler to use
#
# Outputs:
# COMMON_JAVAC -- Java compiler command with common arguments
#
ifndef ANDROID_COMPILE_WITH_JACK
# Defines if compilation with jack is enabled by default.
ANDROID_COMPILE_WITH_JACK := true
endif
common_jdk_flags := -Xmaxerrs 9999999
ANDROID_JAVA_HOME := prebuilts/jdk/jdk8/$(HOST_PREBUILT_TAG)
ANDROID_JAVA_TOOLCHAIN := $(ANDROID_JAVA_HOME)/bin
export JAVA_HOME := $(abspath $(ANDROID_JAVA_HOME))
# Use the indexer wrapper to index the codebase instead of the javac compiler
ifeq ($(ALTERNATE_JAVAC),)
JAVACC := $(ANDROID_JAVA_TOOLCHAIN)/javac
else
JAVACC := $(ALTERNATE_JAVAC)
endif
JAVA := $(ANDROID_JAVA_TOOLCHAIN)/java
JAVADOC := $(ANDROID_JAVA_TOOLCHAIN)/javadoc
JAR := $(ANDROID_JAVA_TOOLCHAIN)/jar
# The actual compiler can be wrapped by setting the JAVAC_WRAPPER var.
ifdef JAVAC_WRAPPER
ifneq ($(JAVAC_WRAPPER),$(firstword $(JAVACC)))
JAVACC := $(JAVAC_WRAPPER) $(JAVACC)
endif
endif
COMMON_JAVAC := $(JAVACC) -J-Xmx2048M $(common_jdk_flags)
GLOBAL_JAVAC_DEBUG_FLAGS := -g
HOST_JAVAC ?= $(COMMON_JAVAC)
TARGET_JAVAC ?= $(COMMON_JAVAC)
#$(info HOST_JAVAC=$(HOST_JAVAC))
#$(info TARGET_JAVAC=$(TARGET_JAVAC))