Merge "Report reverse dependencies for dangling rules." am: a268d59e8b
Change-Id: I92a6eb03814e4480eeeeb200e517833f7dfc7b8b
This commit is contained in:
@@ -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),
|
||||
|
Reference in New Issue
Block a user