summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Anton Hansson <hansson@google.com> 2023-10-24 10:06:54 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-10-24 10:06:54 +0000
commitaf1c929943dbdba7b1d9481daa207ba36ad4fd1c (patch)
treec642a288523cca6eccb454c4cebcd760531c5de6
parent7ec40649bbc5ebd4328b79c7f46fe69cc1d254c6 (diff)
parent9421c4ceb912ffb27df86d3a9cb0c8e5609e0384 (diff)
Merge "SdkTestCore for non-updatable modules" into main
-rw-r--r--android/sdk_version.go12
-rw-r--r--java/sdk.go5
-rw-r--r--java/sdk_library.go6
-rw-r--r--java/sdk_library_test.go26
4 files changed, 45 insertions, 4 deletions
diff --git a/android/sdk_version.go b/android/sdk_version.go
index 1fadda0ca..aafcee79a 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -48,6 +48,7 @@ const (
SdkPublic
SdkSystem
SdkTest
+ SdkTestFrameworksCore
SdkModule
SdkSystemServer
SdkPrivate
@@ -67,6 +68,8 @@ func (k SdkKind) String() string {
return "system"
case SdkTest:
return "test"
+ case SdkTestFrameworksCore:
+ return "test_frameworks_core"
case SdkCore:
return "core"
case SdkCorePlatform:
@@ -92,6 +95,8 @@ func (k SdkKind) DefaultJavaLibraryName() string {
return "android_system_stubs_current"
case SdkTest:
return "android_test_stubs_current"
+ case SdkTestFrameworksCore:
+ return "android_test_frameworks_core_stubs_current"
case SdkCore:
return "core.current.stubs"
case SdkModule:
@@ -137,7 +142,7 @@ func (s SdkSpec) Stable() bool {
return true
case SdkCore, SdkPublic, SdkSystem, SdkModule, SdkSystemServer:
return true
- case SdkCorePlatform, SdkTest, SdkPrivate:
+ case SdkCorePlatform, SdkTest, SdkTestFrameworksCore, SdkPrivate:
return false
default:
panic(fmt.Errorf("unknown SdkKind=%v", s.Kind))
@@ -185,7 +190,8 @@ func (s SdkSpec) UsePrebuilt(ctx EarlyModuleContext) bool {
return ctx.Config().AlwaysUsePrebuiltSdks()
} else if !s.ApiLevel.IsPreview() {
// 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))
return false
}
@@ -266,6 +272,8 @@ func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
kind = SdkSystem
case "test":
kind = SdkTest
+ case "test_frameworks_core":
+ kind = SdkTestFrameworksCore
case "module":
kind = SdkModule
case "system_server":
diff --git a/java/sdk.go b/java/sdk.go
index 7c702c405..ddd99bb33 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -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
// just use its system modules.
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
// its system modules.
systemModuleKind = android.SdkPublic
@@ -192,7 +193,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
bootclasspath: corePlatformBootclasspathLibraries(ctx),
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))
case android.SdkCore:
return sdkDep{
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 041aeb786..4ad3907a1 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -470,6 +470,9 @@ type ApiScopeProperties struct {
// or the API file. They both have to use the same sdk_version as is used for
// compiling the implementation library.
Sdk_version *string
+
+ // Extra libs used when compiling stubs for this scope.
+ Libs []string
}
type sdkLibraryProperties struct {
@@ -1653,6 +1656,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
props.Patch_module = module.properties.Patch_module
props.Installable = proptools.BoolPtr(false)
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
// The stub-annotations library contains special versions of the annotations
// 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 = append(props.Libs, module.properties.Static_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.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs
props.Java_version = module.properties.Java_version
@@ -1864,6 +1869,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
props.Api_contributions = apiContributions
props.Libs = module.properties.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.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 0b46919d2..21f0bab37 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -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")
}
+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) {
result := android.GroupFixturePreparers(
prepareForJavaTest,