Turn GlobFiles into a Glob for files, use it
am: 540a78c1ce
Change-Id: Ia5811eb2fe2db20d4ab8e554341b875392cc345a
This commit is contained in:
@@ -1220,7 +1220,7 @@ func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string
|
|||||||
ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
|
ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
|
||||||
}
|
}
|
||||||
} else if pathtools.IsGlob(s) {
|
} else if pathtools.IsGlob(s) {
|
||||||
globbedSrcFiles := ctx.Glob(filepath.Join(prefix, s), expandedExcludes)
|
globbedSrcFiles := ctx.GlobFiles(filepath.Join(prefix, s), expandedExcludes)
|
||||||
for i, s := range globbedSrcFiles {
|
for i, s := range globbedSrcFiles {
|
||||||
globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
||||||
}
|
}
|
||||||
@@ -1246,25 +1246,15 @@ func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Pat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ModuleErrorf("glob: %s", err.Error())
|
ctx.ModuleErrorf("glob: %s", err.Error())
|
||||||
}
|
}
|
||||||
return pathsForModuleSrcFromFullPath(ctx, ret)
|
return pathsForModuleSrcFromFullPath(ctx, ret, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// glob only "files" under the directory relative to top of the source tree.
|
|
||||||
func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
||||||
paths, err := ctx.GlobWithDeps(globPattern, excludes)
|
ret, err := ctx.GlobWithDeps(globPattern, excludes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ModuleErrorf("glob: %s", err.Error())
|
ctx.ModuleErrorf("glob: %s", err.Error())
|
||||||
}
|
}
|
||||||
var ret []Path
|
return pathsForModuleSrcFromFullPath(ctx, ret, false)
|
||||||
for _, p := range paths {
|
|
||||||
if isDir, err := ctx.Fs().IsDir(p); err != nil {
|
|
||||||
ctx.ModuleErrorf("error in IsDir(%s): %s", p, err.Error())
|
|
||||||
return nil
|
|
||||||
} else if !isDir {
|
|
||||||
ret = append(ret, PathForSource(ctx, p))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@@ -228,14 +228,17 @@ func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths {
|
|||||||
|
|
||||||
// pathsForModuleSrcFromFullPath returns Paths rooted from the module's local
|
// pathsForModuleSrcFromFullPath returns Paths rooted from the module's local
|
||||||
// source directory, but strip the local source directory from the beginning of
|
// source directory, but strip the local source directory from the beginning of
|
||||||
// each string.
|
// each string. If incDirs is false, strip paths with a trailing '/' from the list.
|
||||||
func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
|
func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bool) Paths {
|
||||||
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
|
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
|
||||||
if prefix == "./" {
|
if prefix == "./" {
|
||||||
prefix = ""
|
prefix = ""
|
||||||
}
|
}
|
||||||
ret := make(Paths, 0, len(paths))
|
ret := make(Paths, 0, len(paths))
|
||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
|
if !incDirs && strings.HasSuffix(p, "/") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
path := filepath.Clean(p)
|
path := filepath.Clean(p)
|
||||||
if !strings.HasPrefix(path, prefix) {
|
if !strings.HasPrefix(path, prefix) {
|
||||||
reportPathErrorf(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)
|
reportPathErrorf(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)
|
||||||
|
@@ -100,7 +100,7 @@ func (stub *llndkStubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
|
|
||||||
func (stub *llndkStubDecorator) processHeaders(ctx ModuleContext, srcHeaderDir string, outDir android.ModuleGenPath) android.Path {
|
func (stub *llndkStubDecorator) processHeaders(ctx ModuleContext, srcHeaderDir string, outDir android.ModuleGenPath) android.Path {
|
||||||
srcDir := android.PathForModuleSrc(ctx, srcHeaderDir)
|
srcDir := android.PathForModuleSrc(ctx, srcHeaderDir)
|
||||||
srcFiles := ctx.Glob(filepath.Join(srcDir.String(), "**/*.h"), nil)
|
srcFiles := ctx.GlobFiles(filepath.Join(srcDir.String(), "**/*.h"), nil)
|
||||||
|
|
||||||
var installPaths []android.WritablePath
|
var installPaths []android.WritablePath
|
||||||
for _, header := range srcFiles {
|
for _, header := range srcFiles {
|
||||||
|
@@ -202,7 +202,7 @@ func (m *preprocessedHeaderModule) GenerateAndroidBuildActions(ctx android.Modul
|
|||||||
|
|
||||||
fromSrcPath := android.PathForModuleSrc(ctx, String(m.properties.From))
|
fromSrcPath := android.PathForModuleSrc(ctx, String(m.properties.From))
|
||||||
toOutputPath := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To))
|
toOutputPath := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To))
|
||||||
srcFiles := ctx.Glob(filepath.Join(fromSrcPath.String(), "**/*.h"), nil)
|
srcFiles := ctx.GlobFiles(filepath.Join(fromSrcPath.String(), "**/*.h"), nil)
|
||||||
var installPaths []android.WritablePath
|
var installPaths []android.WritablePath
|
||||||
for _, header := range srcFiles {
|
for _, header := range srcFiles {
|
||||||
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From), String(m.properties.To))
|
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From), String(m.properties.To))
|
||||||
|
17
java/app.go
17
java/app.go
@@ -342,17 +342,7 @@ func AndroidAppFactory() android.Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resourceGlob(ctx android.ModuleContext, dir android.Path) android.Paths {
|
func resourceGlob(ctx android.ModuleContext, dir android.Path) android.Paths {
|
||||||
var ret android.Paths
|
return ctx.GlobFiles(filepath.Join(dir.String(), "**/*"), aaptIgnoreFilenames)
|
||||||
files := ctx.Glob(filepath.Join(dir.String(), "**/*"), aaptIgnoreFilenames)
|
|
||||||
for _, f := range files {
|
|
||||||
if isDir, err := ctx.Fs().IsDir(f.String()); err != nil {
|
|
||||||
ctx.ModuleErrorf("error in IsDir(%s): %s", f.String(), err.Error())
|
|
||||||
return nil
|
|
||||||
} else if !isDir {
|
|
||||||
ret = append(ret, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type overlayGlobResult struct {
|
type overlayGlobResult struct {
|
||||||
@@ -440,10 +430,7 @@ func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
}
|
}
|
||||||
var paths android.Paths
|
var paths android.Paths
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if isDir, err := ctx.Fs().IsDir(f); err != nil {
|
if !strings.HasSuffix(f, "/") {
|
||||||
ctx.Errorf("error in IsDir(%s): %s", f, err.Error())
|
|
||||||
return
|
|
||||||
} else if !isDir {
|
|
||||||
paths = append(paths, android.PathForSource(ctx, f))
|
paths = append(paths, android.PathForSource(ctx, f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user