File: aapt2.mk

package info (click to toggle)
android-platform-build 1%3A8.1.0%2Br23-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,620 kB
  • sloc: python: 12,074; cpp: 6,068; cs: 5,512; makefile: 2,356; sh: 1,829; java: 1,359; ansic: 987
file content (103 lines) | stat: -rw-r--r-- 4,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
######################################
# Compile resource with AAPT2
# Input variables:
# - full_android_manifest
# - my_res_resources
# - my_overlay_resources
# - my_compiled_res_base_dir
# - my_asset_dirs
# - my_full_asset_paths
# - 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
#
######################################

# 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))

my_generated_resources_flata :=
# Compile generated resources
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)
$(my_generated_resources_flata) : $(my_generated_res_dirs_deps) $(AAPT2)
	@echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIRS)"
	$(call aapt2-compile-resource-dirs)

my_generated_resources_flata += $(my_generated_resources_flata)
endif

$(my_res_resources_flat) $(my_overlay_resources_flat) $(my_generated_resources_flata): \
  PRIVATE_AAPT2_CFLAGS := $(PRODUCT_AAPT2_CFLAGS)

my_static_library_resources := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES)),\
  $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\
  $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)

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)
$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
$(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs)
$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
$(my_res_package): $(my_full_asset_paths)
$(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \
  $(my_generated_resources_flata) $(my_static_library_resources) \
  $(AAPT2)
	@echo "AAPT2 link $@"
	$(call aapt2-link)

ifdef R_file_stamp
$(R_file_stamp) : $(my_res_package) | $(ACP)
	@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
	@rm -rf $@ && mkdir -p $(dir $@)
	$(call find-generated-R.java)
endif

ifdef proguard_options_file
$(proguard_options_file) : $(my_res_package)
endif

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
$(R_file_stamp) : $(resource_export_package)

$(resource_export_package) : $(my_res_package) | $(ACP)
	@echo "target Export Resources: $(PRIVATE_MODULE) $(@)"
	$(copy-file-to-new-target)

endif