diff --git a/core/definitions.mk b/core/definitions.mk index d73360c8c..35d70cb0d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2340,7 +2340,7 @@ endef # The MacOS jar tool doesn't like creating empty jar files, # so we need to give it something. # $(1) package to create -define create-empty-package +define create-empty-package-at @mkdir -p $(dir $(1)) $(hide) touch $(dir $(1))zipdummy $(hide) $(JAR) cf $(1) -C $(dir $(1)) zipdummy @@ -2348,6 +2348,13 @@ $(hide) zip -qd $(1) zipdummy $(hide) rm $(dir $(1))zipdummy 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. # $(1): the source archive file. # $(2): the destination archive file. @@ -2367,7 +2374,6 @@ endef #Note that the version numbers are given to aapt as simple default #values; applications can override these by explicitly stating #them in their manifest. -# $(1) the package file define add-assets-to-package $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \ @@ -2384,17 +2390,16 @@ $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ --skip-symbols-without-default-localization \ - -F $(1) + -F $@ # So that we re-run aapt when the list of input files change $(hide) echo $(PRIVATE_RESOURCE_LIST) >/dev/null endef # We need the extra blank line, so that the command will be on a separate line. -# $(1): the package -# $(2): the ABI name -# $(3): the list of shared libraies +# $(1): the ABI name +# $(2): the list of shared libraies define _add-jni-shared-libs-to-package-per-abi -$(hide) cp $(3) $(dir $(1))lib/$(2) +$(hide) cp $(2) $(dir $@)lib/$(1) endef @@ -2408,19 +2413,23 @@ JNI_COMPRESS_FLAGS := -0 ZIPALIGN_PAGE_ALIGN_FLAGS := -p endif -# $(1): the package file define add-jni-shared-libs-to-package -$(hide) rm -rf $(dir $(1))lib -$(hide) mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)) +$(hide) rm -rf $(dir $@)lib +$(hide) mkdir -p $(addprefix $(dir $@)lib/,$(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))))) -$(hide) (cd $(dir $(1)) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $(1)) lib) -$(hide) rm -rf $(dir $(1))lib +$(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) 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 # $(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) endef diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk index 20bbbe23d..f32daf500 100644 --- a/core/dpi_specific_apk.mk +++ b/core/dpi_specific_apk.mk @@ -51,16 +51,16 @@ $(built_dpi_apk) : $(all_res_assets) $(jni_shared_libraries) $(full_android_mani @echo "target Package: $(PRIVATE_MODULE) ($@)" $(if $(PRIVATE_SOURCE_ARCHIVE),\ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\ - $(call create-empty-package,$@)) - $(call add-assets-to-package,$@) + $(create-empty-package)) + $(add-assets-to-package) ifneq ($(jni_shared_libraries),) - $(call add-jni-shared-libs-to-package,$@) + $(add-jni-shared-libs-to-package) endif ifeq ($(full_classes_jar),) # We don't build jar, need to add the Java resources here. $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) else - $(call add-dex-to-package,$@) + $(add-dex-to-package) endif $(sign-package) diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index 27fc2b21e..779cef950 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -174,7 +174,7 @@ $(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) @echo "Host Jar: $(PRIVATE_MODULE) ($@)" $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@) - $(add-dex-to-package,$@) + $(add-dex-to-package) endif # !LOCAL_IS_STATIC_JAVA_LIBRARY diff --git a/core/java_library.mk b/core/java_library.mk index b9abbe4e1..0a70a3817 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -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) @echo "target Jar: $(PRIVATE_MODULE) ($@)" $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp) - $(call add-dex-to-package,$@.tmp) + $(call add-dex-to-package-arg,$@.tmp) $(hide) $(ZIPTIME) $@.tmp $(call commit-change-for-toc,$@) ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) diff --git a/core/package_internal.mk b/core/package_internal.mk index ef2a5a514..7f74cc903 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -420,8 +420,8 @@ else # LOCAL_USE_AAPT2 $(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets) $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" - $(call create-empty-package,$@) - $(call add-assets-to-package,$@) + $(create-empty-package) + $(add-assets-to-package) endif endif # LOCAL_USE_AAPT2 @@ -628,17 +628,17 @@ ifeq ($(LOCAL_USE_AAPT2),true) else # ! LOCAL_USE_AAPT2 $(if $(PRIVATE_SOURCE_ARCHIVE),\ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\ - $(call create-empty-package,$@)) - $(call add-assets-to-package,$@) + $(create-empty-package)) + $(add-assets-to-package) endif # LOCAL_USE_AAPT2 ifneq ($(jni_shared_libraries),) - $(call add-jni-shared-libs-to-package,$@) + $(add-jni-shared-libs-to-package) endif ifeq ($(full_classes_jar),) # We don't build jar, need to add the Java resources here. $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) else # full_classes_jar - $(call add-dex-to-package,$@) + $(add-dex-to-package) ifeq ($(LOCAL_USE_AAPT2),true) $(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR)) endif @@ -687,7 +687,7 @@ $(built_odex): PRIVATE_DEX_FILE := $(built_dex) # Use pattern rule - we may have multiple built odex files. $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex) $(hide) mkdir -p $(dir $@) && rm -f $@ - $(call add-dex-to-package,$@) + $(add-dex-to-package) ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) $(uncompress-dexs) $(align-package)