"...android_kernel_samsung_matisse.git" did not exist on "97950c3d423e474ef887749b238ee67731b532fe"
Commit 1425e2d8 authored by Ying Wang's avatar Ying Wang
Browse files

Support LOCAL_PACKAGE_SPLITS.

Support LOCAL_PACKAGE_SPLITS, which accepts a list of resource lables
and generates multiple apks. The build system sets up rules to sign and
zipalign the split apks.

Bug: 16319961
Change-Id: I344b3d1c7eb158c6d0df879093d666a89870aadd
parent 337bbf89
File added
...@@ -176,7 +176,6 @@ else ...@@ -176,7 +176,6 @@ else
built_module_path := $(intermediates) built_module_path := $(intermediates)
endif endif
LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem) LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem)
built_module_path :=
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
# Apk and its attachments reside in its own subdir. # Apk and its attachments reside in its own subdir.
......
...@@ -23,6 +23,7 @@ LOCAL_PACKAGE_NAME:= ...@@ -23,6 +23,7 @@ LOCAL_PACKAGE_NAME:=
LOCAL_OVERRIDES_PACKAGES:= LOCAL_OVERRIDES_PACKAGES:=
LOCAL_EXPORT_PACKAGE_RESOURCES:= LOCAL_EXPORT_PACKAGE_RESOURCES:=
LOCAL_MANIFEST_PACKAGE_NAME:= LOCAL_MANIFEST_PACKAGE_NAME:=
LOCAL_PACKAGE_SPLITS:=
LOCAL_REQUIRED_MODULES:= LOCAL_REQUIRED_MODULES:=
LOCAL_ACP_UNAVAILABLE:= LOCAL_ACP_UNAVAILABLE:=
LOCAL_MODULE_TAGS:= LOCAL_MODULE_TAGS:=
......
...@@ -1805,6 +1805,18 @@ $(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned ...@@ -1805,6 +1805,18 @@ $(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned
$(hide) mv $@.aligned $@ $(hide) mv $@.aligned $@
endef endef
# Build a split APK
# The splti APKs are already built in the same command building the base APK.
# We only need to do zipalign and signing etc.
# This macro must be called with $(eval).
# $(1): the path to the built split APK.
# $(2): the path to the base APK.
define build-split-apk
$(1) : $(2)
$$(sign-package)
$$(align-package)
endef
define install-dex-debug define install-dex-debug
$(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \ $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \
mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ mkdir -p $(TOP)/dalvik/DEBUG-FILES; \
......
...@@ -68,6 +68,10 @@ ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) ...@@ -68,6 +68,10 @@ ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
endif endif
ifdef LOCAL_PACKAGE_SPLITS
LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
endif
ifeq (,$(LOCAL_ASSET_DIR)) ifeq (,$(LOCAL_ASSET_DIR))
LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
endif endif
...@@ -403,6 +407,32 @@ $(built_odex) : $(built_dex) ...@@ -403,6 +407,32 @@ $(built_odex) : $(built_dex)
$(hide) rm $@.input $(hide) rm $@.input
endif endif
###############################
## APK splits
ifdef LOCAL_PACKAGE_SPLITS
built_apk_splits := $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/package_$(s).apk)
installed_apk_splits := $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key)
$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate)
# The splits should have been built in the same command building the base apk.
# This rule just establishes the dependency and make sure the splits are up to date.
$(foreach s,$(built_apk_splits),\
$(eval $(call build-split-apk,$(s),$(LOCAL_BUILT_MODULE))))
# Rules to install the splits
$(foreach s,$(LOCAL_PACKAGE_SPLITS),\
$(eval $(call copy-one-file,$(built_module_path)/package_$(s).apk,$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)))
# Register the additional built and installed files.
ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
$(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
# Make sure to install the splits when you run "make <module_name>".
$(my_register_name): $(installed_apk_splits)
endif # LOCAL_PACKAGE_SPLITS
# Save information about this package # Save information about this package
PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources) PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment