Merge "Use merge_zips to merge jars during Java build in Make." am: 39bbfe217a am: d9001d2733 am: 177e7ffb20

am: 6cdb1f8bc7

Change-Id: I74d4d701ca8937ef35c1c2820a6ca3abe257e74c
This commit is contained in:
Nan Zhang 2017-09-20 20:18:29 +00:00 committed by android-build-merger
commit 3aaba35d18
7 changed files with 53 additions and 39 deletions

View file

@ -561,6 +561,7 @@ IJAR := $(prebuilt_build_tools_bin)/ijar
MAKEPARALLEL := $(prebuilt_build_tools_bin)/makeparallel
SOONG_JAVAC_WRAPPER := $(SOONG_HOST_OUT_EXECUTABLES)/soong_javac_wrapper
SOONG_ZIP := $(SOONG_HOST_OUT_EXECUTABLES)/soong_zip
MERGE_ZIPS := $(SOONG_HOST_OUT_EXECUTABLES)/merge_zips
ZIP2ZIP := $(SOONG_HOST_OUT_EXECUTABLES)/zip2zip
ZIPTIME := $(prebuilt_build_tools_bin)/ziptime

View file

@ -2243,7 +2243,6 @@ $(hide) rm -f $@
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
$(hide) mkdir -p $(dir $@)
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
$(SOONG_JAVAC_WRAPPER) $(1) -encoding UTF-8 \
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
@ -2291,19 +2290,18 @@ define transform-java-to-header.jar
@mkdir $(dir $@)/classes-turbine
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
$(JAVA) -jar $(TURBINE) \
--output $@.tmp --temp_dir $(dir $@)/classes-turbine -$(PRIVATE_BOOTCLASSPATH) \
--output $@.premerged --temp_dir $(dir $@)/classes-turbine -$(PRIVATE_BOOTCLASSPATH) \
--sources \@$(PRIVATE_JAVA_SOURCE_LIST) \
--javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) \
$(addprefix --classpath ,$(strip \
$(call normalize-path-list,$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)))) \
|| ( rm -rf $(dir $@)/classes-turbine ; exit 41 ) \
fi
$(hide) $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_HEADER_LIBRARIES),$(dir $@)/classes-turbine)
$(hide) if [ -s $@.tmp ] ; then \
unzip -qo $@.tmp -d $(dir $@)/classes-turbine; rm -f $(dir $@)/classes-turbine/module-info.class; \
$(hide) if [ -s $@.premerged ] ; then \
$(MERGE_ZIPS) -j -stripDir META-INF $@.tmp $@.premerged $(call reverse-list,$(PRIVATE_STATIC_JAVA_HEADER_LIBRARIES)) ; \
else \
$(MERGE_ZIPS) -j -stripDir META-INF $@.tmp $(call reverse-list,$(PRIVATE_STATIC_JAVA_HEADER_LIBRARIES)) ; \
fi
$(hide) $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,$(hide) rm -rf $(dir $@)/classes-turbine/META-INF)
$(hide) $(JAR) -cf $@.tmp $(call jar-args-sorted-files-in-directory,$(dir $@)/classes-turbine)
$(hide) $(ZIPTIME) $@.tmp
$(hide) $(call commit-change-for-toc,$@)
endef

View file

@ -57,7 +57,6 @@ ifeq ($(LOCAL_IS_HOST_MODULE),true)
$(full_target): PRIVATE_BOOTCLASSPATH :=
full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
$(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
full_java_lib_deps := $(full_java_libs)
else
@ -83,7 +82,6 @@ endif # LOCAL_SDK_VERSION
LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
endif # !LOCAL_IS_HOST_MODULE
$(full_target): PRIVATE_CLASSPATH := $(call normalize-path-list,$(full_java_libs))
@ -174,7 +172,7 @@ $(full_target): \
$(droiddoc_templates) \
$(droiddoc) \
$(html_dir_files) \
$(full_java_lib_deps) \
$(full_java_libs) \
$(LOCAL_ADDITIONAL_DEPENDENCIES)
@echo Docs droiddoc: $(PRIVATE_OUT_DIR)
$(hide) mkdir -p $(dir $@)
@ -226,7 +224,7 @@ else
$(full_target): PRIVATE_BOOTCLASSPATH_ARG := $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH))
endif
$(full_target): $(full_src_files) $(full_java_lib_deps)
$(full_target): $(full_src_files) $(full_java_libs)
@echo Docs javadoc: $(PRIVATE_OUT_DIR)
@mkdir -p $(dir $@)
$(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \

View file

@ -46,6 +46,7 @@ full_classes_turbine_jar := $(intermediates.COMMON)/classes-turbine.jar
full_classes_header_jarjar := $(intermediates.COMMON)/classes-header-jarjar.jar
full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar
full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar
full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
full_classes_jar := $(intermediates.COMMON)/classes.jar
@ -57,6 +58,7 @@ java_source_list_file := $(intermediates.COMMON)/java-source-list
LOCAL_INTERMEDIATE_TARGETS += \
$(full_classes_turbine_jar) \
$(full_classes_compiled_jar) \
$(full_classes_combined_jar) \
$(full_classes_desugar_jar) \
$(full_classes_jarjar_jar) \
$(full_classes_jack) \
@ -110,7 +112,6 @@ $(full_classes_compiled_jar): \
$(java_source_list_file) \
$(java_sources_deps) \
$(full_java_header_libs) \
$(full_static_java_libs) \
$(jar_manifest_file) \
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
@ -128,7 +129,8 @@ $(full_classes_turbine_jar): \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
$(ZIPTIME) \
| $(TURBINE)
| $(TURBINE) \
$(MERGE_ZIPS)
$(transform-java-to-header.jar)
.KATI_RESTAT: $(full_classes_turbine_jar)
@ -145,14 +147,21 @@ endif
$(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar)))
$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
$(full_classes_combined_jar): $(full_classes_compiled_jar) \
$(full_static_java_libs) | $(MERGE_ZIPS)
$(MERGE_ZIPS) -j \
$(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \
$@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
# Run jarjar if necessary, otherwise just copy the file.
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)
$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
@echo JarJar: $@
$(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
else
full_classes_jarjar_jar := $(full_classes_compiled_jar)
full_classes_jarjar_jar := $(full_classes_combined_jar)
endif
$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))

View file

@ -36,11 +36,13 @@ full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
full_classes_jar := $(intermediates.COMMON)/classes.jar
java_source_list_file := $(intermediates.COMMON)/java-source-list
full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar
LOCAL_INTERMEDIATE_TARGETS += \
$(full_classes_compiled_jar) \
$(full_classes_jarjar_jar) \
$(java_source_list_file)
$(java_source_list_file) \
$(full_classes_combined_jar)
#######################################
include $(BUILD_SYSTEM)/base_rules.mk
@ -79,7 +81,7 @@ $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
$(full_classes_compiled_jar): \
$(java_source_list_file) \
$(java_sources_deps) \
$(full_java_lib_deps) \
$(full_java_libs) \
$(jar_manifest_file) \
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
@ -92,14 +94,18 @@ $(full_classes_compiled_jar): \
javac-check : $(full_classes_compiled_jar)
javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
$(full_classes_combined_jar): $(full_classes_compiled_jar) \
$(full_static_java_libs) | $(MERGE_ZIPS)
$(MERGE_ZIPS) -j -stripDir META-INF -zipToNotStrip $< $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
# Run jarjar if necessary, otherwise just copy the file.
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)
$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
@echo JarJar: $@
$(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
else
full_classes_jarjar_jar := $(full_classes_compiled_jar)
full_classes_jarjar_jar := $(full_classes_combined_jar)
endif

View file

@ -135,6 +135,7 @@ full_classes_desugar_jar := $(intermediates.COMMON)/classes-desugar.jar
jarjar_leaf := classes-jarjar.jar
full_classes_jarjar_jar := $(intermediates.COMMON)/$(jarjar_leaf)
full_classes_proguard_jar := $(intermediates.COMMON)/classes-proguard.jar
full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar
built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)/classes.dex
full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
java_source_list_file := $(intermediates.COMMON)/java-source-list
@ -160,6 +161,7 @@ LOCAL_INTERMEDIATE_TARGETS += \
$(full_classes_desugar_jar) \
$(full_classes_jarjar_jar) \
$(full_classes_jar) \
$(full_classes_combined_jar) \
$(full_classes_proguard_jar) \
$(built_dex_intermediate) \
$(full_classes_jack) \
@ -487,7 +489,6 @@ $(full_classes_compiled_jar): \
$(java_source_list_file) \
$(java_sources_deps) \
$(full_java_header_libs) \
$(full_static_java_libs) \
$(jar_manifest_file) \
$(layers_file) \
$(annotation_processor_deps) \
@ -507,7 +508,8 @@ $(full_classes_turbine_jar): \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
$(ZIPTIME) \
| $(TURBINE)
| $(TURBINE) \
$(MERGE_ZIPS)
$(transform-java-to-header.jar)
.KATI_RESTAT: $(full_classes_turbine_jar)
@ -527,12 +529,19 @@ $(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_
javac-check : $(full_classes_compiled_jar)
javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
$(full_classes_combined_jar): $(full_classes_compiled_jar) \
$(full_static_java_libs) | $(MERGE_ZIPS)
$(MERGE_ZIPS) -j \
$(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \
$@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
ifdef LOCAL_JAR_PROCESSOR
# LOCAL_JAR_PROCESSOR_ARGS must be evaluated here to set up the rule-local
# PRIVATE_JAR_PROCESSOR_ARGS variable, but $< and $@ are not available yet.
# Set ${in} and ${out} so they can be referenced by LOCAL_JAR_PROCESSOR_ARGS
# using deferred evaluation (LOCAL_JAR_PROCESSOR_ARGS = instead of :=).
in := $(full_classes_compiled_jar)
in := $(full_classes_combined_jar)
out := $(full_classes_processed_jar).tmp
my_jar_processor := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_JAR_PROCESSOR).jar
@ -542,7 +551,7 @@ $(full_classes_processed_jar): PRIVATE_TMP_OUT := $(out)
in :=
out :=
$(full_classes_processed_jar): $(full_classes_compiled_jar) $(my_jar_processor)
$(full_classes_processed_jar): $(full_classes_combined_jar) $(my_jar_processor)
@echo Processing $@ with $(PRIVATE_JAR_PROCESSOR)
$(hide) rm -f $@ $(PRIVATE_TMP_OUT)
$(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS)
@ -550,7 +559,7 @@ $(full_classes_processed_jar): $(full_classes_compiled_jar) $(my_jar_processor)
my_jar_processor :=
else
full_classes_processed_jar := $(full_classes_compiled_jar)
full_classes_processed_jar := $(full_classes_combined_jar)
endif
# Run jarjar if necessary

View file

@ -156,7 +156,7 @@ annotation_processor_flags :=
annotation_processor_deps :=
ifdef LOCAL_ANNOTATION_PROCESSORS
annotation_processor_jars := $(call java-lib-deps,$(LOCAL_ANNOTATION_PROCESSORS),true)
annotation_processor_jars := $(call java-lib-files,$(LOCAL_ANNOTATION_PROCESSORS),true)
annotation_processor_flags += -processorpath $(call normalize-path-list,$(annotation_processor_jars))
annotation_processor_deps += $(annotation_processor_jars)
@ -195,9 +195,6 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
# full_java_libs: The list of files that should be used as the classpath.
# Using this list as a dependency list WILL NOT WORK.
# full_java_lib_deps: Should be specified as a prerequisite of this module
# to guarantee that the files in full_java_libs will
# be up-to-date.
ifndef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_SDK_VERSION),)
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
@ -234,8 +231,6 @@ endif
full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
full_java_lib_deps := $(addsuffix .toc, $(full_java_lib_deps))
else # LOCAL_IS_HOST_MODULE
@ -249,22 +244,17 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_boot
full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),true)
full_java_lib_deps := $(full_shared_java_libs)
else # !USE_CORE_LIB_BOOTCLASSPATH
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
$(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
full_java_lib_deps := $(full_shared_java_libs)
endif # USE_CORE_LIB_BOOTCLASSPATH
endif # !LOCAL_IS_HOST_MODULE
# Only host java libraries use LOCAL_CLASSPATH.
full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
full_java_header_libs := $(full_shared_java_header_libs) $(full_static_java_header_libs)
full_java_lib_deps := $(full_java_lib_deps) $(full_static_java_libs) $(LOCAL_CLASSPATH)
ifndef LOCAL_IS_HOST_MODULE
# This is set by packages that are linking to other packages that export
# shared libraries, allowing them to make use of the code in the linked apk.
@ -274,12 +264,15 @@ ifneq ($(apk_libraries),)
$(foreach lib,$(apk_libraries), \
$(call intermediates-dir-for, \
APPS,$(lib),,COMMON)/classes-pre-proguard.jar)
link_apk_header_libs := \
$(foreach lib,$(apk_libraries), \
$(call intermediates-dir-for, \
APPS,$(lib),,COMMON)/classes-header.jar)
# link against the jar with full original names (before proguard processing).
full_shared_java_libs += $(link_apk_libraries)
full_java_libs += $(link_apk_libraries)
full_java_header_libs += $(link_apk_libraries)
full_java_lib_deps += $(link_apk_libraries)
full_java_header_libs += $(link_apk_header_libs)
endif
# This is set by packages that contain instrumentation, allowing them to
@ -296,9 +289,9 @@ ifdef LOCAL_INSTRUMENTATION_FOR
APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
# link against the jar with full original names (before proguard processing).
link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes-pre-proguard.jar
link_instr_classes_header_jar := $(link_instr_intermediates_dir.COMMON)/classes-header.jar
full_java_libs += $(link_instr_classes_jar)
full_java_header_libs += $(link_instr_classes_jar)
full_java_lib_deps += $(link_instr_classes_jar)
full_java_header_libs += $(link_instr_classes_header_jar)
endif # LOCAL_INSTRUMENTATION_FOR
endif # LOCAL_IS_HOST_MODULE