Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame^] | 1 | ###################################### |
| 2 | # Compile resource with AAPT2 |
| 3 | # Input variables: |
| 4 | # full_android_manifest, |
| 5 | # my_res_resources, my_overlay_resources, my_aapt_characteristics, |
| 6 | # my_compiled_res_base_dir, rs_generated_res_dir, my_res_package, |
| 7 | # R_file_stamp, proguard_options_file |
| 8 | # Output variables: |
| 9 | # my_res_resources_flat, my_overlay_resources_flat, |
| 10 | # my_generated_resources_flata |
| 11 | # |
| 12 | ###################################### |
| 13 | |
| 14 | |
| 15 | # Compile all the resource files. |
| 16 | my_res_resources_flat := \ |
| 17 | $(foreach r, $(my_res_resources),\ |
| 18 | $(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\ |
| 19 | $(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\ |
| 20 | $(o)) |
| 21 | |
| 22 | my_overlay_resources_flat := \ |
| 23 | $(foreach r, $(my_overlay_resources),\ |
| 24 | $(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\ |
| 25 | $(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\ |
| 26 | $(o)) |
| 27 | |
| 28 | my_generated_resources_flata := |
| 29 | # Compile generated resources |
| 30 | ifneq ($(rs_generated_res_dir),) |
| 31 | rs_gen_resource_flata := $(my_compiled_res_base_dir)/renderscript_gen_res.flata |
| 32 | $(rs_gen_resource_flata): PRIVATE_SOURCE_RES_DIR := $(rs_generated_res_dir) |
| 33 | $(rs_gen_resource_flata) : $(RenderScript_file_stamp) |
| 34 | @echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIR)" |
| 35 | $(call aapt2-compile-one-resource-dir) |
| 36 | |
| 37 | my_generated_resources_flata += $(rs_gen_resource_flata) |
| 38 | endif |
| 39 | |
| 40 | $(my_res_resources_flat) $(my_overlay_resources_flat) $(my_generated_resources_flata): \ |
| 41 | PRIVATE_AAPT2_CFLAGS := $(addprefix --product ,$(my_aapt_characteristics)) |
| 42 | |
| 43 | # Link the static library resource packages. |
| 44 | my_static_library_resources := $(foreach l, $(LOCAL_STATIC_JAVA_LIBRARIES),\ |
| 45 | $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/library-res.flata) |
| 46 | |
| 47 | $(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat) |
| 48 | $(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_overlay_resources_flat) $(my_generated_resources_flata) $(my_static_library_resources) |
| 49 | $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) |
| 50 | $(my_res_package) : $(full_android_manifest) |
| 51 | $(my_res_package) : $(my_res_resources_flat) $(my_overlay_resources_flat) \ |
| 52 | $(my_generated_resources_flata) $(my_static_library_resources) \ |
| 53 | $(AAPT2) |
| 54 | @echo "AAPT2 link $@" |
| 55 | $(call aapt2-link) |
| 56 | |
| 57 | $(R_file_stamp) : $(my_res_package) | $(ACP) |
| 58 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 59 | @rm -rf $@ && mkdir -p $(dir $@) |
| 60 | $(call find-generated-R.java) |
| 61 | |
| 62 | $(proguard_options_file) : $(my_res_package) |
| 63 | |
| 64 | resource_export_package := |
| 65 | ifdef LOCAL_EXPORT_PACKAGE_RESOURCES |
| 66 | # Put this module's resources into a PRODUCT-agnositc package that |
| 67 | # other packages can use to build their own PRODUCT-agnostic R.java (etc.) |
| 68 | # files. |
| 69 | resource_export_package := $(intermediates.COMMON)/package-export.apk |
| 70 | $(R_file_stamp) : $(resource_export_package) |
| 71 | |
| 72 | $(resource_export_package) : $(my_res_package) | $(ACP) |
| 73 | @echo "target Export Resources: $(PRIVATE_MODULE) $(@)" |
| 74 | $(copy-file-to-new-target) |
| 75 | |
| 76 | endif |