From 400673cf1e1efb9f7f9a83d499a32546a6e1dcc9 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Tue, 10 Apr 2018 16:16:33 +0100 Subject: [PATCH] Consolidate the logic for the sdk prebuilt module names. I'm making some changes to it, and found the names are scattered in various places. Make a macro and re-use the logic instead. Bug: 77525052 Test: make droid Change-Id: I0f2da80b8b4d427353509b27ec720d024eee7a6e --- core/config.mk | 9 +++++++++ core/droiddoc.mk | 11 +++++------ core/java.mk | 4 ++-- core/java_common.mk | 9 ++++----- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/core/config.mk b/core/config.mk index b3f3d3662..0029792e6 100644 --- a/core/config.mk +++ b/core/config.mk @@ -956,6 +956,15 @@ else SUPPORT_LIBRARY_ROOT := frameworks/support endif +# Resolve LOCAL_SDK_VERSION to prebuilt module name, e.g.: +# 23 -> sdk_v23 +# system_current -> sdk_vsystem_current +# Note: this also replaces core_X with X (to be removed as there are prebuilts for core now). +# $(1): An sdk version (LOCAL_SDK_VERSION) +define resolve-prebuilt-sdk-module + sdk_v$(patsubst core_%,%,$(1)) +endef + # Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N. # The 'current' version is whatever this source tree is. # diff --git a/core/droiddoc.mk b/core/droiddoc.mk index 77f1a5064..cd48316a6 100644 --- a/core/droiddoc.mk +++ b/core/droiddoc.mk @@ -75,12 +75,11 @@ ifneq ($(LOCAL_SDK_VERSION),) LOCAL_JAVA_LIBRARIES := core.current.stubs $(LOCAL_JAVA_LIBRARIES) $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core.current.stubs) else - # core_ is subset of . Instead of defining a prebuilt lib for core_, - # use the stub for when building for apps. - _version := $(patsubst core_%,%,$(LOCAL_SDK_VERSION)) - LOCAL_JAVA_LIBRARIES := sdk_v$(_version) $(LOCAL_JAVA_LIBRARIES) - $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(_version)) - _version := + # TARGET_BUILD_APPS is set. Use the modules defined in prebuilts/sdk/Android.mk. + _module_name := $(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION)) + LOCAL_JAVA_LIBRARIES := $(_module_name) $(LOCAL_JAVA_LIBRARIES) + $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, $(_module_name)) + _module_name := endif else ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) diff --git a/core/java.mk b/core/java.mk index 9823c133b..dab531479 100644 --- a/core/java.mk +++ b/core/java.mk @@ -406,7 +406,7 @@ endif proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary # When an app contains references to APIs that are not in the SDK specified by -# its LOCAL_SDK_VERSION for example added by support library or by runtime +# its LOCAL_SDK_VERSION for example added by support library or by runtime # classes added by desugar, we artifically raise the "SDK version" "linked" by # ProGuard, to # - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version. @@ -416,7 +416,7 @@ my_proguard_sdk_raise := ifdef LOCAL_SDK_VERSION ifdef TARGET_BUILD_APPS ifeq (,$(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION))) - my_proguard_sdk_raise := $(call java-lib-header-files, sdk_vcurrent) + my_proguard_sdk_raise := $(call java-lib-header-files, $(call resolve-prebuilt-sdk-module,current)) endif else # For platform build, we can't just raise to the "current" SDK, diff --git a/core/java_common.mk b/core/java_common.mk index 44ee4b234..a65b6efc1 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -261,11 +261,10 @@ ifndef LOCAL_IS_HOST_MODULE else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),core_current) full_java_bootclasspath_libs := $(call java-lib-header-files,core.current.stubs) else - # core_ is subset of . Instead of defining a prebuilt lib for core_, - # use the stub for when building for apps. - _version := $(patsubst core_%,%,$(LOCAL_SDK_VERSION)) - full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(_version)) - _version := + # TARGET_BUILD_APPS is set. Use the modules defined in prebuilts/sdk/Android.mk. + _module_name := $(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION)) + full_java_bootclasspath_libs := $(call java-lib-header-files,$(_module_name)) + _module_name := endif # current, system_current, system_${VER}, test_current or core_current endif # LOCAL_SDK_VERSION