SdkTestCore for non-updatable modules
Provides SdkTestCore/test_core_current sdk_version for non-updatable modules that have their test scope dependent on test apis from framework-minus-apex. Ignore-AOSP-First: Change in topic with internal-first projects Bug: 289776578 Test: m checkapi | go test ./java Merged-In: Iba3213e8c34ea75ac9dd8532a95ef62fb5455e6c Change-Id: Iba3213e8c34ea75ac9dd8532a95ef62fb5455e6c
This commit is contained in:
committed by
Anton Hansson
parent
c70be4b986
commit
9421c4ceb9
@@ -48,6 +48,7 @@ const (
|
|||||||
SdkPublic
|
SdkPublic
|
||||||
SdkSystem
|
SdkSystem
|
||||||
SdkTest
|
SdkTest
|
||||||
|
SdkTestFrameworksCore
|
||||||
SdkModule
|
SdkModule
|
||||||
SdkSystemServer
|
SdkSystemServer
|
||||||
SdkPrivate
|
SdkPrivate
|
||||||
@@ -67,6 +68,8 @@ func (k SdkKind) String() string {
|
|||||||
return "system"
|
return "system"
|
||||||
case SdkTest:
|
case SdkTest:
|
||||||
return "test"
|
return "test"
|
||||||
|
case SdkTestFrameworksCore:
|
||||||
|
return "test_frameworks_core"
|
||||||
case SdkCore:
|
case SdkCore:
|
||||||
return "core"
|
return "core"
|
||||||
case SdkCorePlatform:
|
case SdkCorePlatform:
|
||||||
@@ -92,6 +95,8 @@ func (k SdkKind) DefaultJavaLibraryName() string {
|
|||||||
return "android_system_stubs_current"
|
return "android_system_stubs_current"
|
||||||
case SdkTest:
|
case SdkTest:
|
||||||
return "android_test_stubs_current"
|
return "android_test_stubs_current"
|
||||||
|
case SdkTestFrameworksCore:
|
||||||
|
return "android_test_frameworks_core_stubs_current"
|
||||||
case SdkCore:
|
case SdkCore:
|
||||||
return "core.current.stubs"
|
return "core.current.stubs"
|
||||||
case SdkModule:
|
case SdkModule:
|
||||||
@@ -137,7 +142,7 @@ func (s SdkSpec) Stable() bool {
|
|||||||
return true
|
return true
|
||||||
case SdkCore, SdkPublic, SdkSystem, SdkModule, SdkSystemServer:
|
case SdkCore, SdkPublic, SdkSystem, SdkModule, SdkSystemServer:
|
||||||
return true
|
return true
|
||||||
case SdkCorePlatform, SdkTest, SdkPrivate:
|
case SdkCorePlatform, SdkTest, SdkTestFrameworksCore, SdkPrivate:
|
||||||
return false
|
return false
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unknown SdkKind=%v", s.Kind))
|
panic(fmt.Errorf("unknown SdkKind=%v", s.Kind))
|
||||||
@@ -185,7 +190,8 @@ func (s SdkSpec) UsePrebuilt(ctx EarlyModuleContext) bool {
|
|||||||
return ctx.Config().AlwaysUsePrebuiltSdks()
|
return ctx.Config().AlwaysUsePrebuiltSdks()
|
||||||
} else if !s.ApiLevel.IsPreview() {
|
} else if !s.ApiLevel.IsPreview() {
|
||||||
// validation check
|
// validation check
|
||||||
if s.Kind != SdkPublic && s.Kind != SdkSystem && s.Kind != SdkTest && s.Kind != SdkModule && s.Kind != SdkSystemServer {
|
if s.Kind != SdkPublic && s.Kind != SdkSystem && s.Kind != SdkTest &&
|
||||||
|
s.Kind != SdkTestFrameworksCore && s.Kind != SdkModule && s.Kind != SdkSystemServer {
|
||||||
panic(fmt.Errorf("prebuilt SDK is not not available for SdkKind=%q", s.Kind))
|
panic(fmt.Errorf("prebuilt SDK is not not available for SdkKind=%q", s.Kind))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -266,6 +272,8 @@ func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
|
|||||||
kind = SdkSystem
|
kind = SdkSystem
|
||||||
case "test":
|
case "test":
|
||||||
kind = SdkTest
|
kind = SdkTest
|
||||||
|
case "test_frameworks_core":
|
||||||
|
kind = SdkTestFrameworksCore
|
||||||
case "module":
|
case "module":
|
||||||
kind = SdkModule
|
kind = SdkModule
|
||||||
case "system_server":
|
case "system_server":
|
||||||
|
@@ -76,7 +76,8 @@ func systemModuleKind(sdkKind android.SdkKind, apiLevel android.ApiLevel) androi
|
|||||||
// Core is by definition what is included in the system module for the public API so should
|
// Core is by definition what is included in the system module for the public API so should
|
||||||
// just use its system modules.
|
// just use its system modules.
|
||||||
systemModuleKind = android.SdkPublic
|
systemModuleKind = android.SdkPublic
|
||||||
} else if systemModuleKind == android.SdkSystem || systemModuleKind == android.SdkTest {
|
} else if systemModuleKind == android.SdkSystem || systemModuleKind == android.SdkTest ||
|
||||||
|
systemModuleKind == android.SdkTestFrameworksCore {
|
||||||
// The core system and test APIs are currently the same as the public API so they should use
|
// The core system and test APIs are currently the same as the public API so they should use
|
||||||
// its system modules.
|
// its system modules.
|
||||||
systemModuleKind = android.SdkPublic
|
systemModuleKind = android.SdkPublic
|
||||||
@@ -192,7 +193,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
|||||||
bootclasspath: corePlatformBootclasspathLibraries(ctx),
|
bootclasspath: corePlatformBootclasspathLibraries(ctx),
|
||||||
noFrameworksLibs: true,
|
noFrameworksLibs: true,
|
||||||
}
|
}
|
||||||
case android.SdkPublic, android.SdkSystem, android.SdkTest:
|
case android.SdkPublic, android.SdkSystem, android.SdkTest, android.SdkTestFrameworksCore:
|
||||||
return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
|
return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
|
||||||
case android.SdkCore:
|
case android.SdkCore:
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
|
@@ -470,6 +470,9 @@ type ApiScopeProperties struct {
|
|||||||
// or the API file. They both have to use the same sdk_version as is used for
|
// or the API file. They both have to use the same sdk_version as is used for
|
||||||
// compiling the implementation library.
|
// compiling the implementation library.
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
|
||||||
|
// Extra libs used when compiling stubs for this scope.
|
||||||
|
Libs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type sdkLibraryProperties struct {
|
type sdkLibraryProperties struct {
|
||||||
@@ -1653,6 +1656,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
|
|||||||
props.Patch_module = module.properties.Patch_module
|
props.Patch_module = module.properties.Patch_module
|
||||||
props.Installable = proptools.BoolPtr(false)
|
props.Installable = proptools.BoolPtr(false)
|
||||||
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
||||||
|
props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
|
||||||
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
||||||
// The stub-annotations library contains special versions of the annotations
|
// The stub-annotations library contains special versions of the annotations
|
||||||
// with CLASS retention policy, so that they're kept.
|
// with CLASS retention policy, so that they're kept.
|
||||||
@@ -1725,6 +1729,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
|||||||
props.Libs = module.properties.Libs
|
props.Libs = module.properties.Libs
|
||||||
props.Libs = append(props.Libs, module.properties.Static_libs...)
|
props.Libs = append(props.Libs, module.properties.Static_libs...)
|
||||||
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
||||||
|
props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
|
||||||
props.Aidl.Include_dirs = module.deviceProperties.Aidl.Include_dirs
|
props.Aidl.Include_dirs = module.deviceProperties.Aidl.Include_dirs
|
||||||
props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs
|
props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs
|
||||||
props.Java_version = module.properties.Java_version
|
props.Java_version = module.properties.Java_version
|
||||||
@@ -1864,6 +1869,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
|
|||||||
props.Api_contributions = apiContributions
|
props.Api_contributions = apiContributions
|
||||||
props.Libs = module.properties.Libs
|
props.Libs = module.properties.Libs
|
||||||
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
||||||
|
props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
|
||||||
props.Libs = append(props.Libs, "stub-annotations")
|
props.Libs = append(props.Libs, "stub-annotations")
|
||||||
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
||||||
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
|
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
|
||||||
|
@@ -1421,6 +1421,32 @@ func TestJavaSdkLibrary_StubOnlyLibs_PassedToDroidstubs(t *testing.T) {
|
|||||||
android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
|
android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaSdkLibrary_Scope_Libs_PassedToDroidstubs(t *testing.T) {
|
||||||
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForJavaTest,
|
||||||
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
|
FixtureWithLastReleaseApis("foo"),
|
||||||
|
).RunTestWithBp(t, `
|
||||||
|
java_sdk_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
public: {
|
||||||
|
enabled: true,
|
||||||
|
libs: ["bar-lib"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "bar-lib",
|
||||||
|
srcs: ["b.java"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
// The foo.stubs.source should depend on bar-lib
|
||||||
|
fooStubsSources := result.ModuleForTests("foo.stubs.source", "android_common").Module().(*Droidstubs)
|
||||||
|
android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
|
||||||
|
}
|
||||||
|
|
||||||
func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
|
func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
|
Reference in New Issue
Block a user