Merge "Sort files in directories passed to jar" am: 966ed15a1d am: 604a2423b6

am: da54a77928

Change-Id: I5cc539e58d655dbd1730acd368ad98071079a57d
This commit is contained in:
Colin Cross 2017-08-17 01:06:44 +00:00 committed by android-build-merger
commit 18c92897a7
8 changed files with 27 additions and 6 deletions

View file

@ -2195,6 +2195,17 @@ define call-jack
JACK_VERSION=$(PRIVATE_JACK_VERSION) $(JACK) $(DEFAULT_JACK_EXTRA_ARGS)
endef
# Return jar arguments to compress files in a given directory
# $(1): directory
#
# Returns an @-file argument that contains the output of a subshell
# that looks like -C $(1) path/to/file1 -C $(1) path/to/file2
# Also adds "-C out/empty ." which avoids errors in jar when
# there are no files in the directory.
define jar-args-sorted-files-in-directory
@<(find $(1) -type f | sort | $(JAR_ARGS) $(1); echo "-C $(EMPTY_DIRECTORY) .")
endef
# Common definition to invoke javac on the host and target.
#
# Some historical notes:
@ -2252,9 +2263,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 \
-C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \
$(hide) $(JAR) -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .)
$(JAR) -cfm $@ $(dir $@)/manifest.mf, \
$(hide) $(JAR) -cf $@) \
$(call jar-args-sorted-files-in-directory,$(PRIVATE_CLASS_INTERMEDIATES_DIR))
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
endef
@ -2701,7 +2712,7 @@ define add-jar-resources-to-package
rm -rf $(3)
mkdir -p $(3)
unzip -qo $(2) -d $(3) $$(zipinfo -1 $(2) | grep -v -E "\.class$$")
$(JAR) uf $(1) -C $(3) .
$(JAR) uf $(1) $(call jar-args-sorted-files-in-directory,$(3))
endef
# Sign a package using the specified key/cert.

View file

@ -98,6 +98,7 @@ $(full_classes_compiled_jar): \
$(proto_java_sources_file_stamp) \
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) \
| $(SOONG_JAVAC_WRAPPER)
$(transform-host-java-to-package)

View file

@ -71,6 +71,7 @@ $(full_classes_compiled_jar): \
$(proto_java_sources_file_stamp) \
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
$(ZIPTIME) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) \
| $(SOONG_JAVAC_WRAPPER)

View file

@ -120,12 +120,13 @@ $(my_instrumented_timestamp_path): $(my_unzipped_timestamp_path) $(JACOCO_CLI_JA
$(LOCAL_FULL_CLASSES_JACOCO_JAR): PRIVATE_TEMP_JAR_PATH := $(my_temp_jar_path)
$(LOCAL_FULL_CLASSES_JACOCO_JAR): PRIVATE_INSTRUMENTED_PATH := $(my_instrumented_path)
$(LOCAL_FULL_CLASSES_JACOCO_JAR): PRIVATE_FULL_CLASSES_PRE_JACOCO_JAR := $(LOCAL_FULL_CLASSES_PRE_JACOCO_JAR)
$(LOCAL_FULL_CLASSES_JACOCO_JAR): $(JAR_ARGS)
$(LOCAL_FULL_CLASSES_JACOCO_JAR): $(my_instrumented_timestamp_path) $(LOCAL_FULL_CLASSES_PRE_JACOCO_JAR)
rm -f $@ $(PRIVATE_TEMP_JAR_PATH)
# copy the pre-jacoco jar (containing files excluded from instrumentation)
cp $(PRIVATE_FULL_CLASSES_PRE_JACOCO_JAR) $(PRIVATE_TEMP_JAR_PATH)
# copy instrumented files back into the resultant jar
$(JAR) -uf $(PRIVATE_TEMP_JAR_PATH) -C $(PRIVATE_INSTRUMENTED_PATH) .
$(JAR) -uf $(PRIVATE_TEMP_JAR_PATH) $(call jar-args-sorted-files-in-directory,$(PRIVATE_INSTRUMENTED_PATH))
mv $(PRIVATE_TEMP_JAR_PATH) $@
# this is used to trigger $(my_classes_to_report_on_path) to build

View file

@ -449,6 +449,7 @@ $(full_classes_compiled_jar): \
$(proto_java_sources_file_stamp) \
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) \
| $(SOONG_JAVAC_WRAPPER)
$(transform-java-to-classes.jar)

View file

@ -70,6 +70,10 @@ else
DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE)
endif
# Make an empty directory, which can be used to make empty jars
EMPTY_DIRECTORY := $(OUT_DIR)/empty
$(shell mkdir -p $(EMPTY_DIRECTORY) && rm -rf $(EMPTY_DIRECTORY)/*)
# CTS-specific config.
-include cts/build/config.mk
# VTS-specific config.

View file

@ -568,6 +568,7 @@ $(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_D
$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/resources
$(LOCAL_BUILT_MODULE): PRIVATE_FULL_CLASSES_JAR := $(full_classes_jar)
$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
$(LOCAL_BUILT_MODULE) : $(JAR_ARGS)
ifdef LOCAL_USE_AAPT2
$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP)

View file

@ -199,6 +199,7 @@ $(built_aar): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
$(built_aar): PRIVATE_CLASSES_JAR := $(aar_classes_jar)
$(built_aar): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
$(built_aar): PRIVATE_R_TXT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.txt
$(built_aar): $(JAR_ARGS)
$(built_aar) : $(aar_classes_jar) $(full_android_manifest)
@echo "target AAR: $(PRIVATE_MODULE) ($@)"
$(hide) rm -rf $(dir $@)aar && mkdir -p $(dir $@)aar/res
@ -208,7 +209,7 @@ $(built_aar) : $(aar_classes_jar) $(full_android_manifest)
$(hide) $(foreach res,$(PRIVATE_RESOURCE_DIR),cp -Rfn $(res)/* $(dir $@)aar/res;)
$(hide) cp $(PRIVATE_R_TXT) $(dir $@)aar/R.txt
$(hide) $(JAR) -cMf $@ \
-C $(dir $@)aar .
$(call jar-args-sorted-files-in-directory,(dir $@)aar)
# Register the aar file.
ALL_MODULES.$(LOCAL_MODULE).AAR := $(built_aar)