From 63b4e0f5c15276cc5d2b04d12f914798521eed8a Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 26 Jun 2018 23:48:52 -0700 Subject: [PATCH] Sort and uniqify dangling rules list Make the dangling rules list sorted and unique in order to avoid very long lists when a dangling rule is referenced many times. Also prettify the output by indenting the list and printing "stopping" instead of a blank line for the fatal. Test: m checkbuild Change-Id: I8f7c27ae39b59f506b529d9995d90b0d6b9835d1 --- ui/build/test_build.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ui/build/test_build.go b/ui/build/test_build.go index 940f0c89f..4bc4c977b 100644 --- a/ui/build/test_build.go +++ b/ui/build/test_build.go @@ -18,6 +18,7 @@ import ( "bufio" "path/filepath" "runtime" + "sort" "strings" ) @@ -56,7 +57,7 @@ func testForDanglingRules(ctx Context, config Config) { bootstrapDir := filepath.Join(outDir, "soong", ".bootstrap") miniBootstrapDir := filepath.Join(outDir, "soong", ".minibootstrap") - var danglingRules []string + danglingRules := make(map[string]bool) scanner := bufio.NewScanner(stdout) for scanner.Scan() { @@ -70,16 +71,22 @@ func testForDanglingRules(ctx Context, config Config) { // full build rules in the primary build.ninja file. continue } - danglingRules = append(danglingRules, line) + danglingRules[line] = true } cmd.WaitOrFatal() - if len(danglingRules) > 0 { + var danglingRulesList []string + for rule := range danglingRules { + danglingRulesList = append(danglingRulesList, rule) + } + sort.Strings(danglingRulesList) + + if len(danglingRulesList) > 0 { ctx.Println("Dependencies in out found with no rule to create them:") - for _, dep := range danglingRules { - ctx.Println(dep) + for _, dep := range danglingRulesList { + ctx.Println(" ", dep) } - ctx.Fatal("") + ctx.Fatal("stopping") } }