diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-06-30 18:15:24 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-07-01 20:59:39 +0000 |
commit | 2ef08f4458aaeb1cf69a167107d52a2ca22ba3f3 (patch) | |
tree | e315609987dd9b06d1d85f379149e2b64e7bac5d /common | |
parent | c41f63071ebdb34fea48c11bc94b6e4a7e159c06 (diff) | |
download | build_soong-2ef08f4458aaeb1cf69a167107d52a2ca22ba3f3.tar.gz build_soong-2ef08f4458aaeb1cf69a167107d52a2ca22ba3f3.tar.bz2 build_soong-2ef08f4458aaeb1cf69a167107d52a2ca22ba3f3.zip |
Add exclude_* and remove arch_subtract / "-file"
To align with the current make build system, add exclude_srcs and
exclude_java_resource_dirs. These replace the functionality of
arch_subtract and glob exclusions that use "-file" to exclude a file.
Change-Id: I91c23d5e3c9409f2d9f7921f950153a03a68ad61
Diffstat (limited to 'common')
-rw-r--r-- | common/arch.go | 42 | ||||
-rw-r--r-- | common/module.go | 39 |
2 files changed, 23 insertions, 58 deletions
diff --git a/common/arch.go b/common/arch.go index ba1f6712..60a17e44 100644 --- a/common/arch.go +++ b/common/arch.go @@ -628,12 +628,7 @@ func (a *AndroidModuleBase) extendPropertiesRecursive(ctx blueprint.EarlyMutator dstFieldValue, srcFieldValue, newRecursePrefix) case reflect.Slice: - val, err := archCombineSlices(dstFieldValue, srcFieldValue, tags["arch_subtract"]) - if err != nil { - ctx.PropertyErrorf(propertyName, err.Error()) - continue - } - dstFieldValue.Set(val) + dstFieldValue.Set(reflect.AppendSlice(dstFieldValue, srcFieldValue)) case reflect.Ptr, reflect.Interface: // Recursively extend the pointed-to struct's fields. if dstFieldValue.IsNil() != srcFieldValue.IsNil() { @@ -654,38 +649,3 @@ func (a *AndroidModuleBase) extendPropertiesRecursive(ctx blueprint.EarlyMutator } } } - -func archCombineSlices(general, arch reflect.Value, canSubtract bool) (reflect.Value, error) { - if !canSubtract { - // Append the extension slice. - return reflect.AppendSlice(general, arch), nil - } - - // Support -val in arch list to subtract a value from original list - l := general.Interface().([]string) - for archIndex := 0; archIndex < arch.Len(); archIndex++ { - archString := arch.Index(archIndex).String() - if strings.HasPrefix(archString, "-") { - generalIndex := findStringInSlice(archString[1:], l) - if generalIndex == -1 { - return reflect.Value{}, - fmt.Errorf("can't find %q to subtract from general properties", archString[1:]) - } - l = append(l[:generalIndex], l[generalIndex+1:]...) - } else { - l = append(l, archString) - } - } - - return reflect.ValueOf(l), nil -} - -func findStringInSlice(str string, slice []string) int { - for i, s := range slice { - if s == str { - return i - } - } - - return -1 -} diff --git a/common/module.go b/common/module.go index 77e02952..1d17de10 100644 --- a/common/module.go +++ b/common/module.go @@ -53,7 +53,7 @@ type AndroidModuleContext interface { blueprint.ModuleContext androidBaseContext - ExpandSources(srcFiles []string) []string + ExpandSources(srcFiles, excludes []string) []string Glob(globPattern string, excludes []string) []string InstallFile(installPath, srcPath string, deps ...string) string @@ -472,32 +472,37 @@ func isAndroidModule(m blueprint.Module) bool { return ok } -func (ctx *androidModuleContext) ExpandSources(srcFiles []string) []string { +func findStringInSlice(str string, slice []string) int { + for i, s := range slice { + if s == str { + return i + } + } + return -1 +} + +func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []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) + for i, e := range excludes { + j := findStringInSlice(e, srcFiles) + if j != -1 { + srcFiles = append(srcFiles[:j], srcFiles[j+1:]...) } + + excludes[i] = filepath.Join(prefix, e) } - if !hasGlob(srcFiles) { - return srcFiles + for i, srcFile := range srcFiles { + srcFiles[i] = filepath.Join(prefix, srcFile) } - var excludes []string - for _, s := range srcFiles { - if s[0] == '-' { - excludes = append(excludes, s[1:]) - } + if !hasGlob(srcFiles) { + return srcFiles } globbedSrcFiles := make([]string, 0, len(srcFiles)) for _, s := range srcFiles { - if s[0] == '-' { - continue - } else if glob.IsGlob(s) { + if glob.IsGlob(s) { globbedSrcFiles = append(globbedSrcFiles, ctx.Glob(s, excludes)...) } else { globbedSrcFiles = append(globbedSrcFiles, s) |