Generate runtime stubs in droidstubs
Similar to how the exportable stubs are generated in droidstubs, this
change adds the rule to generate the runtime stubs in droidstubs. Unlike
the exportable stubs, which the artifacts are dist'ed during the sdk
build, the runtime stubs will only used in the hiddenapi flags
generation. Therefore, only the stubs are generated and no other
artifacts are generated during the "runtime" metalava invocation. When
`aconfig_declarations` property is not defined (i.e. no flags are
enabled, thus the exportable and the runtime stubs are identical), the
runtime stubs are simple copied from the exportable stubs.
Note that the runtime stubs are not a dependency of `droid` as of now.
The dependency of the hiddenapi flags will be replaced to the runtime
stubs in the child CL.
Test: m nothing --no-skip-soong-tests && m api-stubs-docs-non-updatable
Bug: 319162970
Change-Id: I14928b7b5619522c4caab1dfc795bc9c7e929639
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index e5ffd28..ca34e0e 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -396,23 +396,47 @@
"bar",
],
}
+ droidstubs {
+ name: "baz",
+ srcs: ["a/A.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "a/current.txt",
+ removed_api_file: "a/removed.txt",
+ }
+ },
+ }
`)
// Check that droidstubs depend on aconfig_declarations
android.AssertBoolEquals(t, "foo expected to depend on bar",
CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true)
- m := result.ModuleForTests("foo", "android_common")
+ fooModule := result.ModuleForTests("foo", "android_common")
android.AssertStringDoesContain(t, "foo generates revert annotations file",
- strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt")
+ strings.Join(fooModule.AllOutputs(), ""), "revert-annotations-exportable.txt")
// revert-annotations.txt passed to exportable stubs generation metalava command
- manifest := m.Output("metalava_exportable.sbox.textproto")
- cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
- android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt")
+ exportableManifest := fooModule.Output("metalava_exportable.sbox.textproto")
+ exportableCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, exportableManifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", exportableCmdline, "revert-annotations-exportable.txt")
android.AssertStringDoesContain(t, "foo generates exportable stubs jar",
- strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+ strings.Join(fooModule.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+
+ // revert-annotations.txt passed to runtime stubs generation metalava command
+ runtimeManifest := fooModule.Output("metalava_runtime.sbox.textproto")
+ runtimeCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, runtimeManifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", runtimeCmdline, "revert-annotations-runtime.txt")
+
+ android.AssertStringDoesContain(t, "foo generates runtime stubs jar",
+ strings.Join(fooModule.AllOutputs(), ""), "runtime/foo-stubs.srcjar")
+
+ // If aconfig_declarations property is not defined, the runtime stubs is a copy of the exportable stubs
+ bazModule := result.ModuleForTests("baz", "android_common")
+ bazRuntimeCmdline := bazModule.Rule("metalava_runtime").RuleParams.Command
+ android.AssertStringDoesContain(t, "copy command should include the input stub", bazRuntimeCmdline, "exportable/baz-stubs.srcjar")
}
func TestReleaseExportRuntimeApis(t *testing.T) {