A few more Java7 related clean ups.
- Separate SDK checking from version checking and make messages clearer. - Add explicit source & target versions for javac to make things clearer. - Rename flag from EXPERIMENTAL_USE_JAVA7_OPENJDK to EXPERIMENTAL_USE_JAVA7. - Allow Oracle JDK 1.7 to be used on Mac OS, since there's no official OpenJDK support for that platform. Change-Id: I454d2c917ed78f03ec7559a99659fefe7e7d50f3
This commit is contained in:
@@ -8,10 +8,10 @@
|
|||||||
# COMMON_JAVAC -- Java compiler command with common arguments
|
# COMMON_JAVAC -- Java compiler command with common arguments
|
||||||
#
|
#
|
||||||
|
|
||||||
ifeq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
|
ifeq ($(EXPERIMENTAL_USE_JAVA7),)
|
||||||
common_flags := -target 1.5 -Xmaxerrs 9999999
|
common_flags := -target 1.5 -Xmaxerrs 9999999
|
||||||
else
|
else
|
||||||
common_flags := -Xmaxerrs 9999999
|
common_flags := -source 1.7 -target 1.7 -Xmaxerrs 9999999
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
42
core/main.mk
42
core/main.mk
@@ -138,18 +138,30 @@ $(warning ************************************************************)
|
|||||||
$(error Directory names containing spaces not supported)
|
$(error Directory names containing spaces not supported)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Check for the current jdk
|
# Check for the current JDK.
|
||||||
ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
|
#
|
||||||
# The user asked for java7 openjdk, so check that the host
|
# For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
|
||||||
# java version is really openjdk
|
# For Java 1.6, we require Oracle for all host OSes.
|
||||||
|
requires_openjdk := false
|
||||||
|
ifneq ($(EXPERIMENTAL_USE_JAVA7),)
|
||||||
|
ifeq ($(HOST_OS), linux)
|
||||||
|
requires_openjdk := true
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(requires_openjdk), true)
|
||||||
ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
|
ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
|
||||||
$(info ************************************************************)
|
$(info ************************************************************)
|
||||||
$(info You asked for an OpenJDK 7 build but your version is)
|
$(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 $(shell java -version 2>&1 | head -n 2).)
|
||||||
|
$(info Please follow the machine setup instructions at)
|
||||||
|
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
|
||||||
$(info ************************************************************)
|
$(info ************************************************************)
|
||||||
$(error stop)
|
$(error stop)
|
||||||
endif # java version is not OpenJdk
|
endif # java version is not OpenJdk
|
||||||
else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
|
else # if requires_openjdk
|
||||||
ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
|
ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
|
||||||
$(info ************************************************************)
|
$(info ************************************************************)
|
||||||
$(info You are attempting to build with an unsupported JDK.)
|
$(info You are attempting to build with an unsupported JDK.)
|
||||||
@@ -160,21 +172,19 @@ $(info $(space)$(space)$(space)$(space)https://source.android.com/source/downloa
|
|||||||
$(info ************************************************************)
|
$(info ************************************************************)
|
||||||
$(error stop)
|
$(error stop)
|
||||||
endif # java version is not Sun Oracle JDK
|
endif # java version is not Sun Oracle JDK
|
||||||
endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
|
endif # if requires_openjdk
|
||||||
|
|
||||||
# Check for the correct version of java, should be 1.7 if
|
# Check for the correct version of java, should be 1.7 if
|
||||||
# EXPERIMENTAL_USE_JAVA7_OPENJDK is set, 1.6 otherwise.
|
# EXPERIMENTAL_USE_JAVA7 is set, 1.6 otherwise.
|
||||||
ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
|
ifneq ($(EXPERIMENTAL_USE_JAVA7),)
|
||||||
required_version := "OpenJDK 1.7"
|
required_version := "1.7.x"
|
||||||
required_javac_version := "1.7"
|
|
||||||
java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.7[\. "$$]')
|
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[\. "$$]')
|
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')
|
||||||
else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
|
else # if EXPERIMENTAL_USE_JAVA7
|
||||||
required_version := "JavaSE 1.6"
|
required_version := "1.6.x"
|
||||||
required_javac_version := "1.6"
|
|
||||||
java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]')
|
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[\. "$$]')
|
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
|
||||||
endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
|
endif # if EXPERIMENTAL_USE_JAVA7
|
||||||
|
|
||||||
ifeq ($(strip $(java_version)),)
|
ifeq ($(strip $(java_version)),)
|
||||||
$(info ************************************************************)
|
$(info ************************************************************)
|
||||||
@@ -197,7 +207,7 @@ $(info You are attempting to build with the incorrect version)
|
|||||||
$(info of javac.)
|
$(info of javac.)
|
||||||
$(info $(space))
|
$(info $(space))
|
||||||
$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
|
$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
|
||||||
$(info The required version is: $(required_javac_version))
|
$(info The required version is: $(required_java_version))
|
||||||
$(info $(space))
|
$(info $(space))
|
||||||
$(info Please follow the machine setup instructions at)
|
$(info Please follow the machine setup instructions at)
|
||||||
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
|
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
|
||||||
|
Reference in New Issue
Block a user