From a0f464a8e7f006177db084df7e925bbb8e5ffed3 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 14 Oct 2011 19:37:57 -0700 Subject: [PATCH] New PRODUCT_AAPT_PREF_CONFIG. To use the new aapt --preferred-configurations option. For use with Prime to be able to strip everything but xhdpi density bitmaps selectively, not stripping when this would result in no data for the resource. Change-Id: I4e1012929b8f9b0b1e79c06496647f69661ba1f2 --- core/cleanbuild.mk | 2 +- core/definitions.mk | 1 + core/package.mk | 3 +++ core/product.mk | 1 + core/product_config.mk | 4 ++++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk index 2ac572f133..e6db5cbb3b 100644 --- a/core/cleanbuild.mk +++ b/core/cleanbuild.mk @@ -118,7 +118,7 @@ else endif # A change in the list of aapt configs warrants an installclean, too. -aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG)) +aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG) $(PRODUCT_AAPT_PREF_CONFIG)) current_build_config := \ $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)-{$(aapt_config_list)} diff --git a/core/definitions.mk b/core/definitions.mk index 1afc0f4684..1a7cf4bbe6 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1559,6 +1559,7 @@ endef define add-assets-to-package $(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \ + $(addprefix --preferred-configurations , $(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \ $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ diff --git a/core/package.mk b/core/package.mk index 398e487d87..07cdbd0b2c 100644 --- a/core/package.mk +++ b/core/package.mk @@ -227,6 +227,7 @@ $(R_file_stamp): $(resource_export_package) # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target # can't know anything about PRODUCT. Clear it out just for this target. $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := +$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" $(create-empty-package) @@ -343,8 +344,10 @@ ifneq ($(TARGET_BUILD_APPS),) endif ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := + $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := else $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG) + $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) endif $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) @echo "target Package: $(PRIVATE_MODULE) ($@)" diff --git a/core/product.mk b/core/product.mk index 72cb2f7a3b..0ab9ae0d30 100644 --- a/core/product.mk +++ b/core/product.mk @@ -64,6 +64,7 @@ _product_var_list := \ PRODUCT_MODEL \ PRODUCT_LOCALES \ PRODUCT_AAPT_CONFIG \ + PRODUCT_AAPT_PREF_CONFIG \ PRODUCT_PACKAGES \ PRODUCT_DEVICE \ PRODUCT_MANUFACTURER \ diff --git a/core/product_config.mk b/core/product_config.mk index e673d5ca78..e063e429f6 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -228,12 +228,14 @@ endif # Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG PRODUCT_AAPT_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_CONFIG)) PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) $(PRODUCT_AAPT_CONFIG) +PRODUCT_AAPT_PREF_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREF_CONFIG)) # Default to medium-density assets. # (Can be overridden in the device config, e.g.: PRODUCT_AAPT_CONFIG += hdpi) PRODUCT_AAPT_CONFIG := $(strip \ $(PRODUCT_AAPT_CONFIG) \ $(if $(filter %dpi,$(PRODUCT_AAPT_CONFIG)),,mdpi)) +PRODUCT_AAPT_PREF_CONFIG := $(strip $(PRODUCT_AAPT_PREF_CONFIG)) # Everyone gets nodpi assets which are density-independent. PRODUCT_AAPT_CONFIG += nodpi @@ -242,6 +244,8 @@ PRODUCT_AAPT_CONFIG += nodpi comma := , PRODUCT_AAPT_CONFIG := \ $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG))) +PRODUCT_AAPT_PREF_CONFIG := \ + $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_PREF_CONFIG))) PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))