From 18f28c7781dae089b772e61948a54d27dac9270f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Sat, 22 Jun 2019 13:03:09 -0700 Subject: [PATCH] Allow passing --legacy in LOCAL_AAPT_FLAGS --legacy will soon no longer be passed by default to all aapt2 compiles. Allow it to be specified in LOCAL_AAPT_FLAGS by passing it to aapt2 compile when it is present and filtering it out from the flags passed to aapt2 link. Bug: 135597368 Test: m java Change-Id: I92792cf6a0d4c6ecf5e0971523bd0ab76c81345f --- core/aapt2.mk | 4 ++-- core/package_internal.mk | 11 +---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/core/aapt2.mk b/core/aapt2.mk index fbbf3dd58..7b17df4a9 100644 --- a/core/aapt2.mk +++ b/core/aapt2.mk @@ -61,8 +61,8 @@ endif # Always set --pseudo-localize, it will be stripped out later for release # builds that don't want it. -$(my_res_resources_flat) $(my_overlay_resources_flat) $(my_resources_flata): \ - PRIVATE_AAPT2_CFLAGS := --pseudo-localize +$(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)) # TODO(b/78447299): Forbid LOCAL_STATIC_JAVA_AAR_LIBRARIES in aapt2 and remove # support for it. diff --git a/core/package_internal.mk b/core/package_internal.mk index d693c585b..c41429565 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -328,7 +328,7 @@ my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs)) built_apk_splits := $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk) endif -$(R_file_stamp) $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) +$(R_file_stamp) $(my_res_package): PRIVATE_AAPT_FLAGS := $(filter-out --legacy,$(LOCAL_AAPT_FLAGS)) $(R_file_stamp) $(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) $(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) $(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) @@ -346,7 +346,6 @@ my_asset_dirs := $(LOCAL_ASSET_DIR) my_full_asset_paths := $(all_assets) # Add AAPT2 link specific flags. -$(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) ifndef LOCAL_AAPT_NAMESPACES $(my_res_package): PRIVATE_AAPT_FLAGS += --no-static-lib-packages endif @@ -416,14 +415,6 @@ $(LOCAL_INTERMEDIATE_TARGETS): \ $(my_res_package) : $(all_library_res_package_export_deps) -# These four are set above for $(R_stamp_file) and $(my_res_package), but -# $(LOCAL_BUILT_MODULE) is not set before java.mk, so they have to be set again -# here. -$(LOCAL_BUILT_MODULE): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -$(LOCAL_BUILT_MODULE): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) -$(LOCAL_BUILT_MODULE): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) -$(LOCAL_BUILT_MODULE): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) - ifneq ($(full_classes_jar),) $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) # Use the jarjar processed arhive as the initial package file.