diff options
author | Dan Willemsen <dwillemsen@google.com> | 2018-02-26 21:50:08 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2018-03-01 14:05:20 -0800 |
commit | 540a78c1ce0519b8085a5f5388474b0a3a4350b1 (patch) | |
tree | 1a93fb7a4a5a75c9758c085f723f598479ac13d7 /android | |
parent | f6366cc0a1ffdb894c886ebacf10d65f06a6226c (diff) | |
download | build_soong-540a78c1ce0519b8085a5f5388474b0a3a4350b1.tar.gz build_soong-540a78c1ce0519b8085a5f5388474b0a3a4350b1.tar.bz2 build_soong-540a78c1ce0519b8085a5f5388474b0a3a4350b1.zip |
Turn GlobFiles into a Glob for files, use it
GlobFiles had allowed results to be anywhere in the source tree,
restrict it to results within the current module directory.
Then use it for ExpandSources and other places where we only want files.
This fixes using '*' in cc_test's `data` property, which can only
support files.
The only thing this changes today is that java_resource_dirs and
java_resources no longer pass directories to soong_zip's -f argument.
core-libart previously added some icu directories, now it only passes
files.
Bug: 71906438
Test: only expected changes in out/soong/build.ninja
Test: add data: ["**/*"] to a cc_test, build successfully
Change-Id: Iff1bd8c005a48e431c740706d7e23f4f957d8b1d
Diffstat (limited to 'android')
-rw-r--r-- | android/module.go | 18 | ||||
-rw-r--r-- | android/paths.go | 7 |
2 files changed, 9 insertions, 16 deletions
diff --git a/android/module.go b/android/module.go index 07c4e8fc..4a8e8acf 100644 --- a/android/module.go +++ b/android/module.go @@ -1220,7 +1220,7 @@ func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m) } } 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 { globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir) } @@ -1246,25 +1246,15 @@ func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Pat if err != nil { 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 { - paths, err := ctx.GlobWithDeps(globPattern, excludes) + ret, err := ctx.GlobWithDeps(globPattern, excludes) if err != nil { ctx.ModuleErrorf("glob: %s", err.Error()) } - var ret []Path - 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 + return pathsForModuleSrcFromFullPath(ctx, ret, false) } func init() { diff --git a/android/paths.go b/android/paths.go index 3b1cea67..ffdb3935 100644 --- a/android/paths.go +++ b/android/paths.go @@ -228,14 +228,17 @@ func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths { // pathsForModuleSrcFromFullPath returns Paths rooted from the module's local // source directory, but strip the local source directory from the beginning of -// each string. -func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths { +// each string. If incDirs is false, strip paths with a trailing '/' from the list. +func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bool) Paths { prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/" if prefix == "./" { prefix = "" } ret := make(Paths, 0, len(paths)) for _, p := range paths { + if !incDirs && strings.HasSuffix(p, "/") { + continue + } path := filepath.Clean(p) if !strings.HasPrefix(path, prefix) { reportPathErrorf(ctx, "Path '%s' is not in module source directory '%s'", p, prefix) |