aboutsummaryrefslogtreecommitdiffstats
path: root/common/glob.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-06-17 15:09:06 -0700
committerColin Cross <ccross@android.com>2015-06-17 15:36:48 -0700
commit8f101b45fc876b63f2a556c5b19801dbc8ac5fdc (patch)
tree2be41986a7a55669b2a6632f84685c6a46e343a8 /common/glob.go
parent1f8c52be73d31f3347bcf7f8fb29b49e87b3864e (diff)
downloadbuild_soong-8f101b45fc876b63f2a556c5b19801dbc8ac5fdc.tar.gz
build_soong-8f101b45fc876b63f2a556c5b19801dbc8ac5fdc.tar.bz2
build_soong-8f101b45fc876b63f2a556c5b19801dbc8ac5fdc.zip
Allow common.Glob to be called by singletons
Make common.Glob take an interface that is the intersection of blueprint.ModuleContext and blueprint.SingletonContext used by Glob and GlobRule, allowing it to be called on either. Also move ExpandSources and Glob into AndroidModuleContext. Change-Id: I8d1a3160c5dd201033afdb37210e82d8065b137d
Diffstat (limited to 'common/glob.go')
-rw-r--r--common/glob.go39
1 files changed, 9 insertions, 30 deletions
diff --git a/common/glob.go b/common/glob.go
index 669d1857..d63f87a2 100644
--- a/common/glob.go
+++ b/common/glob.go
@@ -66,41 +66,20 @@ func hasGlob(in []string) bool {
return false
}
-func expandGlobs(ctx AndroidModuleContext, in []string) []string {
- if !hasGlob(in) {
- return in
- }
-
- var excludes []string
- for _, s := range in {
- if s[0] == '-' {
- excludes = append(excludes, s[1:])
- }
- }
-
- out := make([]string, 0, len(in))
- for _, s := range in {
- if s[0] == '-' {
- continue
- } else if glob.IsGlob(s) {
- out = append(out, Glob(ctx, s, excludes)...)
- } else {
- out = append(out, s)
- }
- }
-
- return out
+// The subset of ModuleContext and SingletonContext needed by Glob
+type globContext interface {
+ Build(pctx *blueprint.PackageContext, params blueprint.BuildParams)
+ AddNinjaFileDeps(deps ...string)
}
-func Glob(ctx AndroidModuleContext, globPattern string, excludes []string) []string {
- fileListFile := filepath.Join(ModuleOutDir(ctx), "glob", globToString(globPattern))
+func Glob(ctx globContext, outDir string, globPattern string, excludes []string) ([]string, error) {
+ fileListFile := filepath.Join(outDir, "glob", globToString(globPattern))
depFile := fileListFile + ".d"
// Get a globbed file list, and write out fileListFile and depFile
files, err := glob.GlobWithDepFile(globPattern, fileListFile, depFile, excludes)
if err != nil {
- ctx.ModuleErrorf("glob: %s", err.Error())
- return []string{globPattern}
+ return nil, err
}
GlobRule(ctx, globPattern, excludes, fileListFile, depFile)
@@ -108,10 +87,10 @@ func Glob(ctx AndroidModuleContext, globPattern string, excludes []string) []str
// Make build.ninja depend on the fileListFile
ctx.AddNinjaFileDeps(fileListFile)
- return files
+ return files, nil
}
-func GlobRule(ctx AndroidModuleContext, globPattern string, excludes []string,
+func GlobRule(ctx globContext, globPattern string, excludes []string,
fileListFile, depFile string) {
// Create a rule to rebuild fileListFile if a directory in depFile changes. fileListFile