From 43f7a3226afd3439b9e83c05606d14e3766381cc Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 17 Nov 2014 16:56:04 -0800 Subject: [PATCH] Support prebuilt apk source selection based on PRODUCT_AAPT_PREF_CONFIG Two new LOCAL variables are added to support dpi-specific prebuilt apk selection: - LOCAL_DPI_VARIANTS: specify a list of dpis the module provides with specific prebuilt. Example: LOCAL_DPI_VARIANTS := xxhdpi xhdpi hdpi mdpi - LOCAL_DPI_FILE_STEM: specify the dpi-specific source file name pattern. Example: LOCAL_DPI_FILE_STEM := MyApp-%.apk "%" will be substitued by $(PRODUCT_AAPT_PREF_CONFIG) in the core build system. If you don't set up LOCAL_DPI_FILE_STEM, the default is $(LOCAL_MODULE)_%.apk. The build system searches $(PRODUCT_AAPT_PREF_CONFIG) in a prebuilt apk module's $(LOCAL_DPI_VARIANTS). If not found, use whatever $(LOCAL_SRC_FILES) as the source file; Otherwise use $(LOCAL_DPI_FILE_STEM) to construct the dpi-specific apk's source file name, and use whatever directory name of $(LOCAL_SRC_FILES). Bug: 18388705 Change-Id: I63cae73f1b6f880302142abc476b3ce1fb5500b5 --- core/clear_vars.mk | 2 ++ core/prebuilt_internal.mk | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 92b3fc45f..361988067 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -158,6 +158,8 @@ LOCAL_MODULE_TARGET_ARCH_WARN:= LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:= LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:= LOCAL_MODULE_HOST_ARCH:= +LOCAL_DPI_VARIANTS:= +LOCAL_DPI_FILE_STEM:= # arch specific variables LOCAL_SRC_FILES_$(TARGET_ARCH):= diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 284884cda..5c02f8d3b 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -114,6 +114,19 @@ endif # LOCAL_STRIP_MODULE not true ifeq ($(LOCAL_MODULE_CLASS),APPS) PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) +# Select dpi-specific source +ifdef LOCAL_DPI_VARIANTS +my_dpi := $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG)) +ifdef my_dpi +ifdef LOCAL_DPI_FILE_STEM +my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM) +else +my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk +endif +my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem)) +endif # my_dpi +endif # LOCAL_DPI_VARIANTS + rs_compatibility_jni_libs := include $(BUILD_SYSTEM)/install_jni_libs.mk