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
Merged-In: Ibd521c96b7aeab90b95965c1b524e0a0152aaf5a
Exempt-From-Owner-Approval: cp from aosp
(cherry picked from commit a8bd113a69
)
This commit is contained in:
parent
334b51730a
commit
5e7c32d6cb
3 changed files with 51 additions and 14 deletions
|
@ -411,28 +411,41 @@ type ApexModuleDepInfo struct {
|
||||||
type DepNameToDepInfoMap map[string]ApexModuleDepInfo
|
type DepNameToDepInfoMap map[string]ApexModuleDepInfo
|
||||||
|
|
||||||
type ApexBundleDepsInfo struct {
|
type ApexBundleDepsInfo struct {
|
||||||
|
flatListPath OutputPath
|
||||||
fullListPath OutputPath
|
fullListPath OutputPath
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApexDepsInfoIntf interface {
|
type ApexDepsInfoIntf interface {
|
||||||
|
FlatListPath() Path
|
||||||
FullListPath() Path
|
FullListPath() Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *ApexBundleDepsInfo) FlatListPath() Path {
|
||||||
|
return d.flatListPath
|
||||||
|
}
|
||||||
|
|
||||||
func (d *ApexBundleDepsInfo) FullListPath() Path {
|
func (d *ApexBundleDepsInfo) FullListPath() Path {
|
||||||
return d.fullListPath
|
return d.fullListPath
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ApexDepsInfoIntf = (*ApexBundleDepsInfo)(nil)
|
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) {
|
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)) {
|
for _, key := range FirstUniqueStrings(SortedStringKeys(depInfos)) {
|
||||||
info := depInfos[key]
|
info := depInfos[key]
|
||||||
toName := info.To
|
toName := info.To
|
||||||
if info.IsExternal {
|
if info.IsExternal {
|
||||||
toName = toName + " (external)"
|
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
|
d.fullListPath = PathForModuleOut(ctx, "depsinfo", "fulllist.txt").OutputPath
|
||||||
|
@ -441,7 +454,17 @@ func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, depInfos DepN
|
||||||
Description: "Full Dependency Info",
|
Description: "Full Dependency Info",
|
||||||
Output: d.fullListPath,
|
Output: d.fullListPath,
|
||||||
Args: map[string]string{
|
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(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,12 +478,19 @@ func TestBasicApex(t *testing.T) {
|
||||||
ensureListContains(t, noticeInputs, "custom_notice")
|
ensureListContains(t, noticeInputs, "custom_notice")
|
||||||
ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
|
ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
|
||||||
|
|
||||||
depsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
||||||
ensureListContains(t, depsInfo, "myjar <- myapex")
|
ensureListContains(t, fullDepsInfo, "myjar <- myapex")
|
||||||
ensureListContains(t, depsInfo, "mylib <- myapex")
|
ensureListContains(t, fullDepsInfo, "mylib <- myapex")
|
||||||
ensureListContains(t, depsInfo, "mylib2 <- mylib")
|
ensureListContains(t, fullDepsInfo, "mylib2 <- mylib")
|
||||||
ensureListContains(t, depsInfo, "myotherjar <- myjar")
|
ensureListContains(t, fullDepsInfo, "myotherjar <- myjar")
|
||||||
ensureListContains(t, depsInfo, "mysharedjar (external) <- myjar")
|
ensureListContains(t, fullDepsInfo, "mysharedjar (external) <- myjar")
|
||||||
|
|
||||||
|
flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
|
||||||
|
ensureListContains(t, flatDepsInfo, " myjar")
|
||||||
|
ensureListContains(t, flatDepsInfo, " mylib")
|
||||||
|
ensureListContains(t, flatDepsInfo, " mylib2")
|
||||||
|
ensureListContains(t, flatDepsInfo, " myotherjar")
|
||||||
|
ensureListContains(t, flatDepsInfo, " mysharedjar (external)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaults(t *testing.T) {
|
func TestDefaults(t *testing.T) {
|
||||||
|
@ -784,11 +791,15 @@ func TestApexWithExplicitStubsDependency(t *testing.T) {
|
||||||
// Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
|
// Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
|
||||||
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
|
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
|
||||||
|
|
||||||
depsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
||||||
|
ensureListContains(t, fullDepsInfo, "mylib <- myapex2")
|
||||||
|
ensureListContains(t, fullDepsInfo, "libbaz <- mylib")
|
||||||
|
ensureListContains(t, fullDepsInfo, "libfoo (external) <- mylib")
|
||||||
|
|
||||||
ensureListContains(t, depsInfo, "mylib <- myapex2")
|
flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
|
||||||
ensureListContains(t, depsInfo, "libbaz <- mylib")
|
ensureListContains(t, flatDepsInfo, " mylib")
|
||||||
ensureListContains(t, depsInfo, "libfoo (external) <- mylib")
|
ensureListContains(t, flatDepsInfo, " libbaz")
|
||||||
|
ensureListContains(t, flatDepsInfo, " libfoo (external)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
||||||
|
|
|
@ -710,6 +710,9 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: android.Phony,
|
Rule: android.Phony,
|
||||||
Output: android.PathForPhony(ctx, a.Name()+"-deps-info"),
|
Output: android.PathForPhony(ctx, a.Name()+"-deps-info"),
|
||||||
Inputs: []android.Path{a.ApexBundleDepsInfo.FullListPath()},
|
Inputs: []android.Path{
|
||||||
|
a.ApexBundleDepsInfo.FullListPath(),
|
||||||
|
a.ApexBundleDepsInfo.FlatListPath(),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue