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
This commit is contained in:
Dan Willemsen
2015-06-30 18:15:24 -07:00
parent c41f63071e
commit 2ef08f4458
7 changed files with 62 additions and 76 deletions

View File

@@ -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 {
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)
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, e := range excludes {
j := findStringInSlice(e, srcFiles)
if j != -1 {
srcFiles = append(srcFiles[:j], srcFiles[j+1:]...)
}
excludes[i] = filepath.Join(prefix, e)
}
for i, srcFile := range srcFiles {
srcFiles[i] = filepath.Join(prefix, srcFile)
}
if !hasGlob(srcFiles) {
return srcFiles
}
var excludes []string
for _, s := range srcFiles {
if s[0] == '-' {
excludes = append(excludes, s[1:])
}
}
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)