forked from openkylin/platform_build
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
This commit is contained in:
parent
0e677b426d
commit
4c45205c99
|
@ -1,20 +1,25 @@
|
||||||
######################################
|
######################################
|
||||||
# Compile resource with AAPT2
|
# Compile resource with AAPT2
|
||||||
# Input variables:
|
# Input variables:
|
||||||
# full_android_manifest,
|
# - full_android_manifest
|
||||||
# my_res_resources, my_overlay_resources,
|
# - my_res_resources
|
||||||
# my_compiled_res_base_dir, my_res_package,
|
# - my_overlay_resources
|
||||||
# R_file_stamp, proguard_options_file
|
# - my_compiled_res_base_dir
|
||||||
# my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2.
|
# - my_res_package
|
||||||
# my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs.
|
# - 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:
|
# Output variables:
|
||||||
# my_res_resources_flat, my_overlay_resources_flat,
|
# - my_res_resources_flat
|
||||||
# my_generated_resources_flata
|
# - my_overlay_resources_flat
|
||||||
|
# - my_generated_resources_flata
|
||||||
#
|
#
|
||||||
######################################
|
######################################
|
||||||
|
|
||||||
|
|
||||||
# Compile all the resource files.
|
# Compile all the resource files.
|
||||||
my_res_resources_flat := \
|
my_res_resources_flat := \
|
||||||
$(foreach r, $(my_res_resources),\
|
$(foreach r, $(my_res_resources),\
|
||||||
|
@ -52,6 +57,11 @@ ifneq ($(my_static_library_resources),)
|
||||||
$(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay
|
$(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay
|
||||||
endif
|
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_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_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)
|
$(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources)
|
||||||
|
|
|
@ -75,10 +75,6 @@ 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
|
|
||||||
|
|
||||||
need_compile_asset :=
|
need_compile_asset :=
|
||||||
ifeq (,$(LOCAL_ASSET_DIR))
|
ifeq (,$(LOCAL_ASSET_DIR))
|
||||||
LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
|
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
|
endif # LOCAL_USE_AAPT2
|
||||||
|
|
||||||
ifneq ($(all_resources),)
|
ifneq ($(all_resources),)
|
||||||
|
@ -171,7 +171,6 @@ endif
|
||||||
|
|
||||||
all_res_assets := $(strip $(all_assets) $(all_resources))
|
all_res_assets := $(strip $(all_assets) $(all_resources))
|
||||||
|
|
||||||
|
|
||||||
# If no assets or resources were found, clear the directory variables so
|
# If no assets or resources were found, clear the directory variables so
|
||||||
# we don't try to build them.
|
# we don't try to build them.
|
||||||
ifneq (true,$(need_compile_asset))
|
ifneq (true,$(need_compile_asset))
|
||||||
|
@ -325,6 +324,20 @@ $(built_dex_intermediate) : $(data_binding_stamp)
|
||||||
endif # LOCAL_DATA_BINDING
|
endif # LOCAL_DATA_BINDING
|
||||||
|
|
||||||
ifeq ($(need_compile_res),true)
|
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
|
ifdef LOCAL_USE_AAPT2
|
||||||
my_compiled_res_base_dir := $(intermediates)/flat-res
|
my_compiled_res_base_dir := $(intermediates)/flat-res
|
||||||
my_generated_res_dirs := $(rs_generated_res_dir)
|
my_generated_res_dirs := $(rs_generated_res_dir)
|
||||||
|
@ -548,12 +561,6 @@ endif
|
||||||
###############################
|
###############################
|
||||||
## APK splits
|
## APK splits
|
||||||
ifdef LOCAL_PACKAGE_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.
|
# The splits should have been built in the same command building the base apk.
|
||||||
# This rule just runs signing.
|
# This rule just runs signing.
|
||||||
# Note that we explicily check the existence of the split apk and remove the
|
# Note that we explicily check the existence of the split apk and remove the
|
||||||
|
|
Loading…
Reference in New Issue