Merge "java_sdk_library: Add system-server scope" into rvc-dev am: 4754d4451c
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/11705588 Change-Id: I6c2a7000cf7b46dcef8ed476d6e96ffc7e441ed4
This commit is contained in:
commit
01c577968a
|
@ -1426,6 +1426,38 @@ func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
|
|||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
|
||||
testJava(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
system: {
|
||||
enabled: true,
|
||||
},
|
||||
module_lib: {
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_SystemServer(t *testing.T) {
|
||||
testJava(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
system: {
|
||||
enabled: true,
|
||||
},
|
||||
system_server: {
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_MissingScope(t *testing.T) {
|
||||
testJavaError(t, `requires api scope module-lib from foo but it only has \[\] available`, `
|
||||
java_sdk_library {
|
||||
|
|
|
@ -264,7 +264,7 @@ var (
|
|||
apiScopeModuleLib = initApiScope(&apiScope{
|
||||
name: "module-lib",
|
||||
extends: apiScopeSystem,
|
||||
// Module_lib scope is disabled by default in legacy mode.
|
||||
// The module-lib scope is disabled by default in legacy mode.
|
||||
//
|
||||
// Enabling this would break existing usages.
|
||||
legacyEnabledStatus: func(module *SdkLibrary) bool {
|
||||
|
@ -280,11 +280,34 @@ var (
|
|||
"--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES\\)",
|
||||
},
|
||||
})
|
||||
apiScopeSystemServer = initApiScope(&apiScope{
|
||||
name: "system-server",
|
||||
extends: apiScopePublic,
|
||||
// The system-server scope is disabled by default in legacy mode.
|
||||
//
|
||||
// Enabling this would break existing usages.
|
||||
legacyEnabledStatus: func(module *SdkLibrary) bool {
|
||||
return false
|
||||
},
|
||||
scopeSpecificProperties: func(module *SdkLibrary) *ApiScopeProperties {
|
||||
return &module.sdkLibraryProperties.System_server
|
||||
},
|
||||
apiFilePrefix: "system-server-",
|
||||
moduleSuffix: ".system_server",
|
||||
sdkVersion: "system_server_current",
|
||||
droidstubsArgs: []string{
|
||||
"--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.SYSTEM_SERVER\\) ",
|
||||
"--hide-annotation android.annotation.Hide",
|
||||
// com.android.* classes are okay in this interface"
|
||||
"--hide InternalClasses",
|
||||
},
|
||||
})
|
||||
allApiScopes = apiScopes{
|
||||
apiScopePublic,
|
||||
apiScopeSystem,
|
||||
apiScopeTest,
|
||||
apiScopeModuleLib,
|
||||
apiScopeSystemServer,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -432,12 +455,18 @@ type sdkLibraryProperties struct {
|
|||
// In non-legacy mode the test api scope is disabled by default.
|
||||
Test ApiScopeProperties
|
||||
|
||||
// The properties specific to the module_lib api scope
|
||||
// The properties specific to the module-lib api scope
|
||||
//
|
||||
// Unless explicitly specified by using test.enabled the module_lib api scope is
|
||||
// Unless explicitly specified by using test.enabled the module-lib api scope is
|
||||
// disabled by default.
|
||||
Module_lib ApiScopeProperties
|
||||
|
||||
// The properties specific to the system-server api scope
|
||||
//
|
||||
// Unless explicitly specified by using test.enabled the module-lib api scope is
|
||||
// disabled by default.
|
||||
System_server ApiScopeProperties
|
||||
|
||||
// Determines if the stubs are preferred over the implementation library
|
||||
// for linking, even when the client doesn't specify sdk_version. When this
|
||||
// is set to true, such clients are provided with the widest API surface that
|
||||
|
@ -746,6 +775,8 @@ func (c *commonToSdkLibraryAndImport) selectHeaderJarsForSdkVersion(ctx android.
|
|||
apiScope = apiScopeModuleLib
|
||||
case sdkTest:
|
||||
apiScope = apiScopeTest
|
||||
case sdkSystemServer:
|
||||
apiScope = apiScopeSystemServer
|
||||
default:
|
||||
apiScope = apiScopePublic
|
||||
}
|
||||
|
|
|
@ -142,6 +142,13 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
|||
|
||||
"stubs-sources/foo/Foo.java": nil,
|
||||
"stubs/sources/foo/Foo.java": nil,
|
||||
|
||||
// For java_sdk_library
|
||||
"api/module-lib-current.txt": nil,
|
||||
"api/module-lib-removed.txt": nil,
|
||||
"api/system-server-current.txt": nil,
|
||||
"api/system-server-removed.txt": nil,
|
||||
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
||||
}
|
||||
|
||||
cc.GatherRequiredFilesForTest(mockFS)
|
||||
|
|
|
@ -34,6 +34,8 @@ func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
|
|||
"api/test-removed.txt": nil,
|
||||
"api/module-lib-current.txt": nil,
|
||||
"api/module-lib-removed.txt": nil,
|
||||
"api/system-server-current.txt": nil,
|
||||
"api/system-server-removed.txt": nil,
|
||||
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
||||
}
|
||||
|
||||
|
@ -60,6 +62,9 @@ java_import {
|
|||
java_import {
|
||||
name: "android_module_lib_stubs_current",
|
||||
}
|
||||
java_import {
|
||||
name: "android_system_server_stubs_current",
|
||||
}
|
||||
java_import {
|
||||
name: "core-lambda-stubs",
|
||||
sdk_version: "none",
|
||||
|
@ -1398,6 +1403,93 @@ sdk_snapshot {
|
|||
)
|
||||
}
|
||||
|
||||
func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
|
||||
result := testSdkWithJava(t, `
|
||||
sdk {
|
||||
name: "mysdk",
|
||||
java_sdk_libs: ["myjavalib"],
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
name: "myjavalib",
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
srcs: ["Test.java"],
|
||||
sdk_version: "current",
|
||||
public: {
|
||||
enabled: true,
|
||||
},
|
||||
system_server: {
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
`)
|
||||
|
||||
result.CheckSnapshot("mysdk", "",
|
||||
checkAndroidBpContents(`
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "mysdk_myjavalib@current",
|
||||
sdk_member_name: "myjavalib",
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
shared_library: true,
|
||||
public: {
|
||||
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/public/myjavalib.txt",
|
||||
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||
sdk_version: "current",
|
||||
},
|
||||
system_server: {
|
||||
jars: ["sdk_library/system-server/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/system-server/myjavalib.txt",
|
||||
removed_api: "sdk_library/system-server/myjavalib-removed.txt",
|
||||
sdk_version: "system_server_current",
|
||||
},
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
shared_library: true,
|
||||
public: {
|
||||
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/public/myjavalib.txt",
|
||||
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||
sdk_version: "current",
|
||||
},
|
||||
system_server: {
|
||||
jars: ["sdk_library/system-server/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/system-server/myjavalib.txt",
|
||||
removed_api: "sdk_library/system-server/myjavalib-removed.txt",
|
||||
sdk_version: "system_server_current",
|
||||
},
|
||||
}
|
||||
|
||||
sdk_snapshot {
|
||||
name: "mysdk@current",
|
||||
java_sdk_libs: ["mysdk_myjavalib@current"],
|
||||
}
|
||||
`),
|
||||
checkAllCopyRules(`
|
||||
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
|
||||
.intermediates/myjavalib.stubs.source/android_common/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
|
||||
.intermediates/myjavalib.stubs.source/android_common/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
|
||||
.intermediates/myjavalib.stubs.system_server/android_common/javac/myjavalib.stubs.system_server.jar -> sdk_library/system-server/myjavalib-stubs.jar
|
||||
.intermediates/myjavalib.stubs.source.system_server/android_common/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
|
||||
.intermediates/myjavalib.stubs.source.system_server/android_common/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
|
||||
`),
|
||||
checkMergeZips(
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/system-server/myjavalib_stub_sources.zip",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) {
|
||||
result := testSdkWithJava(t, `
|
||||
sdk {
|
||||
|
|
Loading…
Reference in New Issue