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

Commit 8e47abc7 authored by Steven Moreland's avatar Steven Moreland
Browse files

glob blame

A vote for this is a vote for transparency!

Bugs: me
Test: here's what it looks like:

```
:) m
...
First culprit glob: frameworks/native/libs/binder/**/*
Globs changed, rerunning soong...
```

Change-Id: I71a3b39f540e49dba875db4c3b523179fa0e77cc
parent 07aa071d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -766,7 +766,11 @@ func checkGlobs(ctx Context, finalOutFile string) error {
	globsChan := make(chan pathtools.GlobResult)
	errorsChan := make(chan error)
	wg := sync.WaitGroup{}

	hasChangedGlobs := false
	var changedGlobNameMutex sync.Mutex
	var changedGlobName string

	for i := 0; i < runtime.NumCPU()*2; i++ {
		wg.Add(1)
		go func() {
@@ -804,6 +808,13 @@ func checkGlobs(ctx Context, finalOutFile string) error {
				} else {
					if !slices.Equal(result.Matches, cachedGlob.Matches) {
						hasChangedGlobs = true

						changedGlobNameMutex.Lock()
						defer changedGlobNameMutex.Unlock()
						changedGlobName = result.Pattern
						if len(result.Excludes) > 0 {
							changedGlobName += " (excluding " + strings.Join(result.Excludes, ", ") + ")"
						}
					}
				}
			}
@@ -855,6 +866,7 @@ func checkGlobs(ctx Context, finalOutFile string) error {

	if hasChangedGlobs {
		fmt.Fprintf(os.Stdout, "Globs changed, rerunning soong...\n")
		fmt.Fprintf(os.Stdout, "One culprit glob (may be more): %s\n", changedGlobName)
		// Write the current time to the glob_results file. We just need
		// some unique value to trigger a rerun, it doesn't matter what it is.
		err = os.WriteFile(