Merge "Revert "Make package functions take an argument""

This commit is contained in:
Treehugger Robot
2018-09-15 16:05:39 +00:00
committed by Gerrit Code Review
5 changed files with 36 additions and 27 deletions

View File

@@ -2305,7 +2305,7 @@ endef
# The MacOS jar tool doesn't like creating empty jar files, # The MacOS jar tool doesn't like creating empty jar files,
# so we need to give it something. # so we need to give it something.
# $(1) package to create # $(1) package to create
define create-empty-package define create-empty-package-at
@mkdir -p $(dir $(1)) @mkdir -p $(dir $(1))
$(hide) touch $(dir $(1))zipdummy $(hide) touch $(dir $(1))zipdummy
$(hide) $(JAR) cf $(1) -C $(dir $(1)) zipdummy $(hide) $(JAR) cf $(1) -C $(dir $(1)) zipdummy
@@ -2313,6 +2313,13 @@ $(hide) zip -qd $(1) zipdummy
$(hide) rm $(dir $(1))zipdummy $(hide) rm $(dir $(1))zipdummy
endef endef
# Create a mostly-empty .jar file that we'll add to later.
# The MacOS jar tool doesn't like creating empty jar files,
# so we need to give it something.
define create-empty-package
$(call create-empty-package-at,$@)
endef
# Copy an arhchive file and delete any class files and empty folders inside. # Copy an arhchive file and delete any class files and empty folders inside.
# $(1): the source archive file. # $(1): the source archive file.
# $(2): the destination archive file. # $(2): the destination archive file.
@@ -2332,7 +2339,6 @@ endef
#Note that the version numbers are given to aapt as simple default #Note that the version numbers are given to aapt as simple default
#values; applications can override these by explicitly stating #values; applications can override these by explicitly stating
#them in their manifest. #them in their manifest.
# $(1) the package file
define add-assets-to-package define add-assets-to-package
$(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
$(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \ $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \
@@ -2349,17 +2355,16 @@ $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
$(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
$(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
--skip-symbols-without-default-localization \ --skip-symbols-without-default-localization \
-F $(1) -F $@
# So that we re-run aapt when the list of input files change # So that we re-run aapt when the list of input files change
$(hide) echo $(PRIVATE_RESOURCE_LIST) >/dev/null $(hide) echo $(PRIVATE_RESOURCE_LIST) >/dev/null
endef endef
# We need the extra blank line, so that the command will be on a separate line. # We need the extra blank line, so that the command will be on a separate line.
# $(1): the package # $(1): the ABI name
# $(2): the ABI name # $(2): the list of shared libraies
# $(3): the list of shared libraies
define _add-jni-shared-libs-to-package-per-abi define _add-jni-shared-libs-to-package-per-abi
$(hide) cp $(3) $(dir $(1))lib/$(2) $(hide) cp $(2) $(dir $@)lib/$(1)
endef endef
@@ -2373,19 +2378,23 @@ JNI_COMPRESS_FLAGS := -0
ZIPALIGN_PAGE_ALIGN_FLAGS := -p ZIPALIGN_PAGE_ALIGN_FLAGS := -p
endif endif
# $(1): the package file
define add-jni-shared-libs-to-package define add-jni-shared-libs-to-package
$(hide) rm -rf $(dir $(1))lib $(hide) rm -rf $(dir $@)lib
$(hide) mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)) $(hide) mkdir -p $(addprefix $(dir $@)lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\ $(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
$(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\ $(call _add-jni-shared-libs-to-package-per-abi,$(abi),\
$(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES))))) $(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
$(hide) (cd $(dir $(1)) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $(1)) lib) $(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) lib)
$(hide) rm -rf $(dir $(1))lib $(hide) rm -rf $(dir $@)lib
endef
#TODO: update the manifest to point to the dex file
define add-dex-to-package
$(call add-dex-to-package-arg,$@)
endef endef
# $(1): the package file. # $(1): the package file.
define add-dex-to-package define add-dex-to-package-arg
$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1) $(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1)
endef endef

View File

@@ -51,16 +51,16 @@ $(built_dpi_apk) : $(all_res_assets) $(jni_shared_libraries) $(full_android_mani
@echo "target Package: $(PRIVATE_MODULE) ($@)" @echo "target Package: $(PRIVATE_MODULE) ($@)"
$(if $(PRIVATE_SOURCE_ARCHIVE),\ $(if $(PRIVATE_SOURCE_ARCHIVE),\
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
$(call create-empty-package,$@)) $(create-empty-package))
$(call add-assets-to-package,$@) $(add-assets-to-package)
ifneq ($(jni_shared_libraries),) ifneq ($(jni_shared_libraries),)
$(call add-jni-shared-libs-to-package,$@) $(add-jni-shared-libs-to-package)
endif endif
ifeq ($(full_classes_jar),) ifeq ($(full_classes_jar),)
# We don't build jar, need to add the Java resources here. # We don't build jar, need to add the Java resources here.
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
else else
$(call add-dex-to-package,$@) $(add-dex-to-package)
endif endif
$(sign-package) $(sign-package)

View File

@@ -174,7 +174,7 @@ $(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
@echo "Host Jar: $(PRIVATE_MODULE) ($@)" @echo "Host Jar: $(PRIVATE_MODULE) ($@)"
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@) $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
$(add-dex-to-package,$@) $(add-dex-to-package)
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY endif # !LOCAL_IS_STATIC_JAVA_LIBRARY

View File

@@ -68,7 +68,7 @@ $(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar
$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN) $(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN)
@echo "target Jar: $(PRIVATE_MODULE) ($@)" @echo "target Jar: $(PRIVATE_MODULE) ($@)"
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp) $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp)
$(call add-dex-to-package,$@.tmp) $(call add-dex-to-package-arg,$@.tmp)
$(hide) $(ZIPTIME) $@.tmp $(hide) $(ZIPTIME) $@.tmp
$(call commit-change-for-toc,$@) $(call commit-change-for-toc,$@)
ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) ifeq (true, $(LOCAL_UNCOMPRESS_DEX))

View File

@@ -420,8 +420,8 @@ else # LOCAL_USE_AAPT2
$(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets) $(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets)
$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT)
@echo "target Export Resources: $(PRIVATE_MODULE) ($@)" @echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
$(call create-empty-package,$@) $(create-empty-package)
$(call add-assets-to-package,$@) $(add-assets-to-package)
endif endif
endif # LOCAL_USE_AAPT2 endif # LOCAL_USE_AAPT2
@@ -628,17 +628,17 @@ ifeq ($(LOCAL_USE_AAPT2),true)
else # ! LOCAL_USE_AAPT2 else # ! LOCAL_USE_AAPT2
$(if $(PRIVATE_SOURCE_ARCHIVE),\ $(if $(PRIVATE_SOURCE_ARCHIVE),\
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
$(call create-empty-package,$@)) $(create-empty-package))
$(call add-assets-to-package,$@) $(add-assets-to-package)
endif # LOCAL_USE_AAPT2 endif # LOCAL_USE_AAPT2
ifneq ($(jni_shared_libraries),) ifneq ($(jni_shared_libraries),)
$(call add-jni-shared-libs-to-package,$@) $(add-jni-shared-libs-to-package)
endif endif
ifeq ($(full_classes_jar),) ifeq ($(full_classes_jar),)
# We don't build jar, need to add the Java resources here. # We don't build jar, need to add the Java resources here.
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
else # full_classes_jar else # full_classes_jar
$(call add-dex-to-package,$@) $(add-dex-to-package)
ifeq ($(LOCAL_USE_AAPT2),true) ifeq ($(LOCAL_USE_AAPT2),true)
$(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR)) $(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR))
endif endif
@@ -687,7 +687,7 @@ $(built_odex): PRIVATE_DEX_FILE := $(built_dex)
# Use pattern rule - we may have multiple built odex files. # Use pattern rule - we may have multiple built odex files.
$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex) $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex)
$(hide) mkdir -p $(dir $@) && rm -f $@ $(hide) mkdir -p $(dir $@) && rm -f $@
$(call add-dex-to-package,$@) $(add-dex-to-package)
ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
$(uncompress-dexs) $(uncompress-dexs)
$(align-package) $(align-package)