Merge "Refactor and further simplify the RRO logic"

This commit is contained in:
Anton Hansson 2019-03-20 14:35:25 +00:00 committed by Gerrit Code Review
commit 7c718f37f9
1 changed files with 42 additions and 43 deletions

View File

@ -109,14 +109,8 @@ include $(BUILD_SYSTEM)/force_aapt2.mk
# Process Support Library dependencies.
include $(BUILD_SYSTEM)/support_libraries.mk
package_resource_overlays := $(strip \
$(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
$(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
# Determine whether auto-RRO is enabled for this package.
enforce_rro_enabled :=
ifneq ($(package_resource_overlays),)
ifeq ($(PRODUCT_ENFORCE_RRO_TARGETS),*)
# * means all system APKs, so enable conditionally based on module path.
@ -137,23 +131,28 @@ ifneq ($(package_resource_overlays),)
else ifneq (,$(filter $(LOCAL_PACKAGE_NAME), $(PRODUCT_ENFORCE_RRO_TARGETS)))
enforce_rro_enabled := true
endif
endif
all_package_resource_overlays := $(strip \
$(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
$(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
static_resource_overlays :=
runtime_resource_overlays :=
ifdef enforce_rro_enabled
ifneq ($(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS),)
static_only_resource_overlays := $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(package_resource_overlays))
ifneq ($(static_only_resource_overlays),)
package_resource_overlays := $(filter-out $(static_only_resource_overlays),$(package_resource_overlays))
LOCAL_RESOURCE_DIR := $(static_only_resource_overlays) $(LOCAL_RESOURCE_DIR)
ifeq ($(package_resource_overlays),)
enforce_rro_enabled :=
endif
endif
static_resource_overlays += $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(all_package_resource_overlays))
endif
runtime_resource_overlays := $(filter-out $(static_resource_overlays),$(all_package_resource_overlays))
else
LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
static_resource_overlays := $(all_package_resource_overlays)
endif
# Add the static overlays. Auto-RRO is created later, as it depends on
# other logic in this file.
LOCAL_RESOURCE_DIR := $(static_resource_overlays) $(LOCAL_RESOURCE_DIR)
all_assets := $(strip \
$(foreach dir, $(LOCAL_ASSET_DIR), \
$(addprefix $(dir)/, \
@ -791,7 +790,7 @@ endif # skip_definition
# Reset internal variables.
all_res_assets :=
ifdef enforce_rro_enabled
ifdef runtime_resource_overlays
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
enforce_rro_use_res_lib := true
else
@ -811,6 +810,6 @@ $(call append_enforce_rro_sources, \
$(enforce_rro_is_manifest_package_name), \
$(enforce_rro_manifest_package_info), \
$(enforce_rro_use_res_lib), \
$(package_resource_overlays) \
$(runtime_resource_overlays) \
)
endif # enforce_rro_enabled
endif