Convert merged module lib stub to api.go
Bug: 169103987
Test: m framework-updatable-stubs-module_libs_api and diff intermediates
folder before and after.
Merged-In: I6018791ae136bc764a6e846078c6bce59bcc123b
Change-Id: I6018791ae136bc764a6e846078c6bce59bcc123b
diff --git a/api/api.go b/api/api.go
index 14fe09e..3b0e300 100644
--- a/api/api.go
+++ b/api/api.go
@@ -21,6 +21,7 @@
"android/soong/android"
"android/soong/genrule"
+ "android/soong/java"
)
const art = "art.module.public.api"
@@ -73,6 +74,13 @@
Visibility []string
}
+type libraryProps struct {
+ Name *string
+ Sdk_version *string
+ Static_libs []string
+ Visibility []string
+}
+
// Struct to pass parameters for the various merged [current|removed].txt file modules we create.
type MergedTxtDefinition struct {
// "current.txt" or "removed.txt"
@@ -169,6 +177,25 @@
ctx.CreateModule(genrule.GenRuleFactory, &props)
}
+func createMergedModuleLibStubs(ctx android.LoadHookContext, modules []string) {
+ // The user of this module compiles against the "core" SDK, so remove core libraries to avoid dupes.
+ modules = removeAll(modules, []string{art, conscrypt, i18n})
+ props := libraryProps{}
+ props.Name = proptools.StringPtr("framework-updatable-stubs-module_libs_api")
+ props.Static_libs = appendStr(modules, ".stubs.module_lib")
+ props.Sdk_version = proptools.StringPtr("module_current")
+ props.Visibility = []string{"//frameworks/base"}
+ ctx.CreateModule(java.LibraryFactory, &props)
+}
+
+func appendStr(modules []string, s string) []string {
+ a := make([]string, 0, len(modules))
+ for _, module := range modules {
+ a = append(a, module+s)
+ }
+ return a
+}
+
func createSrcs(base string, modules []string, tag string) []string {
a := make([]string, 0, len(modules)+1)
a = append(a, base)
@@ -246,6 +273,8 @@
createMergedStubsSrcjar(ctx, bootclasspath)
+ createMergedModuleLibStubs(ctx, bootclasspath)
+
createMergedAnnotations(ctx, bootclasspath)
createFilteredApiVersions(ctx, bootclasspath)