Introduce flat deps info list.
Compared to full list, flat list drops dependency edges and simply
lists all transitive dependencies for a top-level apex bundle.
Bug: 149622332
Test: m, manually build flatlist
Change-Id: Ibd521c96b7aeab90b95965c1b524e0a0152aaf5a
diff --git a/android/apex.go b/android/apex.go
index 5910ba0..1c2feb9 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -419,28 +419,41 @@
type DepNameToDepInfoMap map[string]ApexModuleDepInfo
type ApexBundleDepsInfo struct {
+ flatListPath OutputPath
fullListPath OutputPath
}
type ApexDepsInfoIntf interface {
+ FlatListPath() Path
FullListPath() Path
}
+func (d *ApexBundleDepsInfo) FlatListPath() Path {
+ return d.flatListPath
+}
+
func (d *ApexBundleDepsInfo) FullListPath() Path {
return d.fullListPath
}
var _ ApexDepsInfoIntf = (*ApexBundleDepsInfo)(nil)
+// Generate two module out files:
+// 1. FullList with transitive deps and their parents in the dep graph
+// 2. FlatList with a flat list of transitive deps
func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, depInfos DepNameToDepInfoMap) {
- var content strings.Builder
+ var fullContent strings.Builder
+ var flatContent strings.Builder
+
+ fmt.Fprintf(&flatContent, "%s:\\n", ctx.ModuleName())
for _, key := range FirstUniqueStrings(SortedStringKeys(depInfos)) {
info := depInfos[key]
toName := info.To
if info.IsExternal {
toName = toName + " (external)"
}
- fmt.Fprintf(&content, "%s <- %s\\n", toName, strings.Join(SortedUniqueStrings(info.From), ", "))
+ fmt.Fprintf(&fullContent, "%s <- %s\\n", toName, strings.Join(SortedUniqueStrings(info.From), ", "))
+ fmt.Fprintf(&flatContent, " %s\\n", toName)
}
d.fullListPath = PathForModuleOut(ctx, "depsinfo", "fulllist.txt").OutputPath
@@ -449,7 +462,17 @@
Description: "Full Dependency Info",
Output: d.fullListPath,
Args: map[string]string{
- "content": content.String(),
+ "content": fullContent.String(),
+ },
+ })
+
+ d.flatListPath = PathForModuleOut(ctx, "depsinfo", "flatlist.txt").OutputPath
+ ctx.Build(pctx, BuildParams{
+ Rule: WriteFile,
+ Description: "Flat Dependency Info",
+ Output: d.flatListPath,
+ Args: map[string]string{
+ "content": flatContent.String(),
},
})
}