Allow paths containing glob characters in glob results

Some paths contain glob characters.  For now allow paths with glob
characters as long as they are in glob results.  In the future we
may need to allow escaping glob characters.

Test: m checkbuild
Test: paths_test.go
Change-Id: I1cbeea658e8fc4975ca0b6a50a8c24ac2de026c5
This commit is contained in:
Colin Cross 2018-08-15 20:18:53 -07:00
parent 331a1213b0
commit e3924e180b
1 changed files with 24 additions and 5 deletions

View File

@ -245,7 +245,17 @@ func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bo
reportPathErrorf(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)
continue
}
ret = append(ret, PathForModuleSrc(ctx, path[len(prefix):]))
srcPath, err := pathForSource(ctx, ctx.ModuleDir(), path[len(prefix):])
if err != nil {
reportPathError(ctx, err)
continue
}
moduleSrcPath := ModuleSrcPath{srcPath}
moduleSrcPath.basePath.rel = srcPath.path
ret = append(ret, moduleSrcPath)
}
return ret
}
@ -529,10 +539,6 @@ func pathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error
return ret, fmt.Errorf("source path %s is in output", abs)
}
if pathtools.IsGlob(ret.String()) {
return ret, fmt.Errorf("path may not contain a glob: %s", ret.String())
}
return ret, nil
}
@ -569,6 +575,10 @@ func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
reportPathError(ctx, err)
}
if pathtools.IsGlob(path.String()) {
reportPathErrorf(ctx, "path may not contain a glob: %s", path.String())
}
if modCtx, ok := ctx.(ModuleContext); ok && ctx.Config().AllowMissingDependencies() {
exists, err := existsWithDependencies(ctx, path)
if err != nil {
@ -595,6 +605,11 @@ func ExistentPathForSource(ctx PathContext, pathComponents ...string) OptionalPa
return OptionalPath{}
}
if pathtools.IsGlob(path.String()) {
reportPathErrorf(ctx, "path may not contain a glob: %s", path.String())
return OptionalPath{}
}
exists, err := existsWithDependencies(ctx, path)
if err != nil {
reportPathError(ctx, err)
@ -774,6 +789,10 @@ func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath {
reportPathError(ctx, err)
}
if pathtools.IsGlob(srcPath.String()) {
reportPathErrorf(ctx, "path may not contain a glob: %s", srcPath.String())
}
path := ModuleSrcPath{srcPath}
path.basePath.rel = p