Export depsInfo into android package.
Move depsInfo into android for easier sharing with APK code.
Bug: 149622332
Test: m, diff'ing outputs for conscrypt module.
Change-Id: If0ee967d37425540e69b4ce9304229d9f2cd86bd
diff --git a/apex/apex.go b/apex/apex.go
index a2a75ef..d196e95 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1276,12 +1276,6 @@
return false
}
-type depInfo struct {
- to string
- from []string
- isExternal bool
-}
-
type apexBundle struct {
android.ModuleBase
android.DefaultableModuleBase
@@ -1316,7 +1310,7 @@
requiredDeps []string
// list of module names that this APEX is including (to be shown via *-deps-info target)
- depInfos map[string]depInfo
+ android.ApexBundleDepsInfo
testApex bool
vndkApex bool
@@ -1890,35 +1884,6 @@
}
}
-// Collects the list of module names that directly or indirectly contributes to the payload of this APEX
-func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) {
- a.depInfos = make(map[string]depInfo)
- a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
- if from.Name() == to.Name() {
- // This can happen for cc.reuseObjTag. We are not interested in tracking this.
- // As soon as the dependency graph crosses the APEX boundary, don't go further.
- return !externalDep
- }
-
- if info, exists := a.depInfos[to.Name()]; exists {
- if !android.InList(from.Name(), info.from) {
- info.from = append(info.from, from.Name())
- }
- info.isExternal = info.isExternal && externalDep
- a.depInfos[to.Name()] = info
- } else {
- a.depInfos[to.Name()] = depInfo{
- to: to.Name(),
- from: []string{from.Name()},
- isExternal: externalDep,
- }
- }
-
- // As soon as the dependency graph crosses the APEX boundary, don't go further.
- return !externalDep
- })
-}
-
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
switch a.properties.ApexType {
@@ -1956,7 +1921,6 @@
a.checkApexAvailability(ctx)
a.checkUpdatable(ctx)
- a.collectDepsInfo(ctx)
handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d30b429..d520544 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -504,7 +504,7 @@
ensureListContains(t, noticeInputs, "custom_notice")
ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
- depsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("myapex-deps-info.txt").Args["content"], "\\n")
+ depsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
ensureListContains(t, depsInfo, "myjar <- myapex")
ensureListContains(t, depsInfo, "mylib <- myapex")
ensureListContains(t, depsInfo, "mylib2 <- mylib")
@@ -818,7 +818,7 @@
// Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
- depsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("myapex2-deps-info.txt").Args["content"], "\\n")
+ depsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
ensureListContains(t, depsInfo, "mylib <- myapex2")
ensureListContains(t, depsInfo, "libbaz <- mylib")
diff --git a/apex/builder.go b/apex/builder.go
index fba6b94..c6650c3 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -688,29 +688,37 @@
return
}
- var content strings.Builder
- for _, key := range android.SortedStringKeys(a.depInfos) {
- info := a.depInfos[key]
- toName := info.to
- if info.isExternal {
- toName = toName + " (external)"
+ depInfos := android.DepNameToDepInfoMap{}
+ a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
+ if from.Name() == to.Name() {
+ // This can happen for cc.reuseObjTag. We are not interested in tracking this.
+ // As soon as the dependency graph crosses the APEX boundary, don't go further.
+ return !externalDep
}
- fmt.Fprintf(&content, "%s <- %s\\n", toName, strings.Join(android.SortedUniqueStrings(info.from), ", "))
- }
- depsInfoFile := android.PathForOutput(ctx, a.Name()+"-deps-info.txt")
- ctx.Build(pctx, android.BuildParams{
- Rule: android.WriteFile,
- Description: "Dependency Info",
- Output: depsInfoFile,
- Args: map[string]string{
- "content": content.String(),
- },
+ if info, exists := depInfos[to.Name()]; exists {
+ if !android.InList(from.Name(), info.From) {
+ info.From = append(info.From, from.Name())
+ }
+ info.IsExternal = info.IsExternal && externalDep
+ depInfos[to.Name()] = info
+ } else {
+ depInfos[to.Name()] = android.ApexModuleDepInfo{
+ To: to.Name(),
+ From: []string{from.Name()},
+ IsExternal: externalDep,
+ }
+ }
+
+ // As soon as the dependency graph crosses the APEX boundary, don't go further.
+ return !externalDep
})
+ a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, depInfos)
+
ctx.Build(pctx, android.BuildParams{
Rule: android.Phony,
Output: android.PathForPhony(ctx, a.Name()+"-deps-info"),
- Inputs: []android.Path{depsInfoFile},
+ Inputs: []android.Path{a.ApexBundleDepsInfo.FullListPath()},
})
}