From 0851df8c82d61ec6abab757b1102eb2a6e98ea37 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 30 Jun 2017 13:55:38 -0700 Subject: [PATCH] Provide make variables for java binaries Replace java -> $(JAVA), etc. to prepare for moving java binaries out of the path and using full paths to them. Test: builds Bug: 62956999 Change-Id: I5dfcd0d4e855ecde69cd127169e9545e59723d12 --- core/Makefile | 2 +- core/combo/javac.mk | 4 ++++ core/config.mk | 6 +++--- core/definitions.mk | 16 ++++++++-------- core/droiddoc.mk | 4 ++-- core/host_dalvik_java_library.mk | 2 +- core/host_java_library.mk | 2 +- core/java.mk | 4 ++-- core/package_internal.mk | 2 +- core/static_java_library.mk | 2 +- core/tasks/sdk-addon.mk | 2 +- 11 files changed, 25 insertions(+), 21 deletions(-) diff --git a/core/Makefile b/core/Makefile index 9aae8ca79..8dbd5ed30 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1093,7 +1093,7 @@ $(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys) @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)" @rm -rf $@ @mkdir -p $(dir $@) - java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@ + $(JAVA) -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@ RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id diff --git a/core/combo/javac.mk b/core/combo/javac.mk index 7f66ea83a..99bd0eeb9 100644 --- a/core/combo/javac.mk +++ b/core/combo/javac.mk @@ -23,6 +23,10 @@ else JAVACC := $(ALTERNATE_JAVAC) endif +JAVA := java +JAVADOC := javadoc +JAR := jar + # The actual compiler can be wrapped by setting the JAVAC_WRAPPER var. ifdef JAVAC_WRAPPER ifneq ($(JAVAC_WRAPPER),$(firstword $(JAVACC))) diff --git a/core/config.mk b/core/config.mk index 66511c110..6ca45c0a7 100644 --- a/core/config.mk +++ b/core/config.mk @@ -517,7 +517,7 @@ DX := $(HOST_OUT_EXECUTABLES)/dx DX_COMMAND := $(DX) -JXms16M -JXmx2048M else DX := $(DX_ALT_JAR) -DX_COMMAND := java -Xms16M -Xmx2048M -jar $(DX) +DX_COMMAND := $(JAVA) -Xms16M -Xmx2048M -jar $(DX) endif MAINDEXCLASSES := $(HOST_OUT_EXECUTABLES)/mainDexClasses @@ -676,7 +676,7 @@ FINDBUGS := $(FINDBUGS_DIR)/findbugs EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX) # Tool to merge AndroidManifest.xmls -ANDROID_MANIFEST_MERGER := java -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge +ANDROID_MANIFEST_MERGER := $(JAVA) -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge COLUMN:= column @@ -700,7 +700,7 @@ endif # ifeq ($(EXPERIMENTAL_USE_OPENJDK9),) # Is the host JDK 64-bit version? HOST_JDK_IS_64BIT_VERSION := -ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),) +ifneq ($(filter 64-Bit, $(shell $(JAVA) -version 2>&1)),) HOST_JDK_IS_64BIT_VERSION := true endif endif # CALLED_FROM_SETUP not true diff --git a/core/definitions.mk b/core/definitions.mk index 15ef6f403..fe8d64425 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2243,9 +2243,9 @@ $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) rm -rf \ $(if $(PRIVATE_JAR_MANIFEST), \ $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf && \ - jar -cfm $@ $(dir $@)/manifest.mf \ + $(JAR) -cfm $@ $(dir $@)/manifest.mf \ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \ - $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .) + $(hide) $(JAR) -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .) $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) endef @@ -2516,7 +2516,7 @@ $(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $ endef define transform-classes.jar-to-emma -$(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \ +$(hide) $(JAVA) -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \ $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \ $(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER)) endef @@ -2539,7 +2539,7 @@ define desugar-classes-jar $(hide) rm -f $@ $@.tmp @rm -rf $(dir $@)/desugar_dumped_classes @mkdir $(dir $@)/desugar_dumped_classes -$(hide) java \ +$(hide) $(JAVA) \ $(if $(EXPERIMENTAL_USE_OPENJDK9),--add-opens java.base/java.lang.invoke=ALL-UNNAMED,) \ -Djdk.internal.lambda.dumpProxyClasses=$(abspath $(dir $@))/desugar_dumped_classes \ -jar $(DESUGAR) \ @@ -2577,7 +2577,7 @@ endef define create-empty-package-at @mkdir -p $(dir $(1)) $(hide) touch $(dir $(1))zipdummy -$(hide) (cd $(dir $(1)) && jar cf $(notdir $(1)) zipdummy) +$(hide) $(JAR) cf $(1) -C $(dir $(1)) zipdummy $(hide) zip -qd $(1) zipdummy $(hide) rm $(dir $(1))zipdummy endef @@ -2671,7 +2671,7 @@ endef # define add-java-resources-to $(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list) -$(hide) jar uf $(1) @$(1).jar-arg-list +$(hide) $(JAR) uf $(1) @$(1).jar-arg-list @rm -f $(1).jar-arg-list endef @@ -2683,7 +2683,7 @@ define add-carried-jack-resources | sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C \"$(PRIVATE_JACK_INTERMEDIATES_DIR)\" \"?" -e "s/$$/\"/" \ > $(dir $@)jack_res_jar_flags; \ if [ -s $(dir $@)jack_res_jar_flags ] ; then \ - jar uf $@ @$(dir $@)jack_res_jar_flags; \ + $(JAR) uf $@ @$(dir $@)jack_res_jar_flags; \ fi; \ fi endef @@ -2698,7 +2698,7 @@ endef # $(1): the package file we are signing. define sign-package-arg $(hide) mv $(1) $(1).unsigned -$(hide) java -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) \ +$(hide) $(JAVA) -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) \ $(if $(EXPERIMENTAL_USE_OPENJDK9),--add-exports java.base/sun.security.pkcs=ALL-UNNAMED,) \ $(if $(EXPERIMENTAL_USE_OPENJDK9),--add-exports java.base/sun.security.x509=ALL-UNNAMED,) \ -jar $(SIGNAPK_JAR) \ diff --git a/core/droiddoc.mk b/core/droiddoc.mk index eb126305c..48a930d48 100644 --- a/core/droiddoc.mk +++ b/core/droiddoc.mk @@ -179,7 +179,7 @@ $(full_target): \ $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) $(hide) ( \ - javadoc \ + $(JAVADOC) \ -encoding UTF-8 \ -source 1.8 \ \@$(PRIVATE_SRC_LIST_FILE) \ @@ -216,7 +216,7 @@ $(full_target): $(full_src_files) $(full_java_lib_deps) $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) $(hide) ( \ - javadoc \ + $(JAVADOC) \ -encoding UTF-8 \ $(PRIVATE_DROIDDOC_OPTIONS) \ \@$(PRIVATE_SRC_LIST_FILE) \ diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index 7101229e9..4f3069fb5 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -119,7 +119,7 @@ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) @echo JarJar: $@ - $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ else full_classes_jarjar_jar := $(full_classes_desugar_jar) endif diff --git a/core/host_java_library.mk b/core/host_java_library.mk index d30c90d94..939ff3722 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -90,7 +90,7 @@ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) @echo JarJar: $@ - $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ else full_classes_jarjar_jar := $(full_classes_compiled_jar) endif diff --git a/core/java.mk b/core/java.mk index 8dc4b22e9..e4569934c 100644 --- a/core/java.mk +++ b/core/java.mk @@ -463,7 +463,7 @@ out := $(full_classes_processed_jar): $(full_classes_compiled_jar) $(LOCAL_JAR_PROCESSOR) @echo Processing $@ with $(PRIVATE_JAR_PROCESSOR) $(hide) rm -f $@ $(PRIVATE_TMP_OUT) - $(hide) java -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS) + $(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS) $(hide) mv $(PRIVATE_TMP_OUT) $@ else @@ -489,7 +489,7 @@ ifneq ($(strip $(LOCAL_JARJAR_RULES)),) $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) $(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) @echo JarJar: $@ - $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ + $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ else full_classes_jarjar_jar := $(full_classes_desugar_jar) endif diff --git a/core/package_internal.mk b/core/package_internal.mk index 6255ef143..8b3c37578 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -355,7 +355,7 @@ $(data_binding_stamp) : $(all_res_assets) $(full_android_manifest) \ @rm -rf $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) && \ mkdir -p $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) \ $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_ANNO_SRC_DIR) - $(hide) java -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \ + $(hide) $(JAVA) -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \ $(PRIVATE_MANIFEST) $(PRIVATE_SRC_OUT) $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_RES_IN) $(hide) touch $@ diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 343b94989..db64a8df2 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -199,7 +199,7 @@ $(built_aar) : $(full_classes_jar) $(full_android_manifest) # Note: Use "cp -n" to honor the resource overlay rules, if multiple res dirs exist. $(hide) $(foreach res,$(PRIVATE_RESOURCE_DIR),cp -Rfn $(res)/* $(dir $@)aar/res;) $(hide) cp $(PRIVATE_R_TXT) $(dir $@)aar/R.txt - $(hide) jar -cMf $@ \ + $(hide) $(JAR) -cMf $@ \ -C $(dir $@)aar . # Register the aar file. diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk index 362b22935..610e0ce62 100644 --- a/core/tasks/sdk-addon.mk +++ b/core/tasks/sdk-addon.mk @@ -35,7 +35,7 @@ endef define stub-addon-jar $(call stub-addon-jar-file,$(1)): $(1) | mkstubs $(info Stubbing addon jar using $(PRODUCT_SDK_ADDON_STUB_DEFS)) - $(hide) java -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \ + $(hide) $(JAVA) -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \ "$$<" "$$@" @$(PRODUCT_SDK_ADDON_STUB_DEFS) endef