OSDN Git Service

Fix issue #2048267: Run zipalign on all prebuilts
authorDianne Hackborn <hackbod@google.com>
Wed, 12 Aug 2009 02:16:46 +0000 (19:16 -0700)
committerDianne Hackborn <hackbod@google.com>
Wed, 12 Aug 2009 02:41:51 +0000 (19:41 -0700)
core/definitions.mk
core/prebuilt.mk

index 1c2f05b..e4d2ecb 100644 (file)
@@ -1469,6 +1469,12 @@ define copy-file-to-target-with-cp
 $(hide) cp -fp $< $@
 endef
 
+# The same as copy-file-to-target, but use the zipalign tool to do so.
+define copy-file-to-target-with-zipalign
+@mkdir -p $(dir $@)
+$(hide) $(ZIPALIGN) -f 4 $< $@
+endef
+
 # The same as copy-file-to-target, but strip out "# comment"-style
 # comments (for config files and such).
 define copy-file-to-target-strip-comments
@@ -1496,6 +1502,12 @@ define transform-prebuilt-to-target
 $(copy-file-to-target)
 endef
 
+# Copy a prebuilt file to a target location, using zipalign on it.
+define transform-prebuilt-to-target-with-zipalign
+@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)"
+$(copy-file-to-target-with-zipalign)
+endef
+
 # Copy a prebuilt file to a target location, stripping "# comment" comments.
 define transform-prebuilt-to-target-strip-comments
 @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)"
index 6df276c..34d2453 100644 (file)
@@ -26,6 +26,11 @@ else
   prebuilt_module_is_a_library :=
 endif
 
+# Ensure that prebuilt .apks have been aligned.
+ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
+       $(transform-prebuilt-to-target-with-zipalign)
+else
 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
 $(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
        $(transform-prebuilt-to-target-strip-comments)
@@ -33,6 +38,8 @@ else
 $(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
        $(transform-prebuilt-to-target)
 endif
+endif
+
 ifneq ($(prebuilt_module_is_a_library),)
   ifneq ($(LOCAL_IS_HOST_MODULE),)
        $(transform-host-ranlib-copy-hack)