Report reverse dependencies for dangling rules.
To help find what pulls them in. Test: m checkbuild on a tree that exhibited the problem in https://android-build.googleplex.com/builds/pending/P13607612/aosp_crosshatch-userdebug/latest/view/logs/build_error.log Change-Id: I59f3c98f21e5fb45dbd0aa814400f734d769a442
This commit is contained in:
parent
ff6bd149dd
commit
946fb67272
1 changed files with 28 additions and 6 deletions
|
@ -50,10 +50,10 @@ func testForDanglingRules(ctx Context, config Config) {
|
|||
// Get a list of leaf nodes in the dependency graph from ninja
|
||||
executable := config.PrebuiltBuildTool("ninja")
|
||||
|
||||
args := []string{}
|
||||
args = append(args, config.NinjaArgs()...)
|
||||
args = append(args, "-f", config.CombinedNinjaFile())
|
||||
args = append(args, "-t", "targets", "rule")
|
||||
common_args := []string{}
|
||||
common_args = append(common_args, config.NinjaArgs()...)
|
||||
common_args = append(common_args, "-f", config.CombinedNinjaFile())
|
||||
args := append(common_args, "-t", "targets", "rule")
|
||||
|
||||
cmd := Command(ctx, config, "ninja", executable, args...)
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
|
@ -96,9 +96,31 @@ func testForDanglingRules(ctx Context, config Config) {
|
|||
sb := &strings.Builder{}
|
||||
title := "Dependencies in out found with no rule to create them:"
|
||||
fmt.Fprintln(sb, title)
|
||||
for _, dep := range danglingRulesList {
|
||||
fmt.Fprintln(sb, " ", dep)
|
||||
|
||||
report_lines := 1
|
||||
for i, dep := range danglingRulesList {
|
||||
if report_lines > 20 {
|
||||
fmt.Fprintf(sb, " ... and %d more\n", len(danglingRulesList)-i)
|
||||
break
|
||||
}
|
||||
// It's helpful to see the reverse dependencies. ninja -t query is the
|
||||
// best tool we got for that. Its output starts with the dependency
|
||||
// itself.
|
||||
query_cmd := Command(ctx, config, "ninja", executable,
|
||||
append(common_args, "-t", "query", dep)...)
|
||||
query_stdout, err := query_cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
ctx.Fatal(err)
|
||||
}
|
||||
query_cmd.StartOrFatal()
|
||||
scanner := bufio.NewScanner(query_stdout)
|
||||
for scanner.Scan() {
|
||||
report_lines++
|
||||
fmt.Fprintln(sb, " ", scanner.Text())
|
||||
}
|
||||
query_cmd.WaitOrFatal()
|
||||
}
|
||||
|
||||
ts.FinishAction(status.ActionResult{
|
||||
Action: action,
|
||||
Error: fmt.Errorf(title),
|
||||
|
|
Loading…
Reference in a new issue