Remove ExpandSourcesSubDir and ModuleSrcPath.WithSubDir
Replace ExpandSourcesSubDir with ExpandSources plus
PathsWithModuleSrcSubDir, which loops over the paths and uses
Join to create paths relative to subdir on any results that
are ModuleSrcPaths.
Test: All soong tests
Change-Id: I11a7face88641e2c26ccdca0a3117d5c38ab588e
diff --git a/android/module.go b/android/module.go
index 9a69a26..dfeb45d 100644
--- a/android/module.go
+++ b/android/module.go
@@ -117,7 +117,6 @@
ExpandSources(srcFiles, excludes []string) Paths
ExpandSource(srcFile, prop string) Path
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
- ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths
Glob(globPattern string, excludes []string) Paths
GlobFiles(globPattern string, excludes []string) Paths
@@ -1421,39 +1420,6 @@
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
// be tagged with `android:"path" to support automatic source module dependency resolution.
func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
- return ctx.ExpandSourcesSubDir(srcFiles, excludes, "")
-}
-
-// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
-// be tagged with `android:"path" to support automatic source module dependency resolution.
-func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path {
- srcFiles := ctx.ExpandSourcesSubDir([]string{srcFile}, nil, "")
- if len(srcFiles) == 1 {
- return srcFiles[0]
- } else if len(srcFiles) == 0 {
- if ctx.Config().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{srcFile})
- } else {
- ctx.PropertyErrorf(prop, "%s path %s does not exist", prop, srcFile)
- }
- return nil
- } else {
- ctx.PropertyErrorf(prop, "module providing %s must produce exactly one file", prop)
- return nil
- }
-}
-
-// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
-// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
-// dependency resolution.
-func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
- if srcFile != nil {
- return OptionalPathForPath(ctx.ExpandSource(*srcFile, prop))
- }
- return OptionalPath{}
-}
-
-func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths {
prefix := PathForModuleSrc(ctx).String()
var expandedExcludes []string
@@ -1508,22 +1474,48 @@
}
} else if pathtools.IsGlob(s) {
globbedSrcFiles := ctx.GlobFiles(filepath.Join(prefix, s), expandedExcludes)
- for i, s := range globbedSrcFiles {
- globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
- }
+ globbedSrcFiles = PathsWithModuleSrcSubDir(ctx, globbedSrcFiles, "")
expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
} else {
- p := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
+ p := PathForModuleSrc(ctx, s)
j := findStringInSlice(p.String(), expandedExcludes)
if j == -1 {
expandedSrcFiles = append(expandedSrcFiles, p)
}
-
}
}
return expandedSrcFiles
}
+// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
+// be tagged with `android:"path" to support automatic source module dependency resolution.
+func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path {
+ srcFiles := ctx.ExpandSources([]string{srcFile}, nil)
+ if len(srcFiles) == 1 {
+ return srcFiles[0]
+ } else if len(srcFiles) == 0 {
+ if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{srcFile})
+ } else {
+ ctx.PropertyErrorf(prop, "%s path %s does not exist", prop, srcFile)
+ }
+ return nil
+ } else {
+ ctx.PropertyErrorf(prop, "module providing %s must produce exactly one file", prop)
+ return nil
+ }
+}
+
+// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
+// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
+// dependency resolution.
+func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
+ if srcFile != nil {
+ return OptionalPathForPath(ctx.ExpandSource(*srcFile, prop))
+ }
+ return OptionalPath{}
+}
+
func (ctx *androidModuleContext) RequiredModuleNames() []string {
return ctx.module.base().commonProperties.Required
}