Merge "sdk_version: "module_current" is supported" am: c4930248c4 am: e04b901737 am: 5ca166b2a9

Change-Id: I8dcd37faa79f265ea144798c1753c62485707f79
This commit is contained in:
Automerger Merge Worker 2020-02-06 04:40:23 +00:00
commit 37c98748ea
4 changed files with 32 additions and 1 deletions

View file

@ -757,9 +757,12 @@ func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer
type linkType int type linkType int
const ( const (
// TODO(jiyong) rename these for better readability. Make the allowed
// and disallowed link types explicit
javaCore linkType = iota javaCore linkType = iota
javaSdk javaSdk
javaSystem javaSystem
javaModule
javaPlatform javaPlatform
) )
@ -789,6 +792,10 @@ func (m *Module) getLinkType(name string) (ret linkType, stubs bool) {
return javaSdk, true return javaSdk, true
case ver.kind == sdkPublic: case ver.kind == sdkPublic:
return javaSdk, false return javaSdk, false
case name == "android_module_lib_stubs_current":
return javaModule, true
case ver.kind == sdkModule:
return javaModule, false
case ver.kind == sdkPrivate || ver.kind == sdkNone || ver.kind == sdkCorePlatform: case ver.kind == sdkPrivate || ver.kind == sdkNone || ver.kind == sdkCorePlatform:
return javaPlatform, false return javaPlatform, false
case !ver.valid(): case !ver.valid():
@ -824,11 +831,17 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext,
} }
break break
case javaSystem: case javaSystem:
if otherLinkType == javaPlatform { if otherLinkType == javaPlatform || otherLinkType == javaModule {
ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage, ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage,
ctx.OtherModuleName(to)) ctx.OtherModuleName(to))
} }
break break
case javaModule:
if otherLinkType == javaPlatform {
ctx.ModuleErrorf("compiles against module API, but dependency %q is compiling against private API."+commonMessage,
ctx.OtherModuleName(to))
}
break
case javaPlatform: case javaPlatform:
// no restriction on link-type // no restriction on link-type
break break

View file

@ -71,6 +71,7 @@ const (
sdkPublic sdkPublic
sdkSystem sdkSystem
sdkTest sdkTest
sdkModule
sdkPrivate sdkPrivate
) )
@ -91,6 +92,8 @@ func (k sdkKind) String() string {
return "core" return "core"
case sdkCorePlatform: case sdkCorePlatform:
return "core_platform" return "core_platform"
case sdkModule:
return "module"
default: default:
return "invalid" return "invalid"
} }
@ -256,6 +259,8 @@ func sdkSpecFrom(str string) sdkSpec {
kind = sdkSystem kind = sdkSystem
case "test": case "test":
kind = sdkTest kind = sdkTest
case "module":
kind = sdkModule
default: default:
return sdkSpec{sdkInvalid, sdkVersionNone, str} return sdkSpec{sdkInvalid, sdkVersionNone, str}
} }
@ -382,6 +387,9 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
return toModule("android_test_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx)) return toModule("android_test_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
case sdkCore: case sdkCore:
return toModule("core.current.stubs", "", nil) return toModule("core.current.stubs", "", nil)
case sdkModule:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
return toModule("android_module_lib_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
default: default:
panic(fmt.Errorf("invalid sdk %q", sdkVersion.raw)) panic(fmt.Errorf("invalid sdk %q", sdkVersion.raw))
} }

View file

@ -211,6 +211,15 @@ func TestClasspath(t *testing.T) {
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/29/public/framework.aidl", aidl: "-pprebuilts/sdk/29/public/framework.aidl",
}, },
{
name: "module_current",
properties: `sdk_version: "module_current",`,
bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"},
system: "core-current-stubs-system-modules",
java9classpath: []string{"android_module_lib_stubs_current"},
aidl: "-p" + buildDir + "/framework.aidl",
},
} }
for _, testcase := range classpathTestcases { for _, testcase := range classpathTestcases {

View file

@ -146,6 +146,7 @@ func GatherRequiredDepsForTest() string {
"android_stubs_current", "android_stubs_current",
"android_system_stubs_current", "android_system_stubs_current",
"android_test_stubs_current", "android_test_stubs_current",
"android_module_lib_stubs_current",
"core.current.stubs", "core.current.stubs",
"core.platform.api.stubs", "core.platform.api.stubs",
"kotlin-stdlib", "kotlin-stdlib",