2015-12-04 22:59:18 +01:00
|
|
|
######################################
|
|
|
|
# Compile resource with AAPT2
|
|
|
|
# Input variables:
|
2016-08-12 21:57:17 +02:00
|
|
|
# - full_android_manifest
|
|
|
|
# - my_res_resources
|
|
|
|
# - my_overlay_resources
|
|
|
|
# - my_compiled_res_base_dir
|
2017-03-16 05:53:05 +01:00
|
|
|
# - my_asset_dirs
|
|
|
|
# - my_full_asset_paths
|
2016-08-12 21:57:17 +02:00
|
|
|
# - 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.
|
2018-03-13 07:33:15 +01:00
|
|
|
# - my_generated_res_zips: Zip files containing resources
|
2016-08-12 21:57:17 +02:00
|
|
|
# - my_apk_split_configs: The configurations for which to generate splits.
|
|
|
|
# - built_apk_splits: The paths where AAPT should generate the splits.
|
2016-02-24 23:11:55 +01:00
|
|
|
#
|
2015-12-04 22:59:18 +01:00
|
|
|
# Output variables:
|
2016-08-12 21:57:17 +02:00
|
|
|
# - my_res_resources_flat
|
|
|
|
# - my_overlay_resources_flat
|
|
|
|
# - my_generated_resources_flata
|
2015-12-04 22:59:18 +01:00
|
|
|
#
|
|
|
|
######################################
|
|
|
|
|
|
|
|
# Compile all the resource files.
|
|
|
|
my_res_resources_flat := \
|
|
|
|
$(foreach r, $(my_res_resources),\
|
|
|
|
$(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\
|
|
|
|
$(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\
|
|
|
|
$(o))
|
|
|
|
|
|
|
|
my_overlay_resources_flat := \
|
|
|
|
$(foreach r, $(my_overlay_resources),\
|
|
|
|
$(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\
|
|
|
|
$(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\
|
|
|
|
$(o))
|
|
|
|
|
2018-03-13 07:33:15 +01:00
|
|
|
my_resources_flata :=
|
2015-12-04 22:59:18 +01:00
|
|
|
# Compile generated resources
|
2016-02-24 23:11:55 +01:00
|
|
|
ifneq ($(my_generated_res_dirs),)
|
|
|
|
my_generated_resources_flata := $(my_compiled_res_base_dir)/gen_res.flata
|
|
|
|
$(my_generated_resources_flata): PRIVATE_SOURCE_RES_DIRS := $(my_generated_res_dirs)
|
2017-06-08 09:14:32 +02:00
|
|
|
$(my_generated_resources_flata) : $(my_generated_res_dirs_deps) $(AAPT2)
|
2016-02-24 23:11:55 +01:00
|
|
|
@echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIRS)"
|
|
|
|
$(call aapt2-compile-resource-dirs)
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2018-03-13 07:33:15 +01:00
|
|
|
my_resources_flata += $(my_generated_resources_flata)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Compile zipped resources
|
|
|
|
ifneq ($(my_generated_res_zips),)
|
|
|
|
my_zipped_resources_flata := $(my_compiled_res_base_dir)/zip_res.flata
|
|
|
|
$(my_zipped_resources_flata): PRIVATE_SOURCE_RES_ZIPS := $(my_generated_res_zips)
|
2018-05-16 01:04:47 +02:00
|
|
|
$(my_zipped_resources_flata) : $(my_generated_res_zips) $(AAPT2) $(ZIPSYNC)
|
2018-03-13 07:33:15 +01:00
|
|
|
@echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_ZIPS)"
|
|
|
|
$(call aapt2-compile-resource-zips)
|
|
|
|
|
|
|
|
my_resources_flata += $(my_zipped_resources_flata)
|
2015-12-04 22:59:18 +01:00
|
|
|
endif
|
|
|
|
|
2017-10-28 01:10:18 +02:00
|
|
|
# Always set --pseudo-localize, it will be stripped out later for release
|
|
|
|
# builds that don't want it.
|
2019-06-22 22:03:09 +02:00
|
|
|
$(my_res_resources_flat) $(my_overlay_resources_flat) $(my_resources_flata) $(my_generated_resources_flata) $(my_zippped_resources_flata): \
|
|
|
|
PRIVATE_AAPT2_CFLAGS := --pseudo-localize $(filter --legacy,$(LOCAL_AAPT_FLAGS))
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2018-05-23 22:35:53 +02:00
|
|
|
# TODO(b/78447299): Forbid LOCAL_STATIC_JAVA_AAR_LIBRARIES in aapt2 and remove
|
|
|
|
# support for it.
|
|
|
|
my_static_library_resources := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\
|
2016-02-24 23:11:55 +01:00
|
|
|
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
|
2023-06-24 01:17:54 +02:00
|
|
|
my_static_library_transitive_resource_packages_lists := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\
|
|
|
|
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/transitive-res-packages)
|
2018-05-23 22:35:53 +02:00
|
|
|
my_static_library_extra_packages := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\
|
2018-05-02 21:52:43 +02:00
|
|
|
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/extra_packages)
|
2016-02-24 23:11:55 +01:00
|
|
|
my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\
|
|
|
|
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2016-03-03 03:55:46 +01:00
|
|
|
ifneq ($(my_static_library_resources),)
|
|
|
|
$(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay
|
|
|
|
endif
|
|
|
|
|
2016-08-12 21:57:17 +02:00
|
|
|
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
|
|
|
|
|
2018-03-09 01:49:16 +01:00
|
|
|
my_srcjar := $(intermediates.COMMON)/aapt2.srcjar
|
|
|
|
LOCAL_SRCJARS += $(my_srcjar)
|
|
|
|
|
2018-05-02 21:52:43 +02:00
|
|
|
aapt_extra_packages := $(intermediates.COMMON)/extra_packages
|
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
$(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat)
|
2018-03-13 07:33:15 +01:00
|
|
|
$(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_resources_flata) $(my_overlay_resources_flat)
|
2016-02-24 23:11:55 +01:00
|
|
|
$(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources)
|
2015-12-04 22:59:18 +01:00
|
|
|
$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
|
2017-03-16 05:53:05 +01:00
|
|
|
$(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs)
|
2018-03-09 01:49:16 +01:00
|
|
|
$(my_res_package): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt2
|
|
|
|
$(my_res_package): PRIVATE_SRCJAR := $(my_srcjar)
|
2018-05-02 21:52:43 +02:00
|
|
|
$(my_res_package): PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES := $(my_static_library_extra_packages)
|
2023-06-24 01:17:54 +02:00
|
|
|
$(my_res_package): PRIVATE_STATIC_LIBRARY_TRANSITIVE_RES_PACKAGES_LISTS := $(my_static_library_transitive_resource_packages_lists)
|
2018-05-02 21:52:43 +02:00
|
|
|
$(my_res_package): PRIVATE_AAPT_EXTRA_PACKAGES := $(aapt_extra_packages)
|
|
|
|
$(my_res_package): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar) $(aapt_extra_packages)
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2016-02-24 23:11:55 +01:00
|
|
|
ifdef R_file_stamp
|
2017-09-30 04:18:21 +02:00
|
|
|
$(my_res_package): PRIVATE_R_FILE_STAMP := $(R_file_stamp)
|
|
|
|
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(R_file_stamp)
|
2016-02-24 23:11:55 +01:00
|
|
|
endif
|
2015-12-04 22:59:18 +01:00
|
|
|
|
|
|
|
resource_export_package :=
|
|
|
|
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
|
|
|
|
# Put this module's resources into a PRODUCT-agnositc package that
|
|
|
|
# other packages can use to build their own PRODUCT-agnostic R.java (etc.)
|
|
|
|
# files.
|
|
|
|
resource_export_package := $(intermediates.COMMON)/package-export.apk
|
2017-09-30 04:18:21 +02:00
|
|
|
$(my_res_package): PRIVATE_RESOURCE_EXPORT_PACKAGE := $(resource_export_package)
|
|
|
|
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(resource_export_package)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef proguard_options_file
|
|
|
|
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(proguard_options_file)
|
|
|
|
endif
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2023-06-24 01:17:54 +02:00
|
|
|
$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_static_library_transitive_resource_packages_lists) $(my_shared_library_resources)
|
2017-09-30 04:18:21 +02:00
|
|
|
$(my_res_package): $(my_full_asset_paths)
|
|
|
|
$(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \
|
2018-05-02 21:52:43 +02:00
|
|
|
$(my_resources_flata) $(my_static_library_resources) $(my_static_library_extra_packages) \
|
|
|
|
$(AAPT2) $(SOONG_ZIP) $(EXTRACT_JAR_PACKAGES)
|
2017-09-30 04:18:21 +02:00
|
|
|
@echo "AAPT2 link $@"
|
|
|
|
$(call aapt2-link)
|
|
|
|
ifdef R_file_stamp
|
|
|
|
@rm -f $(PRIVATE_R_FILE_STAMP)
|
2018-03-09 01:49:16 +01:00
|
|
|
$(call find-generated-R.java,$(PRIVATE_JAVA_GEN_DIR),$(PRIVATE_R_FILE_STAMP))
|
2017-09-30 04:18:21 +02:00
|
|
|
endif
|
|
|
|
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
|
|
|
|
@rm -f $(PRIVATE_RESOURCE_EXPORT_PACKAGE)
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2017-09-30 04:18:21 +02:00
|
|
|
cp $@ $(PRIVATE_RESOURCE_EXPORT_PACKAGE)
|
2015-12-04 22:59:18 +01:00
|
|
|
endif
|
2017-11-16 02:00:46 +01:00
|
|
|
|
|
|
|
# Clear inputs only used in this file, so that they're not re-used during the next build
|
|
|
|
my_res_resources :=
|
|
|
|
my_overlay_resources :=
|
|
|
|
my_compiled_res_base_dir :=
|
|
|
|
my_asset_dirs :=
|
|
|
|
my_full_asset_paths :=
|
|
|
|
my_apk_split_configs :=
|
|
|
|
my_generated_res_dirs :=
|
|
|
|
my_generated_res_dirs_deps :=
|
2018-03-13 07:33:15 +01:00
|
|
|
my_generated_res_zips :=
|