Merge "Report reverse dependencies for dangling rules."
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
|
// Get a list of leaf nodes in the dependency graph from ninja
|
||||||
executable := config.PrebuiltBuildTool("ninja")
|
executable := config.PrebuiltBuildTool("ninja")
|
||||||
|
|
||||||
args := []string{}
|
common_args := []string{}
|
||||||
args = append(args, config.NinjaArgs()...)
|
common_args = append(common_args, config.NinjaArgs()...)
|
||||||
args = append(args, "-f", config.CombinedNinjaFile())
|
common_args = append(common_args, "-f", config.CombinedNinjaFile())
|
||||||
args = append(args, "-t", "targets", "rule")
|
args := append(common_args, "-t", "targets", "rule")
|
||||||
|
|
||||||
cmd := Command(ctx, config, "ninja", executable, args...)
|
cmd := Command(ctx, config, "ninja", executable, args...)
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
@@ -96,9 +96,31 @@ func testForDanglingRules(ctx Context, config Config) {
|
|||||||
sb := &strings.Builder{}
|
sb := &strings.Builder{}
|
||||||
title := "Dependencies in out found with no rule to create them:"
|
title := "Dependencies in out found with no rule to create them:"
|
||||||
fmt.Fprintln(sb, title)
|
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{
|
ts.FinishAction(status.ActionResult{
|
||||||
Action: action,
|
Action: action,
|
||||||
Error: fmt.Errorf(title),
|
Error: fmt.Errorf(title),
|
||||||
|
Reference in New Issue
Block a user