find bazel-related files and add them to bazel.list and ninja deps
This retriggers soong_build whenever a new bzl, WORKSPACE, or
BUILD.bazel file is changed or added.
Test: Manually verified on bionic/libc genrules with manual changes to
related BUILD/bzl/WORKSPACE files -- these all retrigger builds.
Test: Updated finder_test.go
Change-Id: I634384f88781a6b6db32f5d6bf9c07e179e14c39
diff --git a/finder/finder.go b/finder/finder.go
index 6513fa3..5413fa6 100644
--- a/finder/finder.go
+++ b/finder/finder.go
@@ -103,6 +103,9 @@
// IncludeFiles are file names to include as matches
IncludeFiles []string
+
+ // IncludeSuffixes are filename suffixes to include as matches.
+ IncludeSuffixes []string
}
// a cacheConfig stores the inputs that determine what should be included in the cache
@@ -1310,6 +1313,20 @@
return stats
}
+func (f *Finder) shouldIncludeFile(fileName string) bool {
+ for _, includedName := range f.cacheMetadata.Config.IncludeFiles {
+ if fileName == includedName {
+ return true
+ }
+ }
+ for _, includeSuffix := range f.cacheMetadata.Config.IncludeSuffixes {
+ if strings.HasSuffix(fileName, includeSuffix) {
+ return true
+ }
+ }
+ return false
+}
+
// pruneCacheCandidates removes the items that we don't want to include in our persistent cache
func (f *Finder) pruneCacheCandidates(items *DirEntries) {
@@ -1326,13 +1343,9 @@
// remove any files that aren't the ones we want to include
writeIndex := 0
for _, fileName := range items.FileNames {
- // include only these files
- for _, includedName := range f.cacheMetadata.Config.IncludeFiles {
- if fileName == includedName {
- items.FileNames[writeIndex] = fileName
- writeIndex++
- break
- }
+ if f.shouldIncludeFile(fileName) {
+ items.FileNames[writeIndex] = fileName
+ writeIndex++
}
}
// resize