Skip to content

Commit

Permalink
Add build flag to allow experimenting with new Java versions.
Browse files Browse the repository at this point in the history
	Change on 2019/01/24 by antoniocortes <antoniocortes@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=230758216
  • Loading branch information
antonio-cortes-perez committed Feb 22, 2019
1 parent 5c67b67 commit e37963f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
5 changes: 4 additions & 1 deletion cycle_finder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ RESOURCES = \
com/google/devtools/j2objc/reserved_names.txt

DIST_DEPS = $(JSR305_JAR) j2objc_annotations.jar
INTERNAL_DEPS = $(GUAVA_JAR) $(JAVAC_JAR) $(PROCYON_JARS) $(SCENELIB_JAR)
INTERNAL_DEPS = $(GUAVA_JAR) $(PROCYON_JARS) $(SCENELIB_JAR)
ifdef JAVA_8
INTERNAL_DEPS += $(JAVAC_JAR)
endif
JAR_DEPS_DIST = $(DIST_DEPS:%=$(DIST_JAR_DIR)/%) $(INTERNAL_DEPS:%=$(JAVA_DEPS_JAR_DIR)/%)
JAR_DEPS_PATH = $(subst $(eval) ,:,$(strip $(JAR_DEPS_DIST)))
JUNIT_JAR_DIST = $(DIST_JAR_DIR)/$(JUNIT_JAR)
Expand Down
4 changes: 3 additions & 1 deletion java_deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ INTERNAL_JARS = \
$(JSR305_SOURCE_JAR) $(JAVAX_INJECT_SOURCE_JAR) \
$(MOCKITO_SOURCE_JAR) \
$(JARJAR_JAR) \
$(JAVAC_JAR) \
$(PROTOBUF_JAR) \
$(PROCYON_JARS) \
$(SCENELIB_JAR) \
$(PLUME_UTIL_JAR)
ifdef JAVA_8
INTERNAL_JARS += $(JAVAC_JAR)
endif
DIST_JARS = $(DISTRIBUTION_JARS:%=$(DIST_JAR_DIR)/%)
DOCLET_JARS = $(DOCLAVA_JAR) $(JSILVER_JAR)
BUILD_DIR_JARS = $(DISTRIBUTION_JARS:%=$(BUILD_DIR)/%) $(INTERNAL_JARS:%=$(BUILD_DIR)/%)
Expand Down
12 changes: 8 additions & 4 deletions make/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ TRANSLATOR_DEPS = $(DIST_DIR)/j2objc $(DIST_JAR_DIR)/j2objc.jar

# Use Java 8 by default.
# TODO(tball): remove when Java 9 is supported.
JAVA_HOME = $(shell /usr/libexec/java_home -v 1.8)
JAVA = $(JAVA_HOME)/jre/bin/java
ifdef J2OBJC_JAVAC
JAVAC = $(J2OBJC_JAVAC)
ifdef J2OBJC_JAVA_HOME
JAVA_HOME = $(J2OBJC_JAVA_HOME)
else
JAVA_HOME = $(shell /usr/libexec/java_home -v 1.8)
endif
JAVA = $(JAVA_HOME)/bin/java
JAVAC = $(JAVA_HOME)/bin/javac
ifneq (,$(findstring build 1.8, $(shell $(JAVA) -version 2>&1)))
# Flag used to include tools.jar. This jar was removed in JDK 9.
JAVA_8 = 1
endif

comma=,
Expand Down
8 changes: 5 additions & 3 deletions scripts/j2objc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ if [ $# -eq 0 ]; then
exit $?
fi

# Run command with Java 8.
if [ -x "/usr/libexec/java_home" ]; then
if [ ! -z "${J2OBJC_JAVA_HOME}" ]; then
readonly JAVA_HOME="${J2OBJC_JAVA_HOME}"
readonly JAVA=${JAVA_HOME}/bin/java
elif [ -x "/usr/libexec/java_home" ]; then
# java_home is available on all Mac systems.
readonly JAVA_HOME=`/usr/libexec/java_home -v 1.8 2> /dev/null`
readonly JAVA=${JAVA_HOME}/jre/bin/java
readonly JAVA=${JAVA_HOME}/bin/java
else
# Non-Mac system (not supported, but should still work).
readonly JAVA=`which java`
Expand Down
5 changes: 4 additions & 1 deletion translator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ SOURCEPATH = $(CWD):$(JAVA_SOURCE_DIR)
BASE_PACKAGE = com/google/devtools/j2objc

DIST_DEPS = $(JSR305_JAR) j2objc_annotations.jar
INTERNAL_DEPS = $(GUAVA_JAR) $(JSR305_JAR) $(JAVAC_JAR) $(PROCYON_JARS) $(SCENELIB_JAR) \
INTERNAL_DEPS = $(GUAVA_JAR) $(JSR305_JAR) $(PROCYON_JARS) $(SCENELIB_JAR) \
$(PLUME_UTIL_JAR)
ifdef JAVA_8
INTERNAL_DEPS += $(JAVAC_JAR)
endif
JAR_DEPS_DIST = $(DIST_DEPS:%=$(DIST_JAR_DIR)/%) $(INTERNAL_DEPS:%=$(JAVA_DEPS_JAR_DIR)/%)
JAR_DEPS_PATH = $(subst $(eval) ,:,$(strip $(JAR_DEPS_DIST)))
JUNIT_JAR_DIST = $(DIST_JAR_DIR)/$(JUNIT_JAR)
Expand Down
5 changes: 4 additions & 1 deletion tree_shaker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ RESOURCES = \
com/google/devtools/j2objc/JRE.mappings

DIST_DEPS = $(JSR305_JAR) j2objc_annotations.jar
INTERNAL_DEPS = $(GUAVA_JAR) $(JAVAC_JAR) $(PROCYON_JARS)
INTERNAL_DEPS = $(GUAVA_JAR) $(PROCYON_JARS)
ifdef JAVA_8
INTERNAL_DEPS += $(JAVAC_JAR)
endif
JAR_DEPS_DIST = $(DIST_DEPS:%=$(DIST_JAR_DIR)/%) $(INTERNAL_DEPS:%=$(JAVA_DEPS_JAR_DIR)/%)
JAR_DEPS_PATH = $(subst $(eval) ,:,$(strip $(JAR_DEPS_DIST)))
JUNIT_JAR_DIST = $(DIST_JAR_DIR)/$(JUNIT_JAR)
Expand Down

0 comments on commit e37963f

Please sign in to comment.