aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-04-08 11:21:40 -0700
committerColin Cross <ccross@android.com>2015-04-08 15:19:30 -0700
commitfce532760f1d22c23df764aefbd3e08592c76105 (patch)
treef11f10e878c4634e489543625989187b750afb99 /common
parent1332b0035caf416d4d9b275e6bfead48fe0b9cac (diff)
downloadbuild_soong-fce532760f1d22c23df764aefbd3e08592c76105.tar.gz
build_soong-fce532760f1d22c23df764aefbd3e08592c76105.tar.bz2
build_soong-fce532760f1d22c23df764aefbd3e08592c76105.zip
Support subtracting sources from globs
Support -file or -path/glob in file lists that contain globs to subtract files from the resulting glob. Also move source file prefixing and handling into a common function. Change-Id: Ib6d74ce22f53cae7348c4ba35b779976d90359a6
Diffstat (limited to 'common')
-rw-r--r--common/glob.go17
-rw-r--r--common/module.go14
2 files changed, 25 insertions, 6 deletions
diff --git a/common/glob.go b/common/glob.go
index a3cfab26..7bb623df 100644
--- a/common/glob.go
+++ b/common/glob.go
@@ -68,16 +68,23 @@ func hasGlob(in []string) bool {
return false
}
-func ExpandGlobs(ctx AndroidModuleContext, in []string) []string {
+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 glob.IsGlob(s) {
- out = append(out, Glob(ctx, s)...)
- } else {
+ out = append(out, Glob(ctx, s, excludes)...)
+ } else if s[0] != '-' {
out = append(out, s)
}
}
@@ -85,12 +92,10 @@ func ExpandGlobs(ctx AndroidModuleContext, in []string) []string {
return out
}
-func Glob(ctx AndroidModuleContext, globPattern string) []string {
+func Glob(ctx AndroidModuleContext, globPattern string, excludes []string) []string {
fileListFile := filepath.Join(ModuleOutDir(ctx), "glob", globToString(globPattern))
depFile := fileListFile + ".d"
- var excludes []string
-
// Get a globbed file list, and write out fileListFile and depFile
files, err := glob.GlobWithDepFile(globPattern, fileListFile, depFile, excludes)
if err != nil {
diff --git a/common/module.go b/common/module.go
index d4970760..bafb583f 100644
--- a/common/module.go
+++ b/common/module.go
@@ -432,3 +432,17 @@ func isAndroidModule(m blueprint.Module) bool {
_, ok := m.(AndroidModule)
return ok
}
+
+func ExpandSources(ctx AndroidModuleContext, srcFiles []string) []string {
+ prefix := ModuleSrcDir(ctx)
+ for i, srcFile := range srcFiles {
+ if srcFile[0] == '-' {
+ srcFiles[i] = "-" + filepath.Join(prefix, srcFile[1:])
+ } else {
+ srcFiles[i] = filepath.Join(prefix, srcFile)
+ }
+ }
+
+ srcFiles = expandGlobs(ctx, srcFiles)
+ return srcFiles
+}