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
This commit is contained in:
13
glob/glob.go
13
glob/glob.go
@@ -35,7 +35,7 @@ func IsGlob(glob string) bool {
|
||||
// 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 @@ func GlobWithDepFile(glob, fileListFile, depFile string) (files []string, err er
|
||||
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 @@ func GlobWithDepFile(glob, fileListFile, depFile string) (files []string, err er
|
||||
return nil
|
||||
})
|
||||
|
||||
fileList := strings.Join(files, "\n")
|
||||
fileList := strings.Join(files, "\n") + "\n"
|
||||
|
||||
writeFileIfChanged(fileListFile, []byte(fileList), 0666)
|
||||
deptools.WriteDepFile(depFile, fileListFile, dirs)
|
||||
|
Reference in New Issue
Block a user