Support excludes in globs
Java resource support requires globbing directories while ignoring
specific filenames. Add support for multiple -e options to
soong_glob to specify filenames to exclude, and split out Glob
into GlobRule to insert a rule to generate a glob file list.
Change-Id: Ia911dd68bd1638452881d18378572d015fd4e31a
diff --git a/glob/glob.go b/glob/glob.go
index eb4d1ab..a8c348d 100644
--- a/glob/glob.go
+++ b/glob/glob.go
@@ -35,7 +35,7 @@
// for a recursive glob.
//
// Returns a list of file paths, and an error.
-func GlobWithDepFile(glob, fileListFile, depFile string) (files []string, err error) {
+func GlobWithDepFile(glob, fileListFile, depFile string, excludes []string) (files []string, err error) {
globPattern := filepath.Base(glob)
globDir := filepath.Dir(glob)
recursive := false
@@ -64,6 +64,15 @@
return err
}
if match {
+ for _, e := range excludes {
+ excludeMatch, err := filepath.Match(e, info.Name())
+ if err != nil {
+ return err
+ }
+ if excludeMatch {
+ return nil
+ }
+ }
files = append(files, path)
}
}
@@ -71,7 +80,7 @@
return nil
})
- fileList := strings.Join(files, "\n")
+ fileList := strings.Join(files, "\n") + "\n"
writeFileIfChanged(fileListFile, []byte(fileList), 0666)
deptools.WriteDepFile(depFile, fileListFile, dirs)