summaryrefslogtreecommitdiffstats
path: root/core/main.mk
diff options
context:
space:
mode:
authorPeter Ammon <pca@google.com>2014-03-31 15:36:02 -0700
committerPeter Ammon <pca@google.com>2014-03-31 15:36:02 -0700
commitbb406bf4c059fac41bd91038e7a2d2725068c057 (patch)
treee6ab13c0172d6d7704c76d0c787e79d7de099da4 /core/main.mk
parent1c380c13d9bd60eefb515ea2c0a33f900a81f970 (diff)
downloadbuild-bb406bf4c059fac41bd91038e7a2d2725068c057.zip
build-bb406bf4c059fac41bd91038e7a2d2725068c057.tar.gz
build-bb406bf4c059fac41bd91038e7a2d2725068c057.tar.bz2
Fix java version detection when _JAVA_OPTIONS is set.
_JAVA_OPTIONS is an environment variable that can be used to affect the behavior of java and javac. It is currently required to get Android to build on some configurations, where the default Java heap size is too small. Unfortunately, if _JAVA_OPTIONS is set, both java and javac will output its value to the console as the first line on every invocation, including trivial ones like java -version. This will confuse main.mk’s version detection, which only looks at the first line of output. Tweak the version detection to run grep before head, so that the _JAVA_OPTIONS line is filtered by the grep. Change-Id: I69aee52b56d27711b7d3087ec6b3ebab07ffc3af
Diffstat (limited to 'core/main.mk')
-rw-r--r--core/main.mk12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/main.mk b/core/main.mk
index 3c4fd94..6e9f75a 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -180,12 +180,12 @@ endif # if requires_openjdk
# EXPERIMENTAL_USE_JAVA7 is set, 1.6 otherwise.
ifneq ($(EXPERIMENTAL_USE_JAVA7),)
required_version := "1.7.x"
-java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.7[\. "$$]')
-javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')
+java_version := $(shell java -version 2>&1 | grep '^java .*[ "]1\.7[\. "$$]' | head -n 1)
+javac_version := $(shell javac -version 2>&1 | grep '[ "]1\.7[\. "$$]' | head -n 1 )
else # if EXPERIMENTAL_USE_JAVA7
required_version := "1.6.x"
-java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]')
-javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
+java_version := $(shell java -version 2>&1 | grep '^java .*[ "]1\.6[\. "$$]' | head -n 1)
+javac_version := $(shell javac -version 2>&1 | grep '[ "]1\.6[\. "$$]' | head -n 1)
endif # if EXPERIMENTAL_USE_JAVA7
ifeq ($(strip $(java_version)),)
@@ -193,7 +193,7 @@ $(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of java.)
$(info $(space))
-$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
+$(info Your version is: $(shell java -version 2>&1 | grep '^java' | head -n 1).)
$(info The required version is: $(required_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
@@ -208,7 +208,7 @@ $(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of javac.)
$(info $(space))
-$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
+$(info Your version is: $(shell javac -version 2>&1 | grep '^javac' | head -n 1).)
$(info The required version is: $(required_java_version))
$(info $(space))
$(info Please follow the machine setup instructions at)