From f5cefdcefb0e1472ac2cf38387e95d7c4ff30443 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Thu, 12 Apr 2018 16:17:55 +0100 Subject: [PATCH] Add support for specifying LOCAL_SDK_LIBRARIES for prebuilts. This new variable allows specifying libraries like this: LOCAL_SDK_VERISON := 25 LOCAL_SDK_LIBRARIES := org.apache.http.legacy, which would automatically pick up the prebuilt OAHL prebuilt from prebuilts/sdk/25/public/org.apache.http.legacy.jar Test: In master with uiautomator. Bug: 77575476 Change-Id: Id8d92176f5b608c2bcea622b6aed4aa27c32e000 --- core/clear_vars.mk | 1 + core/config.mk | 5 +++-- core/java_common.mk | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 62549d97e6..346bcf9c60 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -229,6 +229,7 @@ LOCAL_SANITIZE:= LOCAL_SANITIZE_DIAG:= LOCAL_SANITIZE_RECOVER:= LOCAL_SANITIZE_BLACKLIST := +LOCAL_SDK_LIBRARIES := LOCAL_SDK_RES_VERSION:= LOCAL_SDK_VERSION:= LOCAL_SHARED_ANDROID_LIBRARIES:= diff --git a/core/config.mk b/core/config.mk index c432c37a7e..2a1a7d0c9a 100644 --- a/core/config.mk +++ b/core/config.mk @@ -963,10 +963,11 @@ endif # 23 -> sdk_public_23_android # system_current -> sdk_system_current_android # $(1): An sdk version (LOCAL_SDK_VERSION) +# $(2): optional library name (default: android) define resolve-prebuilt-sdk-module $(if $(findstring _,$(1)),\ - sdk_$(1)_android,\ - sdk_public_$(1)_android) + sdk_$(1)_$(or $(2),android),\ + sdk_public_$(1)_$(or $(2),android)) endef # Resolve LOCAL_SDK_VERSION to prebuilt framework.aidl diff --git a/core/java_common.mk b/core/java_common.mk index a65b6efc10..0de8e92489 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -230,6 +230,7 @@ empty_bootclasspath := my_system_modules := ifndef LOCAL_IS_HOST_MODULE + sdk_libs := ifeq ($(LOCAL_SDK_VERSION),) ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) # No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath. @@ -261,9 +262,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 - # TARGET_BUILD_APPS is set. Use the modules defined in prebuilts/sdk/Android.mk. + # TARGET_BUILD_APPS or numbered SDK. 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)) + sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION),$(lib_name))) _module_name := endif # current, system_current, system_${VER}, test_current or core_current endif # LOCAL_SDK_VERSION @@ -291,10 +293,9 @@ ifndef LOCAL_IS_HOST_MODULE full_java_bootclasspath_libs += $(call java-lib-header-files,core-lambda-stubs) endif endif - - full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) - full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) - + full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(sdk_libs),$(LOCAL_IS_HOST_MODULE)) + full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES) $(sdk_libs),$(LOCAL_IS_HOST_MODULE)) + sdk_libs := else # LOCAL_IS_HOST_MODULE ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)