diff --git a/core/aapt2.mk b/core/aapt2.mk index ccc453576..34f32e3bc 100644 --- a/core/aapt2.mk +++ b/core/aapt2.mk @@ -1,20 +1,25 @@ ###################################### # Compile resource with AAPT2 # Input variables: -# full_android_manifest, -# my_res_resources, my_overlay_resources, -# my_compiled_res_base_dir, my_res_package, -# R_file_stamp, proguard_options_file -# my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2. -# my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs. +# - full_android_manifest +# - my_res_resources +# - my_overlay_resources +# - my_compiled_res_base_dir +# - my_res_package +# - R_file_stamp +# - proguard_options_file +# - my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2. +# - my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs. +# - my_apk_split_configs: The configurations for which to generate splits. +# - built_apk_splits: The paths where AAPT should generate the splits. # # Output variables: -# my_res_resources_flat, my_overlay_resources_flat, -# my_generated_resources_flata +# - my_res_resources_flat +# - my_overlay_resources_flat +# - my_generated_resources_flata # ###################################### - # Compile all the resource files. my_res_resources_flat := \ $(foreach r, $(my_res_resources),\ @@ -52,6 +57,11 @@ ifneq ($(my_static_library_resources),) $(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay endif +ifneq ($(my_apk_split_configs),) +# Join the Split APK paths with their configuration, separated by a ':'. +$(my_res_package): PRIVATE_AAPT_FLAGS += $(addprefix --split ,$(join $(built_apk_splits),$(addprefix :,$(my_apk_split_configs)))) +endif + $(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat) $(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_generated_resources_flata) $(my_overlay_resources_flat) $(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources) diff --git a/core/package_internal.mk b/core/package_internal.mk index 9545823f9..2a36ce7a3 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -75,10 +75,6 @@ ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) 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 @@ all_resources := $(strip \ ) \ )) +ifdef LOCAL_PACKAGE_SPLITS +LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS)) +endif + endif # LOCAL_USE_AAPT2 ifneq ($(all_resources),) @@ -171,7 +171,6 @@ endif 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 @@ $(built_dex_intermediate) : $(data_binding_stamp) 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 @@ endif ############################### ## 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