Pass --sdk-extensions-{root,info} to metalava
Teach soong to pass metalava the two new command line arguments --sdk-extensions-root <dir> and --sdk-extensions-info <file> when generating the API levels file (--generate-api-levels api-versions.xml). The directory hierarcy in a droiddoc_exported_dir module has special meaning, e.g. extensions/1/public/*-stubs.jar are the mainline module stubs containing the public API for SdkExt version 1. Update the logic where the directories are scanned for android.jar files to locate the SDK extension jars (extensions/<int>/public/*-stubs.jar). Also introduce a new field on droidstubs properties (Extensions_info_file) to set the value of --sdk-extensions-info. Note: if Extensions_info_file is not set, neither --sdk-extensions-root or --sdk-extensions-info will be passed to metalava. Bug: 228828986 Test: go test -run TestDroidstubsWithSdkExtensions ./java Test: m sdk dist && grep -e from= -e module= out/dist/data/api-versions.xml # needs APIs to be listed in the info file Change-Id: I682e34d328fc93d3eded8565ffee40961307901a
This commit is contained in:
@@ -259,3 +259,33 @@ func checkSystemModulesUseByDroidstubs(t *testing.T, ctx *android.TestContext, m
|
||||
t.Errorf("inputs of %q must be []string{%q}, but was %#v.", moduleName, systemJar, systemJars)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroidstubsWithSdkExtensions(t *testing.T) {
|
||||
ctx, _ := testJavaWithFS(t, `
|
||||
droiddoc_exported_dir {
|
||||
name: "sdk-dir",
|
||||
path: "sdk",
|
||||
}
|
||||
|
||||
droidstubs {
|
||||
name: "baz-stubs",
|
||||
api_levels_annotations_dirs: ["sdk-dir"],
|
||||
api_levels_annotations_enabled: true,
|
||||
extensions_info_file: ":info-file",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "info-file",
|
||||
srcs: ["sdk/extensions/info.txt"],
|
||||
}
|
||||
`,
|
||||
map[string][]byte{
|
||||
"sdk/extensions/1/public/some-mainline-module-stubs.jar": nil,
|
||||
"sdk/extensions/info.txt": nil,
|
||||
})
|
||||
m := ctx.ModuleForTests("baz-stubs", "android_common")
|
||||
manifest := m.Output("metalava.sbox.textproto")
|
||||
cmdline := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command)
|
||||
android.AssertStringDoesContain(t, "sdk-extensions-root present", cmdline, "--sdk-extensions-root sdk/extensions")
|
||||
android.AssertStringDoesContain(t, "sdk-extensions-info present", cmdline, "--sdk-extensions-info sdk/extensions/info.txt")
|
||||
}
|
||||
|
Reference in New Issue
Block a user