Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63b4e0f5 authored by Colin Cross's avatar Colin Cross
Browse files

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
parent 17ef5635
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -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")
	}
}