Add split support for AAPT2
AAPT2 allows the declaration of a split path, so that build systems
don't need to guess the auto-generated name.
Construct the split path we want from the configurations passed in to
LOCAL_PACKAGE_SPLITS.
Bug:30445078
Change-Id: I06a4148b283d0c6751751ba116e9482c3a6eae5d
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 9545823..2a36ce7 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -75,10 +75,6 @@
LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
endif
-ifdef LOCAL_PACKAGE_SPLITS
-LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
-endif
-
need_compile_asset :=
ifeq (,$(LOCAL_ASSET_DIR))
LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
@@ -163,6 +159,10 @@
) \
))
+ifdef LOCAL_PACKAGE_SPLITS
+LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
+endif
+
endif # LOCAL_USE_AAPT2
ifneq ($(all_resources),)
@@ -171,7 +171,6 @@
all_res_assets := $(strip $(all_assets) $(all_resources))
-
# If no assets or resources were found, clear the directory variables so
# we don't try to build them.
ifneq (true,$(need_compile_asset))
@@ -325,6 +324,20 @@
endif # LOCAL_DATA_BINDING
ifeq ($(need_compile_res),true)
+
+###############################
+## APK splits
+built_apk_splits :=
+installed_apk_splits :=
+my_apk_split_configs :=
+
+ifdef LOCAL_PACKAGE_SPLITS
+my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS)
+my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs))
+built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk)
+installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
+endif
+
ifdef LOCAL_USE_AAPT2
my_compiled_res_base_dir := $(intermediates)/flat-res
my_generated_res_dirs := $(rs_generated_res_dir)
@@ -548,12 +561,6 @@
###############################
## APK splits
ifdef LOCAL_PACKAGE_SPLITS
-# LOCAL_PACKAGE_SPLITS is a list of resource labels.
-# aapt will convert comma inside resource lable to underscore in the file names.
-my_split_suffixes := $(subst $(comma),_,$(LOCAL_PACKAGE_SPLITS))
-built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk)
-installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
-
# The splits should have been built in the same command building the base apk.
# This rule just runs signing.
# Note that we explicily check the existence of the split apk and remove the