aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2013-11-13 15:05:15 -0800
committerNarayan Kamath <narayan@google.com>2014-04-02 10:45:17 +0000
commit8d45e51803c0ca5194b07e493cb231e3a52db2ca (patch)
treeb892efb9c62c9f8b1ef9088efcdc8655f2b44d7b
parent2f5de9f50460bbd369abd4218e746553f15f24fb (diff)
downloadbuild-8d45e51803c0ca5194b07e493cb231e3a52db2ca.tar.gz
Call "java[c] -version" only once
and print out the full output if error occurs. Bug: 11672548 (cherry picked from 7b66d366bf5c469130f71d0870424fcd265e0301) Change-Id: I8e2f2ffa2f28146405273b04667efe3c8d1c03ad
-rw-r--r--core/main.mk23
1 files changed, 14 insertions, 9 deletions
diff --git a/core/main.mk b/core/main.mk
index 2d42a14e6d..418c6739e3 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -151,22 +151,26 @@ requires_openjdk := true
endif
endif
+java_version_str := $(shell java -version 2>&1)
+javac_version_str := $(shell javac -version 2>&1)
+
+# Check for the current jdk
ifeq ($(requires_openjdk), true)
# The user asked for java7 openjdk, so check that the host
# java version is really openjdk
-ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
+ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
$(info ************************************************************)
$(info You are attempting to build with an unsupported JDK.)
$(info $(space))
$(info This build requires OpenJDK, but you are using:)
-$(info $(shell java -version 2>&1 | head -n 2).)
+$(info $(java_version_str).)
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif # java version is not OpenJdk
else # if requires_openjdk
-ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
+ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
$(info ************************************************************)
$(info You are attempting to build with an unsupported JDK.)
$(info $(space))
@@ -183,13 +187,13 @@ endif # if requires_openjdk
ifneq ($(EXPERIMENTAL_USE_JAVA7),)
required_version := "1.7.x"
required_javac_version := "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 )
+java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]' | head -n 1)
+javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]' | head -n 1)
else # if EXPERIMENTAL_USE_JAVA7
required_version := "1.6.x"
required_javac_version := "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)
+java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.6[\. "$$]' | head -n 1)
+javac_version := $(shell echo '$(javac_version_str)' | head -n 1 | grep '[ "]1\.6[\. "$$]' | head -n 1)
endif # if EXPERIMENTAL_USE_JAVA7
ifeq ($(strip $(java_version)),)
@@ -197,7 +201,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 | grep '^java' | head -n 1).)
+$(info Your version is: $(java_version_str).)
$(info The required version is: $(required_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
@@ -212,7 +216,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 | grep '^javac' | head -n 1).)
+$(info Your version is: $(javac_version_str).)
$(info The required version is: $(required_javac_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
@@ -221,6 +225,7 @@ $(info ************************************************************)
$(error stop)
endif
+
ifndef BUILD_EMULATOR
ifeq (darwin,$(HOST_OS))
GCC_REALPATH = $(realpath $(shell which $(HOST_CC)))