From 8ae30017e9cc595592f09d7d16c0d8ad68784fcd Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Tue, 24 Apr 2018 14:22:51 +0100 Subject: [PATCH 1/3] Support LOCAL_SDK_LIBRARIES for "current" builds. Resolve these using the naming scheme from sdk_library.go, added in I4a4ccf6e730e041703c63bb275d8860d0de96887. Also re-write the LOCAL_SDK_VERSION logic, as it was becoming a real mess. Bug: 77575476 Test: With uiautomator in a follow-on CL Change-Id: I11bd10c02df3d458a4ed6de90114e27fabe8d9e0 --- core/java_common.mk | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/core/java_common.mk b/core/java_common.mk index 0de8e92489..9245e201f0 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -231,6 +231,7 @@ 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. @@ -252,22 +253,30 @@ ifndef LOCAL_IS_HOST_MODULE $(call pretty-error,Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \ Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS)) endif - ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) - # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. - full_java_bootclasspath_libs := $(call java-lib-header-files,android_stubs_current) - else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current) - full_java_bootclasspath_libs := $(call java-lib-header-files,android_system_stubs_current) - else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current) - full_java_bootclasspath_libs := $(call java-lib-header-files,android_test_stubs_current) - 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 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)) + + ifneq (,$(TARGET_BUILD_APPS)$(filter-out %current,$(LOCAL_SDK_VERSION))) + # TARGET_BUILD_APPS mode or numbered SDK. Use prebuilt modules. + sdk_module := $(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION)) 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 + else + # Note: the lib naming scheme must be kept in sync with build/soong/java/sdk_library.go. + sdk_lib_suffix = $(call pretty-error,sdk_lib_suffix was not set correctly) + ifeq (current,$(LOCAL_SDK_VERSION)) + sdk_module := android_stubs_current + sdk_lib_suffix := .stubs + else ifeq (system_current,$(LOCAL_SDK_VERSION)) + sdk_module := android_system_stubs_current + sdk_lib_suffix := .stubs.system + else ifeq (test_current,$(LOCAL_SDK_VERSION)) + sdk_module := android_test_stubs_current + sdk_lib_suffix = $(call pretty-error,LOCAL_SDK_LIBRARIES not supported for LOCAL_SDK_VERSION = test_current) + else ifeq (core_current,$(LOCAL_SDK_VERSION)) + sdk_module := core.current.stubs + sdk_lib_suffix = $(call pretty-error,LOCAL_SDK_LIBRARIES not supported for LOCAL_SDK_VERSION = core_current) + endif + sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(lib_name)$(sdk_lib_suffix)) + endif + full_java_bootclasspath_libs := $(call java-lib-header-files,$(sdk_module)) endif # LOCAL_SDK_VERSION ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) From 6023db8844b79ca27a9f780135a4f25242f78a0a Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 27 Apr 2018 16:23:38 +0900 Subject: [PATCH 2/3] java_sdk_library supports test as another API scope When a module built with LOCAL_SDK_VERSION := test_current, then it is linked against test variant of the sdk stubs library. Bug: 77575606 Test: m -j Change-Id: I08ce120d8e4774722a95bfc4e200ad7d123abc70 --- core/java_common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java_common.mk b/core/java_common.mk index 9245e201f0..99fa6d20fb 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -269,7 +269,7 @@ ifndef LOCAL_IS_HOST_MODULE sdk_lib_suffix := .stubs.system else ifeq (test_current,$(LOCAL_SDK_VERSION)) sdk_module := android_test_stubs_current - sdk_lib_suffix = $(call pretty-error,LOCAL_SDK_LIBRARIES not supported for LOCAL_SDK_VERSION = test_current) + sdk_lib_suffix := .stubs.test else ifeq (core_current,$(LOCAL_SDK_VERSION)) sdk_module := core.current.stubs sdk_lib_suffix = $(call pretty-error,LOCAL_SDK_LIBRARIES not supported for LOCAL_SDK_VERSION = core_current) From cd06fe34e0cc9972a0de4db993da309c9f6b1b2e Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 27 Apr 2018 16:21:00 +0900 Subject: [PATCH 3/3] sdk lib name can be in LOCAL_[STATIC_]JAVA_LIBRARIES When an sdk lib name (a module defined with java_sdk_library{...}) is listed in LOCAL_JAVA_LIBRARIES or LOCAL_STATIC_JAVA_LIBRARIES, the name is translated to the stubs lib name of the sdk lib. We have to support this at least until all existing references to sdk libs are all correctly converted to LOCAL_SDK_LIBRARIES. Bug: 77575606 Test: m -j Change-Id: I8cff668afd6b5f265cc7ae6fe6f5fa36b76b8334 --- core/java_common.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/java_common.mk b/core/java_common.mk index 99fa6d20fb..9fd6bfed53 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -232,6 +232,11 @@ my_system_modules := ifndef LOCAL_IS_HOST_MODULE sdk_libs := + # When an sdk lib name is listed in LOCAL_JAVA_LIBRARIES, move it to LOCAL_SDK_LIBRARIES, so that + # it is correctly redirected to the stubs library. + LOCAL_SDK_LIBRARIES += $(filter $(JAVA_SDK_LIBRARIES),$(LOCAL_JAVA_LIBRARIES)) + LOCAL_JAVA_LIBRARIES := $(filter-out $(JAVA_SDK_LIBRARIES),$(LOCAL_JAVA_LIBRARIES)) + ifeq ($(LOCAL_SDK_VERSION),) ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) # No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath. @@ -245,6 +250,9 @@ ifndef LOCAL_IS_HOST_MODULE LOCAL_JAVA_LIBRARIES := $(filter-out $(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES),$(LOCAL_JAVA_LIBRARIES)) my_system_modules := $(DEFAULT_SYSTEM_MODULES) endif # LOCAL_NO_STANDARD_LIBRARIES + # When SDK libraries are referenced from modules built without SDK, provide the system stub to them + # because it has the largest API surface. + sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(lib_name).stubs.system) else ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) $(call pretty-error,Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION)