Merge "AAPT2: library resource compilation" into nyc-dev

This commit is contained in:
Ying Wang 2016-02-26 22:58:12 +00:00 committed by Android (Google) Code Review
commit 6dece90534
9 changed files with 90 additions and 77 deletions

View File

@ -3,8 +3,11 @@
# Input variables: # Input variables:
# full_android_manifest, # full_android_manifest,
# my_res_resources, my_overlay_resources, my_aapt_characteristics, # my_res_resources, my_overlay_resources, my_aapt_characteristics,
# my_compiled_res_base_dir, rs_generated_res_dir, my_res_package, # my_compiled_res_base_dir, my_res_package,
# R_file_stamp, proguard_options_file # 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.
#
# Output variables: # Output variables:
# my_res_resources_flat, my_overlay_resources_flat, # my_res_resources_flat, my_overlay_resources_flat,
# my_generated_resources_flata # my_generated_resources_flata
@ -27,39 +30,45 @@ my_overlay_resources_flat := \
my_generated_resources_flata := my_generated_resources_flata :=
# Compile generated resources # Compile generated resources
ifneq ($(rs_generated_res_dir),) ifneq ($(my_generated_res_dirs),)
rs_gen_resource_flata := $(my_compiled_res_base_dir)/renderscript_gen_res.flata my_generated_resources_flata := $(my_compiled_res_base_dir)/gen_res.flata
$(rs_gen_resource_flata): PRIVATE_SOURCE_RES_DIR := $(rs_generated_res_dir) $(my_generated_resources_flata): PRIVATE_SOURCE_RES_DIRS := $(my_generated_res_dirs)
$(rs_gen_resource_flata) : $(RenderScript_file_stamp) $(my_generated_resources_flata) : $(my_generated_res_dirs_deps)
@echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIR)" @echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIRS)"
$(call aapt2-compile-one-resource-dir) $(call aapt2-compile-resource-dirs)
my_generated_resources_flata += $(rs_gen_resource_flata) my_generated_resources_flata += $(my_generated_resources_flata)
endif endif
$(my_res_resources_flat) $(my_overlay_resources_flat) $(my_generated_resources_flata): \ $(my_res_resources_flat) $(my_overlay_resources_flat) $(my_generated_resources_flata): \
PRIVATE_AAPT2_CFLAGS := $(addprefix --product ,$(my_aapt_characteristics)) $(PRODUCT_AAPT2_CFLAGS) PRIVATE_AAPT2_CFLAGS := $(addprefix --product ,$(my_aapt_characteristics)) $(PRODUCT_AAPT2_CFLAGS)
# Link the static library resource packages. my_static_library_resources := $(foreach l, $(LOCAL_STATIC_ANDROID_LIBRARIES),\
my_static_library_resources := $(foreach l, $(LOCAL_STATIC_JAVA_LIBRARIES),\ $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/library-res.flata) my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
$(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_overlay_resources_flat) $(my_generated_resources_flata) $(my_static_library_resources) $(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_overlay_resources_flat) $(my_generated_resources_flata) $(my_static_library_resources)
$(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_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
$(my_res_package) : $(full_android_manifest) $(my_res_package) : $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
$(my_res_package) : $(my_res_resources_flat) $(my_overlay_resources_flat) \ $(my_res_package) : $(my_res_resources_flat) $(my_overlay_resources_flat) \
$(my_generated_resources_flata) $(my_static_library_resources) \ $(my_generated_resources_flata) $(my_static_library_resources) \
$(AAPT2) $(AAPT2)
@echo "AAPT2 link $@" @echo "AAPT2 link $@"
$(call aapt2-link) $(call aapt2-link)
ifdef R_file_stamp
$(R_file_stamp) : $(my_res_package) | $(ACP) $(R_file_stamp) : $(my_res_package) | $(ACP)
@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
@rm -rf $@ && mkdir -p $(dir $@) @rm -rf $@ && mkdir -p $(dir $@)
$(call find-generated-R.java) $(call find-generated-R.java)
endif
ifdef proguard_options_file
$(proguard_options_file) : $(my_res_package) $(proguard_options_file) : $(my_res_package)
endif
resource_export_package := resource_export_package :=
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES ifdef LOCAL_EXPORT_PACKAGE_RESOURCES

View File

@ -22,11 +22,11 @@ my_full_libs_manifest_deps += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),
my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml) $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml)
# With USE_AAPT2, we'll link in the built resource from the AAR. # With aapt2, we'll link in the built resource from the AAR.
ifndef USE_AAPT2 ifndef LOCAL_USE_AAPT2
LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res) $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res)
endif # USE_AAPT2 endif # LOCAL_USE_AAPT2
endif # LOCAL_STATIC_JAVA_AAR_LIBRARIES endif # LOCAL_STATIC_JAVA_AAR_LIBRARIES
# Set up rules to merge library manifest files # Set up rules to merge library manifest files

View File

@ -193,6 +193,9 @@ LOCAL_INIT_RC:=
LOCAL_MODULE_HOST_OS:= LOCAL_MODULE_HOST_OS:=
LOCAL_FINDBUGS_FLAGS:= LOCAL_FINDBUGS_FLAGS:=
LOCAL_NOTICE_FILE:= LOCAL_NOTICE_FILE:=
LOCAL_USE_AAPT2:=$(USE_AAPT2)
LOCAL_STATIC_ANDROID_LIBRARIES:=
LOCAL_SHARED_ANDROID_LIBRARIES:=
# arch specific variables # arch specific variables
LOCAL_SRC_FILES_$(TARGET_ARCH):= LOCAL_SRC_FILES_$(TARGET_ARCH):=

View File

@ -1825,9 +1825,9 @@ define aapt2-compile-one-resource-file
$(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) --legacy $< $(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) --legacy $<
endef endef
define aapt2-compile-one-resource-dir define aapt2-compile-resource-dirs
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(hide) $(AAPT2) compile -o $@ --dir $(PRIVATE_SOURCE_RES_DIR) \ $(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \
$(PRIVATE_AAPT2_CFLAGS) --legacy $(PRIVATE_AAPT2_CFLAGS) --legacy
endef endef
@ -1856,8 +1856,10 @@ endef
define aapt2-link define aapt2-link
$(hide) $(AAPT2) link -o $@ \ $(hide) $(AAPT2) link -o $@ \
$(PRIVATE_AAPT_FLAGS) \ $(PRIVATE_AAPT_FLAGS) \
--auto-add-overlay \
$(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \ $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
$(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \ $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
$(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
$(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ $(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
$(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \ $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
$(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \

View File

@ -57,10 +57,12 @@ else
endif endif
endif endif
# LOCAL_STATIC_JAVA_AAR_LIBRARIES are special LOCAL_STATIC_JAVA_LIBRARIES # LOCAL_STATIC_JAVA_AAR_LIBRARIES and LOCAL_STATIC_ANDROID_LIBRARIES are also LOCAL_STATIC_JAVA_LIBRARIES.
LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)) LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) \
$(LOCAL_STATIC_JAVA_AAR_LIBRARIES) \
LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES)) $(LOCAL_STATIC_ANDROID_LIBRARIES))
# LOCAL_SHARED_ANDROID_LIBRARIES are also LOCAL_JAVA_LIBRARIES.
LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES) $(LOCAL_SHARED_ANDROID_LIBRARIES))
LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM)) LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
ifeq ($(LOCAL_BUILT_MODULE_STEM),) ifeq ($(LOCAL_BUILT_MODULE_STEM),)

View File

@ -115,7 +115,7 @@ ifneq ($(all_assets),)
need_compile_asset := true need_compile_asset := true
endif endif
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
# In aapt2 the last takes precedence. # In aapt2 the last takes precedence.
my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR)) my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR))
my_res_resources := my_res_resources :=
@ -140,7 +140,7 @@ LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
# Always run aapt2 # Always run aapt2
need_compile_res := true need_compile_res := true
else # USE_AAPT2 else # LOCAL_USE_AAPT2
all_resources := $(strip \ all_resources := $(strip \
$(foreach dir, $(LOCAL_RESOURCE_DIR), \ $(foreach dir, $(LOCAL_RESOURCE_DIR), \
$(addprefix $(dir)/, \ $(addprefix $(dir)/, \
@ -150,7 +150,7 @@ all_resources := $(strip \
) \ ) \
)) ))
endif # USE_AAPT2 endif # LOCAL_USE_AAPT2
ifneq ($(all_resources),) ifneq ($(all_resources),)
need_compile_res := true need_compile_res := true
@ -312,11 +312,16 @@ $(built_dex_intermediate) : $(data_binding_stamp)
endif # LOCAL_DATA_BINDING endif # LOCAL_DATA_BINDING
ifeq ($(need_compile_res),true) ifeq ($(need_compile_res),true)
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
my_aapt_characteristics := $(TARGET_AAPT_CHARACTERISTICS) # my_aapt_characteristics := $(TARGET_AAPT_CHARACTERISTICS)
my_aapt_characteristics :=
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_deps := $(RenderScript_file_stamp)
# Add AAPT2 specific flags.
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --no-static-lib-packages
include $(BUILD_SYSTEM)/aapt2.mk include $(BUILD_SYSTEM)/aapt2.mk
else # USE_AAPT2 else # LOCAL_USE_AAPT2
# Since we don't know where the real R.java file is going to end up, # Since we don't know where the real R.java file is going to end up,
# we need to use another file to stand in its place. We'll just # we need to use another file to stand in its place. We'll just
@ -356,7 +361,7 @@ $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderS
$(add-assets-to-package) $(add-assets-to-package)
endif endif
endif # USE_AAPT2 endif # LOCAL_USE_AAPT2
# Other modules should depend on the BUILT module if # Other modules should depend on the BUILT module if
# they want to use this module's R.java file. # they want to use this module's R.java file.
@ -419,7 +424,7 @@ $(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_
$(LOCAL_INTERMEDIATE_TARGETS): \ $(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports) PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
$(my_res_package) : $(all_library_res_package_export_deps) $(my_res_package) : $(all_library_res_package_export_deps)
endif endif
endif # LOCAL_NO_STANDARD_LIBRARIES endif # LOCAL_NO_STANDARD_LIBRARIES
@ -491,14 +496,14 @@ endif
endif endif
$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) $(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries) $(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP) $(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP)
else else
$(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT) $(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT)
endif endif
@echo "target Package: $(PRIVATE_MODULE) ($@)" @echo "target Package: $(PRIVATE_MODULE) ($@)"
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
ifdef LOCAL_JACK_ENABLED ifdef LOCAL_JACK_ENABLED
$(call copy-file-to-new-target) $(call copy-file-to-new-target)
else else
@ -507,7 +512,7 @@ else
$(call merge-two-packages,$(PRIVATE_RES_PACKAGE) $(PRIVATE_SOURCE_ARCHIVE),$@), $(call merge-two-packages,$(PRIVATE_RES_PACKAGE) $(PRIVATE_SOURCE_ARCHIVE),$@),
$(call copy-file-to-new-target)) $(call copy-file-to-new-target))
endif endif
else # USE_AAPT2 else # LOCAL_USE_AAPT2
ifdef LOCAL_JACK_ENABLED ifdef LOCAL_JACK_ENABLED
$(create-empty-package) $(create-empty-package)
else else
@ -516,7 +521,7 @@ else
$(create-empty-package)) $(create-empty-package))
endif endif
$(add-assets-to-package) $(add-assets-to-package)
endif # USE_AAPT2 endif # LOCAL_USE_AAPT2
ifneq ($(jni_shared_libraries),) ifneq ($(jni_shared_libraries),)
$(add-jni-shared-libs-to-package) $(add-jni-shared-libs-to-package)
endif endif

View File

@ -321,26 +321,34 @@ $(common_javalib_jar) : $(common_classes_jar) | $(ACP)
$(call define-jar-to-toc-rule, $(common_classes_jar)) $(call define-jar-to-toc-rule, $(common_classes_jar))
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
my_library_resources := $(intermediates.COMMON)/library-res.flata
ifneq ($(my_src_aar),) ifneq ($(my_src_aar),)
# Compile the AAR resources to a .flata. my_res_package := $(intermediates.COMMON)/package-res.apk
$(my_library_resources): PRIVATE_SOURCE_RES_DIR := $(intermediates.COMMON)/aar/res
$(my_library_resources) : $(my_src_jar) # We needed only very few PRIVATE variables and aapt2.mk input variables. Reset the unnecessary ones.
@echo "AAPT2 compile AAR $@ <- $(PRIVATE_SOURCE_RES_DIR)" $(my_res_package): PRIVATE_AAPT2_CFLAGS :=
$(call aapt2-compile-one-resource-dir) $(my_res_package): PRIVATE_ANDROID_MANIFEST := $(intermediates.COMMON)/aar/AndroidManifest.xml
else # $(my_src_aar) $(my_res_package): PRIVATE_AAPT_INCLUDES :=
# Create an empty packag for prebuilt static Java library. $(my_res_package): PRIVATE_SOURCE_INTERMEDIATES_DIR :=
# TODO: support compiled resources inside a prebuilt static Java library. $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE :=
$(my_library_resources): PRIVATE_RES_DIR := $(intermediates.COMMON)/flat-res/res $(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
$(my_library_resources) : $(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
@echo "Create empty library resources $@"
@rm -rf $@ && mkdir -p $(dir $@) $(PRIVATE_RES_DIR) full_android_manifest :=
$(hide) cd $(dir $(PRIVATE_RES_DIR)) && zip -qrX $(abspath $@) $(notdir $(PRIVATE_RES_DIR)) my_res_resources :=
my_overlay_resources :=
my_aapt_characteristics :=
my_compiled_res_base_dir :=
R_file_stamp :=
proguard_options_file :=
my_generated_res_dirs := $(intermediates.COMMON)/aar/res
my_generated_res_dirs_deps := $(my_src_jar)
include $(BUILD_SYSTEM)/aapt2.mk
# Make sure my_res_package is created when you run mm/mmm.
$(built_module) : $(my_res_package)
endif # $(my_src_aar) endif # $(my_src_aar)
# Make sure my_library_resources is created when you run mm/mmm. endif # LOCAL_USE_AAPT2
$(built_module) : $(my_library_resources)
endif # USE_AAPT2
# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
$(built_module) : $(common_javalib_jar) $(built_module) : $(common_javalib_jar)
endif # LOCAL_IS_HOST_MODULE is not set endif # LOCAL_IS_HOST_MODULE is not set

View File

@ -302,11 +302,8 @@ PRODUCT_AAPT_FLAGS :=
PRODUCT_AAPT2_CFLAGS := PRODUCT_AAPT2_CFLAGS :=
ifneq ($(filter en_XA ar_XB,$(PRODUCT_LOCALES)),) ifneq ($(filter en_XA ar_XB,$(PRODUCT_LOCALES)),)
# Force generating resources for pseudo-locales. # Force generating resources for pseudo-locales.
ifdef USE_AAPT2 PRODUCT_AAPT2_CFLAGS += --pseudo-localize
PRODUCT_AAPT2_CFLAGS += --pseudo-localize PRODUCT_AAPT_FLAGS += --pseudo-localize
else
PRODUCT_AAPT_FLAGS += --pseudo-localize
endif
endif endif
PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND)) PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))

View File

@ -30,9 +30,6 @@ include $(BUILD_SYSTEM)/configure_local_jack.mk
intermediates.COMMON := $(call local-intermediates-dir,COMMON) intermediates.COMMON := $(call local-intermediates-dir,COMMON)
my_res_package := my_res_package :=
# A zip file that apps can link with aapt2
# We need my_library_resources as dependency even if a library doesn't have resource.
my_library_resources := $(intermediates.COMMON)/library-res.flata
# Hack to build static Java library with Android resource # Hack to build static Java library with Android resource
# See bug 5714516 # See bug 5714516
@ -80,7 +77,7 @@ endif # LOCAL_JACK_ENABLED
R_file_stamp := $(intermediates.COMMON)/src/R.stamp R_file_stamp := $(intermediates.COMMON)/src/R.stamp
LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
# For library we treat all the resource equal with no overlay. # For library we treat all the resource equal with no overlay.
my_res_resources := $(all_resources) my_res_resources := $(all_resources)
my_overlay_resources := my_overlay_resources :=
@ -88,7 +85,7 @@ my_overlay_resources :=
my_res_package := $(intermediates.COMMON)/package-res.apk my_res_package := $(intermediates.COMMON)/package-res.apk
LOCAL_INTERMEDIATE_TARGETS += $(my_res_package) LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
endif # USE_AAPT2 endif # LOCAL_USE_AAPT2
endif # LOCAL_RESOURCE_DIR endif # LOCAL_RESOURCE_DIR
all_res_assets := $(all_resources) all_res_assets := $(all_resources)
@ -121,8 +118,8 @@ endif
# add --non-constant-id to prevent inlining constants. # add --non-constant-id to prevent inlining constants.
# AAR needs text symbol file R.txt. # AAR needs text symbol file R.txt.
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-final-ids $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --no-static-lib-packages
else else
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(LOCAL_INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(LOCAL_INTERMEDIATE_SOURCE_DIR)
endif endif
@ -141,11 +138,13 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_optio
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME :=
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR :=
ifdef USE_AAPT2 ifdef LOCAL_USE_AAPT2
# For libraries don't use any product specific flags. # For libraries don't use any product specific flags.
my_aapt_characteristics := my_aapt_characteristics :=
# One more level with name res so we can zip up the flat resources that can be linked by apps. # One more level with name res so we can zip up the flat resources that can be linked by apps.
my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res
my_generated_res_dirs := $(rs_generated_res_dir)
my_generated_res_dirs_deps := $(RenderScript_file_stamp)
include $(BUILD_SYSTEM)/aapt2.mk include $(BUILD_SYSTEM)/aapt2.mk
$(my_res_package) : $(framework_res_package_export_deps) $(my_res_package) : $(framework_res_package_export_deps)
else else
@ -153,7 +152,7 @@ $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_
@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
$(create-resource-java-files) $(create-resource-java-files)
$(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@
endif # USE_AAPT2 endif # LOCAL_USE_AAPT2
$(LOCAL_BUILT_MODULE): $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(R_file_stamp)
ifdef LOCAL_JACK_ENABLED ifdef LOCAL_JACK_ENABLED
@ -184,18 +183,6 @@ $(built_aar) : $(LOCAL_BUILT_MODULE)
ALL_MODULES.$(LOCAL_MODULE).AAR := $(built_aar) ALL_MODULES.$(LOCAL_MODULE).AAR := $(built_aar)
endif # need_compile_res endif # need_compile_res
ifdef USE_AAPT2
# If a static Java library has no resources, create empty package apps can depend on.
$(my_library_resources): PRIVATE_RES_DIR := $(intermediates.COMMON)/flat-res/res
$(my_library_resources) : $(my_res_package)
@echo "Package static library resources $@"
@rm -rf $@ && mkdir -p $(dir $@) $(PRIVATE_RES_DIR)
$(hide) cd $(dir $(PRIVATE_RES_DIR)) && zip -qrX $(abspath $@) $(notdir $(PRIVATE_RES_DIR))
# Make sure my_library_resources is created when you run mm/mmm.
$(LOCAL_BUILT_MODULE) : $(my_library_resources)
endif # USE_AAPT2
# Reset internal variables. # Reset internal variables.
all_res_assets := all_res_assets :=
LOCAL_IS_STATIC_JAVA_LIBRARY := LOCAL_IS_STATIC_JAVA_LIBRARY :=