From bb6393c5a49bf05f0db25dd874c7c78d12cfcb1d Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 17 Nov 2017 15:39:52 -0800 Subject: [PATCH] Add LOCAL_AAPT2_ONLY This allows modules to specify that they may only be used from modules using aapt2. Using aapt2 removes absolute path references to modules, so this can be useful if a module is preparing to move its sources, or replace itself with a prebuilt aar. Test: m Test: Label frameworks/support/design; m Test: Label frameworks/support/v4; m Test: build/soong/build_test.bash Change-Id: Icfb3d4b19a6a0e3a3bb00091d2a97a4d88c0c761 --- core/clear_vars.mk | 1 + core/java_common.mk | 9 ++++++++- core/package_internal.mk | 4 ++++ core/prebuilt_internal.mk | 4 ++++ core/static_java_library.mk | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 1e64c4f3b..bd605ec1e 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -4,6 +4,7 @@ # '',true LOCAL_32_BIT_ONLY:= +LOCAL_AAPT2_ONLY:= LOCAL_AAPT_FLAGS:= LOCAL_AAPT_INCLUDE_ALL_RESOURCES:= LOCAL_ADDITIONAL_CERTIFICATES:= diff --git a/core/java_common.mk b/core/java_common.mk index 6ae1415c7..4dd0de65f 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -414,7 +414,14 @@ my_warn_types := my_allowed_types := java:sdk java:system java:platform endif -my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES)) +ifdef LOCAL_AAPT2_ONLY +my_link_type += aapt2_only +endif +ifdef LOCAL_USE_AAPT2 +my_allowed_types += aapt2_only +endif + +my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES)) my_link_deps += $(addprefix APPS:,$(apk_libraries)) my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) diff --git a/core/package_internal.mk b/core/package_internal.mk index 9bf173fbc..9f99c7af4 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -146,6 +146,10 @@ ifneq ($(all_assets),) need_compile_asset := true endif +ifdef LOCAL_AAPT2_ONLY +LOCAL_USE_AAPT2 := true +endif + my_res_package := ifdef LOCAL_USE_AAPT2 # In aapt2 the last takes precedence. diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 48e410bf6..3fec8d9b3 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -547,6 +547,10 @@ $(common_classes_pre_proguard_jar) : $(my_src_jar) $(common_javalib_jar) : $(common_classes_jar) $(transform-prebuilt-to-target) +ifdef LOCAL_AAPT2_ONLY +LOCAL_USE_AAPT2 := true +endif + ifdef LOCAL_USE_AAPT2 ifneq ($(my_src_aar),) LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 69cf95595..5ffb88db8 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -28,6 +28,10 @@ intermediates.COMMON := $(call local-intermediates-dir,COMMON) my_res_package := +ifdef LOCAL_AAPT2_ONLY +LOCAL_USE_AAPT2 := true +endif + # Hack to build static Java library with Android resource # See bug 5714516 all_resources :=