diff options
author | Ying Wang <wangying@google.com> | 2014-12-01 17:46:56 -0800 |
---|---|---|
committer | Bill Yi <byi@google.com> | 2014-12-02 18:17:55 +0000 |
commit | 8070b20f9ec899a5dc27c7589f11c6db8c72180a (patch) | |
tree | 7e64bf739c124ad9078fdab039120039069b6f69 /core | |
parent | 43fbdb2acb8e4e673d963630acbc32ab2717139c (diff) | |
download | build-8070b20f9ec899a5dc27c7589f11c6db8c72180a.zip build-8070b20f9ec899a5dc27c7589f11c6db8c72180a.tar.gz build-8070b20f9ec899a5dc27c7589f11c6db8c72180a.tar.bz2 |
Support to build dpi-specific apk variants.
In unbundled apps_only build, in addition to the base apk, you can also
build the dpi-specific apk variants, with:
LOCAL_DPI_VARIANTS := <a list of dpi names>
Previously user needs to include $(BUILD_PACKAGE) repeatedly with the
same package definition except dpi flags.
With this change, all the dpi-specific apk variants share the base apk's
compiled Java code and only diverge at the point we add resources/assets
to the apk.
Also we set up variables/targets/rules in a way those dpi-specific apks
appear to be independent apks to the users, for example, you can pass
"AppName_<dpi_name>" to tapas, and AppName_<dpi_name>.apk lives in its
own intermediate directory.
Bug: 18388705
Change-Id: I2ba4972ea7d1f796352fab2407888f996781ae44
Diffstat (limited to 'core')
-rw-r--r-- | core/dpi_specific_apk.mk | 70 | ||||
-rw-r--r-- | core/package_internal.mk | 10 |
2 files changed, 80 insertions, 0 deletions
diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk new file mode 100644 index 0000000..aad4713 --- /dev/null +++ b/core/dpi_specific_apk.mk @@ -0,0 +1,70 @@ +# Set up rules to build dpi-specific apk, with whatever else from the base apk. +# Input variable: my_dpi, and all other variables set up in package_internal.mk. +# + +dpi_apk_name := $(LOCAL_MODULE)_$(my_dpi) +dpi_intermediate := $(call intermediates-dir-for,APPS,$(dpi_apk_name)) +built_dpi_apk := $(dpi_intermediate)/package.apk + +# Set up all the target-specific variables. +$(built_dpi_apk): PRIVATE_MODULE := $(dpi_apk_name) +$(built_dpi_apk): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS) +# Clear PRIVATE_PRODUCT_AAPT_CONFIG to include everything by default. +$(built_dpi_apk): PRIVATE_PRODUCT_AAPT_CONFIG := +$(built_dpi_apk): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(my_dpi) +$(built_dpi_apk): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) +$(built_dpi_apk): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) +$(built_dpi_apk): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR) +$(built_dpi_apk): PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports) +ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) +$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) +else +$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) +endif +$(built_dpi_apk): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) +$(built_dpi_apk): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_INSTRUMENTATION_FOR) +$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis) +$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis) +$(built_dpi_apk): PRIVATE_DEX_FILE := $(built_dex) +# Note that PRIVATE_CLASS_INTERMEDIATES_DIR points to the base apk's intermediate dir. +$(built_dpi_apk): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes +$(built_dpi_apk): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) +$(built_dpi_apk): PRIVATE_PRIVATE_KEY := $(private_key) +$(built_dpi_apk): PRIVATE_CERTIFICATE := $(certificate) +$(built_dpi_apk): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\ + $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8) + +# Set up dependenncies and the build recipe. +$(built_dpi_apk) : $(R_file_stamp) +$(built_dpi_apk) : $(all_library_res_package_export_deps) +$(built_dpi_apk) : $(built_dex) +$(built_dpi_apk) : $(private_key) $(certificate) $(SIGNAPK_JAR) +$(built_dpi_apk) : $(AAPT) | $(ZIPALIGN) +$(built_dpi_apk) : $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) + @echo "target Package: $(PRIVATE_MODULE) ($@)" + $(create-empty-package) + $(add-assets-to-package) +ifneq ($(jni_shared_libraries),) + $(add-jni-shared-libs-to-package) +endif +ifneq ($(full_classes_jar),) + $(add-dex-to-package) +endif + $(add-carried-java-resources) +ifneq ($(extra_jar_args),) + $(add-java-resources-to-package) +endif + $(sign-package) + $(align-package) + +# Set up global variables to register this apk to the higher-level dependency graph. +ALL_MODULES += $(dpi_apk_name) +ALL_MODULES.$(dpi_apk_name).CLASS := APPS +ALL_MODULES.$(dpi_apk_name).BUILT := $(built_dpi_apk) +PACKAGES := $(PACKAGES) $(dpi_apk_name) +PACKAGES.$(dpi_apk_name).PRIVATE_KEY := $(private_key) +PACKAGES.$(dpi_apk_name).CERTIFICATE := $(certificate) + +# Phony targets used by "apps_only". +.PHONY: $(dpi_apk_name) +$(dpi_apk_name) : $(built_dpi_apk) diff --git a/core/package_internal.mk b/core/package_internal.mk index bb458d4..933b32f 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -407,6 +407,16 @@ endif $(align-package) ############################### +## Build dpi-specific apks, if it's apps_only build. +ifdef TARGET_BUILD_APPS +ifdef LOCAL_DPI_VARIANTS +$(foreach d, $(LOCAL_DPI_VARIANTS), \ + $(eval my_dpi := $(d)) \ + $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk)) +endif +endif + +############################### ## Rule to build the odex file ifdef LOCAL_DEX_PREOPT $(built_odex): PRIVATE_DEX_FILE := $(built_dex) |