From 3c979c33487d7507d2a195291f3cd824ca824b90 Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Tue, 11 Sep 2018 09:29:31 +0100 Subject: [PATCH] Add a new sdk_version "core_platform_current" Add a new sdk_version "core_platform_current" value to java_library. This adds the ability to compile system code against the core platform API stubs. These stubs will contain the public SDK API _and_ a selection of extra methods just intended for use by system code (e.g. framework .jar) and which must be preserved if "core" is modularized to retain source and binary compatibility. Methods outside of the core platform API must not be relied upon. Future changes will adding methods to the core platform API and switch targets over to use the stubs. As soon as feasible, (hopefully) the default for when unspecified will be changed to be the same as specifying core_platform_current and build rules will have to explicitly specify when they want to compile against the core library implementation directly. Bug: 113148576 Test: mmm libcore/mmodules/core_platform_api_client_demo Change-Id: I72a03f28a4c38b4232e513a088c2d4e962c98868 --- java/java.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/java/java.go b/java/java.go index 0dd64ef99..b60f9c739 100644 --- a/java/java.go +++ b/java/java.go @@ -412,7 +412,7 @@ type sdkContext interface { func sdkVersionOrDefault(ctx android.BaseContext, v string) string { switch v { - case "", "current", "system_current", "test_current", "core_current": + case "", "current", "system_current", "test_current", "core_current", "core_platform_current": return ctx.Config().DefaultAppTargetSdk() default: return v @@ -423,7 +423,7 @@ func sdkVersionOrDefault(ctx android.BaseContext, v string) string { // it returns android.FutureApiLevel (10000). func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) { switch v { - case "", "current", "test_current", "system_current", "core_current": + case "", "current", "test_current", "system_current", "core_current", "core_platform_current": return ctx.Config().DefaultAppTargetSdkInt(), nil default: n := android.GetNumericSdkVersion(v) @@ -520,6 +520,8 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { } if m == "core.current.stubs" { ret.systemModules = "core-system-modules" + } else if m == "core.platform.api.stubs" { + ret.systemModules = "core-platform-api-stubs-system-modules" } return ret } @@ -542,6 +544,8 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep { return toModule("android_test_stubs_current", "framework-res") case "core_current": return toModule("core.current.stubs", "") + case "core_platform_current": + return toModule("core.platform.api.stubs", "") default: return toPrebuilt(v) } @@ -704,8 +708,9 @@ func getLinkType(m *Module, name string) linkType { ver := m.sdkVersion() noStdLibs := Bool(m.properties.No_standard_libs) switch { - case name == "core.current.stubs" || ver == "core_current" || noStdLibs || name == "stub-annotations" || - name == "private-stub-annotations-jar": + case name == "core.current.stubs" || ver == "core_current" || + name == "core.platform.api.stubs" || ver == "core_platform_current" || + noStdLibs || name == "stub-annotations" || name == "private-stub-annotations-jar": return javaCore case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_"): return javaSystem