From cc93f0c87cbcd7fa00e8407315c3ee60d24abd85 Mon Sep 17 00:00:00 2001 From: Fredrik Roubert Date: Wed, 28 Jan 2015 21:29:38 +0100 Subject: [PATCH] Add new build flag LOCAL_DONT_DELETE_JAR_DIRS. Normally the build function initialize-package-file will delete all class files and all directory entries from JAR files, but sometimes external projects (eg. ICU4J) depend on having directory entries in their JAR files. This change adds the flag LOCAL_DONT_DELETE_JAR_DIRS (analogous to the flag LOCAL_DONT_DELETE_JAR_META_INF) which when set will skip deletion of directory entries in initialize-package-file. Change-Id: I4464b947b7528fca23925affa95e4071915f04d4 --- core/clear_vars.mk | 1 + core/definitions.mk | 4 +++- core/host_dalvik_java_library.mk | 1 + core/java_library.mk | 1 + core/package_internal.mk | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 9f339ffb6..db48bd62f 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -148,6 +148,7 @@ LOCAL_LINT_FLAGS:= LOCAL_SOURCE_FILES_ALL_GENERATED:= # '',true # Don't delete the META_INF dir when merging static Java libraries. LOCAL_DONT_DELETE_JAR_META_INF:= +LOCAL_DONT_DELETE_JAR_DIRS:= LOCAL_ADDITIONAL_CERTIFICATES:= LOCAL_PREBUILT_MODULE_FILE:= LOCAL_POST_LINK_CMD:= diff --git a/core/definitions.mk b/core/definitions.mk index e276887e9..37f7d9d50 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1785,7 +1785,9 @@ endef define initialize-package-file @mkdir -p $(dir $(2)) $(hide) cp -f $(1) $(2) -$(hide) zip -qd $(2) "*.class" "*/" || true # Ignore the error when nothing to delete. +$(hide) zip -qd $(2) "*.class" \ + $(if $(strip $(PRIVATE_DONT_DELETE_JAR_DIRS)),,"*/") \ + || true # Ignore the error when nothing to delete. endef #TODO: we kinda want to build different asset packages for diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index e946b24db..f8264ee26 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -103,6 +103,7 @@ $(built_dex): $(full_classes_jar) $(DX) $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) $(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) +$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) @echo "Host Jar: $(PRIVATE_MODULE) ($@)" $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@) diff --git a/core/java_library.mk b/core/java_library.mk index 61dfef033..b4e3eaae5 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -66,6 +66,7 @@ else # !LOCAL_IS_STATIC_JAVA_LIBRARY $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) $(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) +$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) $(common_javalib.jar) : $(built_dex) $(java_resource_sources) @echo "target Jar: $(PRIVATE_MODULE) ($@)" $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@) diff --git a/core/package_internal.mk b/core/package_internal.mk index 58db27d07..49a6d9bb3 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -388,6 +388,7 @@ else $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) endif endif +$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) @echo "target Package: $(PRIVATE_MODULE) ($@)" $(if $(PRIVATE_SOURCE_ARCHIVE),\