aboutsummaryrefslogtreecommitdiffstats
path: root/glob
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-04-24 15:12:39 -0700
committerColin Cross <ccross@android.com>2015-04-29 14:59:23 -0700
commit6f23ef6bf3519298960a8bc35bd4ef20b4244d54 (patch)
tree18a7cac700407e0f21216d65a94705c1ae3e61cb /glob
parentd8e780df697c7ba52c2062ddcf17438cd9cb1959 (diff)
downloadbuild_soong-6f23ef6bf3519298960a8bc35bd4ef20b4244d54.tar.gz
build_soong-6f23ef6bf3519298960a8bc35bd4ef20b4244d54.tar.bz2
build_soong-6f23ef6bf3519298960a8bc35bd4ef20b4244d54.zip
Move globbing on top of pathtools.GlobWithExcludes
pathtools.GlobWithExcludes contains all the features of glob.GlobWithDepFile now, make GlobWithDepFile a wrapper around GlobWithExcludes that writes the results to a file. Change-Id: Ie75d9042845505f499aac7fa00d3c90f8ecab4f7
Diffstat (limited to 'glob')
-rw-r--r--glob/glob.go51
1 files changed, 4 insertions, 47 deletions
diff --git a/glob/glob.go b/glob/glob.go
index a07501a0..060c9dd6 100644
--- a/glob/glob.go
+++ b/glob/glob.go
@@ -21,6 +21,7 @@ import (
"strings"
"github.com/google/blueprint/deptools"
+ "github.com/google/blueprint/pathtools"
)
func IsGlob(glob string) bool {
@@ -36,55 +37,11 @@ func IsGlob(glob string) bool {
//
// Returns a list of file paths, and an error.
func GlobWithDepFile(glob, fileListFile, depFile string, excludes []string) (files []string, err error) {
- globPattern := filepath.Base(glob)
- globDir := filepath.Dir(glob)
- recursive := false
-
- if filepath.Base(globDir) == "**" {
- recursive = true
- globDir = filepath.Dir(globDir)
+ files, dirs, err := pathtools.GlobWithExcludes(glob, excludes)
+ if err != nil {
+ return nil, err
}
- var dirs []string
-
- err = filepath.Walk(globDir,
- func(path string, info os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- if info.Mode().IsDir() {
- dirs = append(dirs, path)
- if !recursive && path != globDir {
- return filepath.SkipDir
- }
- } else if info.Mode().IsRegular() {
- match, err := filepath.Match(globPattern, info.Name())
- if err != nil {
- return err
- }
- if match {
- for _, e := range excludes {
- var excludeMatch bool
- if filepath.Base(e) == e {
- excludeMatch, err = filepath.Match(e, info.Name())
- } else {
- excludeMatch, err = filepath.Match(e, path)
- }
- if err != nil {
- return err
- }
- if excludeMatch {
- return nil
- }
- }
- files = append(files, path)
- }
- }
-
- return nil
- })
-
fileList := strings.Join(files, "\n") + "\n"
writeFileIfChanged(fileListFile, []byte(fileList), 0666)