From 53f6b2a80b3dfe66fa149e1f06bd07f12afa62d3 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 21 Feb 2018 11:44:57 -0500 Subject: [PATCH] Move Support Library dependencies to their own var with resolution Bug: 73250914 Test: make checkbuild Change-Id: Ibdbe2fd140133202b266ca4f233c4d42292fa3df --- core/clear_vars.mk | 1 + core/package_internal.mk | 3 +++ core/static_java_library.mk | 3 +++ core/support_libraries.mk | 54 +++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 core/support_libraries.mk diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 460a090ee3..270a1408c6 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -59,6 +59,7 @@ LOCAL_DEX_PREOPT_IMAGE_LOCATION:= LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING:= LOCAL_DEX_PREOPT:= # '',true,false,nostripping LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG:= +LOCAL_DISABLE_RESOLVE_SUPPORT_LIBRARIES:= LOCAL_DONT_CHECK_MODULE:= # Don't delete the META_INF dir when merging static Java libraries. LOCAL_DONT_DELETE_JAR_META_INF:= diff --git a/core/package_internal.mk b/core/package_internal.mk index 794e65f712..e25fd99c38 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -314,6 +314,9 @@ LOCAL_RESOURCE_DIR := $(data_binding_res_out) LOCAL_AAPT_FLAGS += --auto-add-overlay --extra-packages com.android.databinding.library endif # LOCAL_DATA_BINDING +# Process Support Library dependencies. +include $(BUILD_SYSTEM)/support_libraries.mk + # If the module is a compressed module, we don't pre-opt it because its final # installation location will be the data partition. ifdef LOCAL_COMPRESSED_MODULE diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 4d06193862..b8f508bd77 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -32,6 +32,9 @@ ifdef LOCAL_AAPT2_ONLY LOCAL_USE_AAPT2 := true endif +# Process Support Library dependencies. +include $(BUILD_SYSTEM)/support_libraries.mk + # Hack to build static Java library with Android resource # See bug 5714516 all_resources := diff --git a/core/support_libraries.mk b/core/support_libraries.mk new file mode 100644 index 0000000000..e204cc4156 --- /dev/null +++ b/core/support_libraries.mk @@ -0,0 +1,54 @@ +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +########################################################### +## Rules for resolving Support Library dependencies. +## +## The following variables may be modified: +## - LOCAL_JAVA_LIBRARIES +## - LOCAL_STATIC_JAVA_LIBRARIES +## - LOCAL_SHARED_ANDROID_LIBRARIES +## - LOCAL_STATIC_ANDROID_LIBRARIES +########################################################### + +# Some projects don't work correctly yet. Allow them to skip resolution. +ifndef LOCAL_DISABLE_RESOLVE_SUPPORT_LIBRARIES + +# Clear these out so we don't accidentally get old values. +support_android_deps := +support_java_deps := + +# Delegate dependency expansion to the Support Library's rules. This will store +# its output in the variables support_android_deps and support_java_deps. +include $(RESOLVE_SUPPORT_LIBRARIES) + +# Store the expanded dependencies in the appropriate variables. Libraries +# should NEVER statically include Support Library modules with resources. +ifdef support_android_deps + ifdef LOCAL_IS_STATIC_JAVA_LIBRARY + LOCAL_SHARED_ANDROID_LIBRARIES += $(support_android_deps) + else + LOCAL_STATIC_ANDROID_LIBRARIES += $(support_android_deps) + endif # LOCAL_IS_STATIC_JAVA_LIBRARY +endif #support_android_deps +LOCAL_STATIC_JAVA_LIBRARIES += $(support_java_deps) + +# We have consumed these values. Clean them up. +support_android_deps := +support_java_deps := + +endif #LOCAL_DISABLE_RESOLVE_SUPPORT_LIBRARIES +LOCAL_DISABLE_RESOLVE_SUPPORT_LIBRARIES :=