java_sdk_library: Add support for module_lib API surface
Adds api scope for the module_lib and adds that to the list of all
all available scopes. The scope is generated if and only if the
api_surfaces property contains "module_lib".
No other changes are needed as the generation of the APIs is completely
driven by the allApiScopes array and the information in its contained
apiScope structures.
Test: m checkapi
Bug: 155164730
Merged-In: I7769af6823badca8715a270f86cf53b4e954b7df
Change-Id: I7769af6823badca8715a270f86cf53b4e954b7df
(cherry picked from commit 8f265b9ab9
)
This commit is contained in:
parent
3a254985af
commit
6d7f0a719c
2 changed files with 137 additions and 0 deletions
|
@ -186,10 +186,30 @@ var (
|
|||
droidstubsArgs: []string{"-showAnnotation android.annotation.TestApi"},
|
||||
unstable: true,
|
||||
})
|
||||
apiScopeModuleLib = initApiScope(&apiScope{
|
||||
name: "module_lib",
|
||||
extends: apiScopeSystem,
|
||||
// Module_lib 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.Module_lib
|
||||
},
|
||||
apiFilePrefix: "module-lib-",
|
||||
moduleSuffix: ".module_lib",
|
||||
sdkVersion: "module_current",
|
||||
droidstubsArgs: []string{
|
||||
"--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES\\)",
|
||||
},
|
||||
})
|
||||
allApiScopes = apiScopes{
|
||||
apiScopePublic,
|
||||
apiScopeSystem,
|
||||
apiScopeTest,
|
||||
apiScopeModuleLib,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -303,6 +323,12 @@ 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
|
||||
//
|
||||
// Unless explicitly specified by using test.enabled the module_lib api scope is
|
||||
// disabled by default.
|
||||
Module_lib ApiScopeProperties
|
||||
|
||||
// TODO: determines whether to create HTML doc or not
|
||||
//Html_doc *bool
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
|
|||
"api/system-removed.txt": nil,
|
||||
"api/test-current.txt": nil,
|
||||
"api/test-removed.txt": nil,
|
||||
"api/module-lib-current.txt": nil,
|
||||
"api/module-lib-removed.txt": nil,
|
||||
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
||||
}
|
||||
|
||||
|
@ -55,6 +57,9 @@ java_import {
|
|||
java_import {
|
||||
name: "android_test_stubs_current",
|
||||
}
|
||||
java_import {
|
||||
name: "android_module_lib_stubs_current",
|
||||
}
|
||||
java_import {
|
||||
name: "core-lambda-stubs",
|
||||
sdk_version: "none",
|
||||
|
@ -1152,3 +1157,109 @@ sdk_snapshot {
|
|||
),
|
||||
)
|
||||
}
|
||||
|
||||
func TestSnapshotWithJavaSdkLibrary_ModuleLib(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: {
|
||||
enabled: true,
|
||||
},
|
||||
module_lib: {
|
||||
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"],
|
||||
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: {
|
||||
jars: ["sdk_library/system/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/system/myjavalib.txt",
|
||||
removed_api: "sdk_library/system/myjavalib-removed.txt",
|
||||
sdk_version: "system_current",
|
||||
},
|
||||
module_lib: {
|
||||
jars: ["sdk_library/module_lib/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/module_lib/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/module_lib/myjavalib.txt",
|
||||
removed_api: "sdk_library/module_lib/myjavalib-removed.txt",
|
||||
sdk_version: "module_current",
|
||||
},
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
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: {
|
||||
jars: ["sdk_library/system/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/system/myjavalib.txt",
|
||||
removed_api: "sdk_library/system/myjavalib-removed.txt",
|
||||
sdk_version: "system_current",
|
||||
},
|
||||
module_lib: {
|
||||
jars: ["sdk_library/module_lib/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/module_lib/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/module_lib/myjavalib.txt",
|
||||
removed_api: "sdk_library/module_lib/myjavalib-removed.txt",
|
||||
sdk_version: "module_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_api.txt -> sdk_library/public/myjavalib-removed.txt
|
||||
.intermediates/myjavalib.stubs.system/android_common/javac/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
|
||||
.intermediates/myjavalib.stubs.source.system/android_common/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
|
||||
.intermediates/myjavalib.stubs.source.system/android_common/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib-removed.txt
|
||||
.intermediates/myjavalib.stubs.module_lib/android_common/javac/myjavalib.stubs.module_lib.jar -> sdk_library/module_lib/myjavalib-stubs.jar
|
||||
.intermediates/myjavalib.stubs.source.module_lib/android_common/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module_lib/myjavalib.txt
|
||||
.intermediates/myjavalib.stubs.source.module_lib/android_common/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module_lib/myjavalib-removed.txt
|
||||
`),
|
||||
checkMergeZips(
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip",
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/module_lib/myjavalib_stub_sources.zip",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue