droidstubs depend on the combined last api filegroup modules
This change creates a "combined" filegroup module, which will contain
all api files of the subset api scopes in the followup change. In this
change, the "combined" filegroup is identical to the currently existing
last api filegroup module in that it only contains the api file /
removed api file of the specific api scope.
This change also passes the "combined" filegroup to the droidstubs
module generated from the sdk_library modules, but this currently does
not lead to any functional changes as the "combined" filegroup is
identical to the currently existing last api filegroup.
Test: m nothing --no-skip-soong-tests
Bug: 321827591
Change-Id: If73a7229f2f970f7e74cd010a8b4808dc9018344
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index 94e9c6c..6a79e58 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -158,6 +158,21 @@
mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
}
+func createCombinedApiFilegroupModule(mctx android.LoadHookContext, name string, srcs []string) {
+ filegroupProps := struct {
+ Name *string
+ Srcs []string
+ }{}
+ filegroupProps.Name = proptools.StringPtr(name)
+
+ var transformedSrcs []string
+ for _, src := range srcs {
+ transformedSrcs = append(transformedSrcs, ":"+src)
+ }
+ filegroupProps.Srcs = transformedSrcs
+ mctx.CreateModule(android.FileGroupFactory, &filegroupProps)
+}
+
func createLatestApiModuleExtensionVersionFile(mctx android.LoadHookContext, name string, version string) {
genruleProps := struct {
Name *string
@@ -252,6 +267,10 @@
return module + ".api." + scope + "." + version
}
+func PrebuiltApiCombinedModuleName(module, scope, version string) string {
+ return module + ".api.combined." + scope + "." + version
+}
+
func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
// <apiver>/<scope>/api/<module>.txt
apiLevelFiles := globApiDirs(mctx, p, "api/*.txt")
@@ -307,7 +326,9 @@
}
// Sort the keys in order to make build.ninja stable
- for _, k := range android.SortedKeys(latest) {
+ sortedLatestKeys := android.SortedKeys(latest)
+
+ for _, k := range sortedLatestKeys {
info := latest[k]
name := PrebuiltApiModuleName(info.module, info.scope, "latest")
latestExtensionVersionModuleName := PrebuiltApiModuleName(info.module, info.scope, "latest.extension_version")
@@ -333,11 +354,25 @@
}
}
// Create empty incompatibilities files for remaining modules
- for _, k := range android.SortedKeys(latest) {
+ // If the incompatibility module has been created, create a corresponding combined module
+ for _, k := range sortedLatestKeys {
if _, ok := incompatibilities[k]; !ok {
createEmptyFile(mctx, PrebuiltApiModuleName(latest[k].module+"-incompatibilities", latest[k].scope, "latest"))
}
}
+
+ // Create combined latest api and removed api files modules.
+ // The combined modules list all api files of the api scope and its subset api scopes.
+ for _, k := range sortedLatestKeys {
+ info := latest[k]
+ name := PrebuiltApiCombinedModuleName(info.module, info.scope, "latest")
+
+ var srcs []string
+ currentApiScope := scopeByName[info.scope]
+ srcs = append(srcs, PrebuiltApiModuleName(info.module, currentApiScope.name, "latest"))
+
+ createCombinedApiFilegroupModule(mctx, name, srcs)
+ }
}
func createPrebuiltApiModules(mctx android.LoadHookContext) {