2015-01-31 02:27:36 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
package android
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
import (
|
2015-07-15 03:55:36 +02:00
|
|
|
"fmt"
|
2015-06-17 01:38:10 +02:00
|
|
|
"path/filepath"
|
2015-09-24 00:26:20 +02:00
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
|
|
|
"github.com/google/blueprint/pathtools"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// PathContext is the subset of a (Module|Singleton)Context required by the
|
|
|
|
// Path methods.
|
|
|
|
type PathContext interface {
|
2017-02-01 23:10:36 +01:00
|
|
|
Fs() pathtools.FileSystem
|
2015-09-24 00:26:20 +02:00
|
|
|
Config() interface{}
|
2015-12-19 00:11:17 +01:00
|
|
|
AddNinjaFileDeps(deps ...string)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-11-01 19:10:25 +01:00
|
|
|
type PathGlobContext interface {
|
|
|
|
GlobWithDeps(globPattern string, excludes []string) ([]string, error)
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
var _ PathContext = blueprint.SingletonContext(nil)
|
|
|
|
var _ PathContext = blueprint.ModuleContext(nil)
|
|
|
|
|
2017-07-07 01:59:48 +02:00
|
|
|
type ModuleInstallPathContext interface {
|
|
|
|
PathContext
|
|
|
|
|
|
|
|
androidBaseContext
|
|
|
|
|
|
|
|
InstallInData() bool
|
|
|
|
InstallInSanitizerDir() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ModuleInstallPathContext = ModuleContext(nil)
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// errorfContext is the interface containing the Errorf method matching the
|
|
|
|
// Errorf method in blueprint.SingletonContext.
|
|
|
|
type errorfContext interface {
|
|
|
|
Errorf(format string, args ...interface{})
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
var _ errorfContext = blueprint.SingletonContext(nil)
|
|
|
|
|
|
|
|
// moduleErrorf is the interface containing the ModuleErrorf method matching
|
|
|
|
// the ModuleErrorf method in blueprint.ModuleContext.
|
|
|
|
type moduleErrorf interface {
|
|
|
|
ModuleErrorf(format string, args ...interface{})
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ moduleErrorf = blueprint.ModuleContext(nil)
|
|
|
|
|
|
|
|
// pathConfig returns the android Config interface associated to the context.
|
|
|
|
// Panics if the context isn't affiliated with an android build.
|
|
|
|
func pathConfig(ctx PathContext) Config {
|
|
|
|
if ret, ok := ctx.Config().(Config); ok {
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
panic("Paths may only be used on Soong builds")
|
|
|
|
}
|
|
|
|
|
|
|
|
// reportPathError will register an error with the attached context. It
|
|
|
|
// attempts ctx.ModuleErrorf for a better error message first, then falls
|
|
|
|
// back to ctx.Errorf.
|
|
|
|
func reportPathError(ctx PathContext, format string, args ...interface{}) {
|
|
|
|
if mctx, ok := ctx.(moduleErrorf); ok {
|
|
|
|
mctx.ModuleErrorf(format, args...)
|
|
|
|
} else if ectx, ok := ctx.(errorfContext); ok {
|
|
|
|
ectx.Errorf(format, args...)
|
|
|
|
} else {
|
|
|
|
panic(fmt.Sprintf(format, args...))
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
type Path interface {
|
|
|
|
// Returns the path in string form
|
|
|
|
String() string
|
|
|
|
|
2016-10-26 19:05:25 +02:00
|
|
|
// Ext returns the extension of the last element of the path
|
2015-09-24 00:26:20 +02:00
|
|
|
Ext() string
|
2016-10-26 19:05:25 +02:00
|
|
|
|
|
|
|
// Base returns the last element of the path
|
|
|
|
Base() string
|
2017-02-01 23:12:44 +01:00
|
|
|
|
|
|
|
// Rel returns the portion of the path relative to the directory it was created from. For
|
|
|
|
// example, Rel on a PathsForModuleSrc would return the path relative to the module source
|
|
|
|
// directory.
|
|
|
|
Rel() string
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// WritablePath is a type of path that can be used as an output for build rules.
|
|
|
|
type WritablePath interface {
|
|
|
|
Path
|
|
|
|
|
2017-04-11 00:47:24 +02:00
|
|
|
// the writablePath method doesn't directly do anything,
|
|
|
|
// but it allows a struct to distinguish between whether or not it implements the WritablePath interface
|
2015-09-24 00:26:20 +02:00
|
|
|
writablePath()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
type genPathProvider interface {
|
2016-11-03 04:43:13 +01:00
|
|
|
genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
type objPathProvider interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
type resPathProvider interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
resPathWithName(ctx ModuleContext, name string) ModuleResPath
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// GenPathWithExt derives a new file path in ctx's generated sources directory
|
|
|
|
// from the current path, but with the new extension.
|
2016-11-03 04:43:13 +01:00
|
|
|
func GenPathWithExt(ctx ModuleContext, subdir string, p Path, ext string) ModuleGenPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
if path, ok := p.(genPathProvider); ok {
|
2016-11-03 04:43:13 +01:00
|
|
|
return path.genPathWithExt(ctx, subdir, ext)
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
reportPathError(ctx, "Tried to create generated file from unsupported path: %s(%s)", reflect.TypeOf(p).Name(), p)
|
|
|
|
return PathForModuleGen(ctx)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// ObjPathWithExt derives a new file path in ctx's object directory from the
|
|
|
|
// current path, but with the new extension.
|
2016-11-03 04:43:13 +01:00
|
|
|
func ObjPathWithExt(ctx ModuleContext, subdir string, p Path, ext string) ModuleObjPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
if path, ok := p.(objPathProvider); ok {
|
|
|
|
return path.objPathWithExt(ctx, subdir, ext)
|
|
|
|
}
|
|
|
|
reportPathError(ctx, "Tried to create object file from unsupported path: %s (%s)", reflect.TypeOf(p).Name(), p)
|
|
|
|
return PathForModuleObj(ctx)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// ResPathWithName derives a new path in ctx's output resource directory, using
|
|
|
|
// the current path to create the directory name, and the `name` argument for
|
|
|
|
// the filename.
|
2016-05-19 00:37:25 +02:00
|
|
|
func ResPathWithName(ctx ModuleContext, p Path, name string) ModuleResPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
if path, ok := p.(resPathProvider); ok {
|
|
|
|
return path.resPathWithName(ctx, name)
|
|
|
|
}
|
2017-04-11 00:47:24 +02:00
|
|
|
reportPathError(ctx, "Tried to create res file from unsupported path: %s (%s)", reflect.TypeOf(p).Name(), p)
|
2015-09-24 00:26:20 +02:00
|
|
|
return PathForModuleRes(ctx)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// OptionalPath is a container that may or may not contain a valid Path.
|
|
|
|
type OptionalPath struct {
|
|
|
|
valid bool
|
|
|
|
path Path
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2015-05-12 20:36:53 +02:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// OptionalPathForPath returns an OptionalPath containing the path.
|
|
|
|
func OptionalPathForPath(path Path) OptionalPath {
|
|
|
|
if path == nil {
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
return OptionalPath{valid: true, path: path}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Valid returns whether there is a valid path
|
|
|
|
func (p OptionalPath) Valid() bool {
|
|
|
|
return p.valid
|
|
|
|
}
|
|
|
|
|
|
|
|
// Path returns the Path embedded in this OptionalPath. You must be sure that
|
|
|
|
// there is a valid path, since this method will panic if there is not.
|
|
|
|
func (p OptionalPath) Path() Path {
|
|
|
|
if !p.valid {
|
|
|
|
panic("Requesting an invalid path")
|
|
|
|
}
|
|
|
|
return p.path
|
|
|
|
}
|
|
|
|
|
|
|
|
// String returns the string version of the Path, or "" if it isn't valid.
|
|
|
|
func (p OptionalPath) String() string {
|
|
|
|
if p.valid {
|
|
|
|
return p.path.String()
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paths is a slice of Path objects, with helpers to operate on the collection.
|
|
|
|
type Paths []Path
|
|
|
|
|
|
|
|
// PathsForSource returns Paths rooted from SrcDir
|
|
|
|
func PathsForSource(ctx PathContext, paths []string) Paths {
|
2016-03-12 00:02:46 +01:00
|
|
|
if pathConfig(ctx).AllowMissingDependencies() {
|
2016-05-19 00:37:25 +02:00
|
|
|
if modCtx, ok := ctx.(ModuleContext); ok {
|
2016-03-12 00:02:46 +01:00
|
|
|
ret := make(Paths, 0, len(paths))
|
2016-03-12 02:01:03 +01:00
|
|
|
intermediates := filepath.Join(modCtx.ModuleDir(), modCtx.ModuleName(), modCtx.ModuleSubDir(), "missing")
|
2016-03-12 00:02:46 +01:00
|
|
|
for _, path := range paths {
|
2017-04-11 00:47:24 +02:00
|
|
|
p := ExistentPathForSource(ctx, intermediates, path)
|
2016-03-12 00:02:46 +01:00
|
|
|
if p.Valid() {
|
|
|
|
ret = append(ret, p.Path())
|
|
|
|
} else {
|
|
|
|
modCtx.AddMissingDependencies([]string{path})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
ret := make(Paths, len(paths))
|
|
|
|
for i, path := range paths {
|
|
|
|
ret[i] = PathForSource(ctx, path)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2017-04-11 00:47:24 +02:00
|
|
|
// ExistentPathsForSources returns a list of Paths rooted from SrcDir that are
|
2015-12-19 00:11:17 +01:00
|
|
|
// found in the tree. If any are not found, they are omitted from the list,
|
|
|
|
// and dependencies are added so that we're re-run when they are added.
|
2017-04-11 00:47:24 +02:00
|
|
|
func ExistentPathsForSources(ctx PathContext, intermediates string, paths []string) Paths {
|
2015-12-19 00:11:17 +01:00
|
|
|
ret := make(Paths, 0, len(paths))
|
|
|
|
for _, path := range paths {
|
2017-04-11 00:47:24 +02:00
|
|
|
p := ExistentPathForSource(ctx, intermediates, path)
|
2015-12-19 00:11:17 +01:00
|
|
|
if p.Valid() {
|
|
|
|
ret = append(ret, p.Path())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// PathsForModuleSrc returns Paths rooted from the module's local source
|
|
|
|
// directory
|
2016-05-19 00:37:25 +02:00
|
|
|
func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths {
|
2015-09-24 00:26:20 +02:00
|
|
|
ret := make(Paths, len(paths))
|
|
|
|
for i, path := range paths {
|
|
|
|
ret[i] = PathForModuleSrc(ctx, path)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// pathsForModuleSrcFromFullPath returns Paths rooted from the module's local
|
|
|
|
// source directory, but strip the local source directory from the beginning of
|
|
|
|
// each string.
|
2016-05-19 00:37:25 +02:00
|
|
|
func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
|
2015-09-24 00:26:20 +02:00
|
|
|
prefix := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir()) + "/"
|
2017-09-28 02:42:05 +02:00
|
|
|
if prefix == "./" {
|
|
|
|
prefix = ""
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
ret := make(Paths, 0, len(paths))
|
|
|
|
for _, p := range paths {
|
|
|
|
path := filepath.Clean(p)
|
|
|
|
if !strings.HasPrefix(path, prefix) {
|
|
|
|
reportPathError(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)
|
|
|
|
continue
|
2015-05-12 20:36:53 +02:00
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
ret = append(ret, PathForModuleSrc(ctx, path[len(prefix):]))
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathsWithOptionalDefaultForModuleSrc returns Paths rooted from the module's
|
|
|
|
// local source directory. If none are provided, use the default if it exists.
|
2016-05-19 00:37:25 +02:00
|
|
|
func PathsWithOptionalDefaultForModuleSrc(ctx ModuleContext, input []string, def string) Paths {
|
2015-09-24 00:26:20 +02:00
|
|
|
if len(input) > 0 {
|
|
|
|
return PathsForModuleSrc(ctx, input)
|
2015-05-12 20:36:53 +02:00
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
// Use Glob so that if the default doesn't exist, a dependency is added so that when it
|
|
|
|
// is created, we're run again.
|
|
|
|
path := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir(), def)
|
2016-11-01 19:10:25 +01:00
|
|
|
return ctx.Glob(path, []string{})
|
2015-05-12 20:36:53 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// Strings returns the Paths in string form
|
|
|
|
func (p Paths) Strings() []string {
|
|
|
|
if p == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
ret := make([]string, len(p))
|
|
|
|
for i, path := range p {
|
|
|
|
ret[i] = path.String()
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2017-08-29 21:28:37 +02:00
|
|
|
// FirstUniqueElements returns all unique elements of a slice, keeping the first copy of each
|
|
|
|
// modifies the slice contents in place, and returns a subslice of the original slice
|
|
|
|
func FirstUniquePaths(list Paths) Paths {
|
|
|
|
k := 0
|
|
|
|
outer:
|
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
|
for j := 0; j < k; j++ {
|
|
|
|
if list[i] == list[j] {
|
|
|
|
continue outer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list[k] = list[i]
|
|
|
|
k++
|
|
|
|
}
|
|
|
|
return list[:k]
|
|
|
|
}
|
|
|
|
|
2017-08-15 22:34:18 +02:00
|
|
|
// HasExt returns true of any of the paths have extension ext, otherwise false
|
|
|
|
func (p Paths) HasExt(ext string) bool {
|
|
|
|
for _, path := range p {
|
|
|
|
if path.Ext() == ext {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// FilterByExt returns the subset of the paths that have extension ext
|
|
|
|
func (p Paths) FilterByExt(ext string) Paths {
|
|
|
|
ret := make(Paths, 0, len(p))
|
|
|
|
for _, path := range p {
|
|
|
|
if path.Ext() == ext {
|
|
|
|
ret = append(ret, path)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// FilterOutByExt returns the subset of the paths that do not have extension ext
|
|
|
|
func (p Paths) FilterOutByExt(ext string) Paths {
|
|
|
|
ret := make(Paths, 0, len(p))
|
|
|
|
for _, path := range p {
|
|
|
|
if path.Ext() != ext {
|
|
|
|
ret = append(ret, path)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// WritablePaths is a slice of WritablePaths, used for multiple outputs.
|
|
|
|
type WritablePaths []WritablePath
|
|
|
|
|
|
|
|
// Strings returns the string forms of the writable paths.
|
|
|
|
func (p WritablePaths) Strings() []string {
|
|
|
|
if p == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
ret := make([]string, len(p))
|
|
|
|
for i, path := range p {
|
|
|
|
ret[i] = path.String()
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
type basePath struct {
|
|
|
|
path string
|
|
|
|
config Config
|
2017-02-01 23:12:44 +01:00
|
|
|
rel string
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p basePath) Ext() string {
|
|
|
|
return filepath.Ext(p.path)
|
|
|
|
}
|
|
|
|
|
2016-10-26 19:05:25 +02:00
|
|
|
func (p basePath) Base() string {
|
|
|
|
return filepath.Base(p.path)
|
|
|
|
}
|
|
|
|
|
2017-02-01 23:12:44 +01:00
|
|
|
func (p basePath) Rel() string {
|
|
|
|
if p.rel != "" {
|
|
|
|
return p.rel
|
|
|
|
}
|
|
|
|
return p.path
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// SourcePath is a Path representing a file path rooted from SrcDir
|
|
|
|
type SourcePath struct {
|
|
|
|
basePath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = SourcePath{}
|
|
|
|
|
|
|
|
// safePathForSource is for paths that we expect are safe -- only for use by go
|
|
|
|
// code that is embedding ninja variables in paths
|
|
|
|
func safePathForSource(ctx PathContext, path string) SourcePath {
|
|
|
|
p := validateSafePath(ctx, path)
|
2017-02-01 23:12:44 +01:00
|
|
|
ret := SourcePath{basePath{p, pathConfig(ctx), ""}}
|
2015-09-24 00:26:20 +02:00
|
|
|
|
|
|
|
abs, err := filepath.Abs(ret.String())
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
buildroot, err := filepath.Abs(pathConfig(ctx).buildDir)
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(abs, buildroot) {
|
|
|
|
reportPathError(ctx, "source path %s is in output", abs)
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2017-04-11 00:47:24 +02:00
|
|
|
// PathForSource joins the provided path components and validates that the result
|
|
|
|
// neither escapes the source dir nor is in the out dir.
|
|
|
|
// On error, it will return a usable, but invalid SourcePath, and report a ModuleError.
|
|
|
|
func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
|
|
|
|
p := validatePath(ctx, pathComponents...)
|
2017-02-01 23:12:44 +01:00
|
|
|
ret := SourcePath{basePath{p, pathConfig(ctx), ""}}
|
2015-09-24 00:26:20 +02:00
|
|
|
|
|
|
|
abs, err := filepath.Abs(ret.String())
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
buildroot, err := filepath.Abs(pathConfig(ctx).buildDir)
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(abs, buildroot) {
|
|
|
|
reportPathError(ctx, "source path %s is in output", abs)
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2017-02-01 23:10:36 +01:00
|
|
|
if exists, _, err := ctx.Fs().Exists(ret.String()); err != nil {
|
|
|
|
reportPathError(ctx, "%s: %s", ret, err.Error())
|
|
|
|
} else if !exists {
|
|
|
|
reportPathError(ctx, "source path %s does not exist", ret)
|
2015-05-12 20:36:53 +02:00
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2017-04-11 00:47:24 +02:00
|
|
|
// ExistentPathForSource returns an OptionalPath with the SourcePath if the
|
2015-09-24 00:26:20 +02:00
|
|
|
// path exists, or an empty OptionalPath if it doesn't exist. Dependencies are added
|
|
|
|
// so that the ninja file will be regenerated if the state of the path changes.
|
2017-04-11 00:47:24 +02:00
|
|
|
func ExistentPathForSource(ctx PathContext, intermediates string, pathComponents ...string) OptionalPath {
|
|
|
|
if len(pathComponents) == 0 {
|
2015-12-19 00:11:17 +01:00
|
|
|
// For when someone forgets the 'intermediates' argument
|
|
|
|
panic("Missing path(s)")
|
|
|
|
}
|
|
|
|
|
2017-04-11 00:47:24 +02:00
|
|
|
p := validatePath(ctx, pathComponents...)
|
2017-02-01 23:12:44 +01:00
|
|
|
path := SourcePath{basePath{p, pathConfig(ctx), ""}}
|
2015-09-24 00:26:20 +02:00
|
|
|
|
|
|
|
abs, err := filepath.Abs(path.String())
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
buildroot, err := filepath.Abs(pathConfig(ctx).buildDir)
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(abs, buildroot) {
|
|
|
|
reportPathError(ctx, "source path %s is in output", abs)
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2016-11-01 19:10:25 +01:00
|
|
|
if pathtools.IsGlob(path.String()) {
|
2015-12-19 00:11:17 +01:00
|
|
|
reportPathError(ctx, "path may not contain a glob: %s", path.String())
|
2015-09-24 00:26:20 +02:00
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2016-11-01 19:10:25 +01:00
|
|
|
if gctx, ok := ctx.(PathGlobContext); ok {
|
2015-12-19 00:11:17 +01:00
|
|
|
// Use glob to produce proper dependencies, even though we only want
|
|
|
|
// a single file.
|
2016-11-01 19:10:25 +01:00
|
|
|
files, err := gctx.GlobWithDeps(path.String(), nil)
|
2015-12-19 00:11:17 +01:00
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "glob: %s", err.Error())
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(files) == 0 {
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We cannot add build statements in this context, so we fall back to
|
|
|
|
// AddNinjaFileDeps
|
2017-02-01 23:10:36 +01:00
|
|
|
files, dirs, err := pathtools.Glob(path.String(), nil)
|
2015-12-19 00:11:17 +01:00
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "glob: %s", err.Error())
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.AddNinjaFileDeps(dirs...)
|
|
|
|
|
|
|
|
if len(files) == 0 {
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.AddNinjaFileDeps(path.String())
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
return OptionalPathForPath(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p SourcePath) String() string {
|
|
|
|
return filepath.Join(p.config.srcDir, p.path)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Join creates a new SourcePath with paths... joined with the current path. The
|
|
|
|
// provided paths... may not use '..' to escape from the current path.
|
|
|
|
func (p SourcePath) Join(ctx PathContext, paths ...string) SourcePath {
|
|
|
|
path := validatePath(ctx, paths...)
|
|
|
|
return PathForSource(ctx, p.path, path)
|
2015-05-12 20:36:53 +02:00
|
|
|
}
|
2015-07-15 03:55:36 +02:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// OverlayPath returns the overlay for `path' if it exists. This assumes that the
|
|
|
|
// SourcePath is the path to a resource overlay directory.
|
2016-05-19 00:37:25 +02:00
|
|
|
func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
var relDir string
|
|
|
|
if moduleSrcPath, ok := path.(ModuleSrcPath); ok {
|
2017-02-01 23:07:55 +01:00
|
|
|
relDir = moduleSrcPath.path
|
2015-09-24 00:26:20 +02:00
|
|
|
} else if srcPath, ok := path.(SourcePath); ok {
|
|
|
|
relDir = srcPath.path
|
|
|
|
} else {
|
|
|
|
reportPathError(ctx, "Cannot find relative path for %s(%s)", reflect.TypeOf(path).Name(), path)
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
dir := filepath.Join(p.config.srcDir, p.path, relDir)
|
|
|
|
// Use Glob so that we are run again if the directory is added.
|
2016-11-01 19:10:25 +01:00
|
|
|
if pathtools.IsGlob(dir) {
|
2015-12-19 00:11:17 +01:00
|
|
|
reportPathError(ctx, "Path may not contain a glob: %s", dir)
|
|
|
|
}
|
2016-11-01 19:10:25 +01:00
|
|
|
paths, err := ctx.GlobWithDeps(dir, []string{})
|
2015-07-15 03:55:36 +02:00
|
|
|
if err != nil {
|
2015-09-24 00:26:20 +02:00
|
|
|
reportPathError(ctx, "glob: %s", err.Error())
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
if len(paths) == 0 {
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
relPath, err := filepath.Rel(p.config.srcDir, paths[0])
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, "%s", err.Error())
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
return OptionalPathForPath(PathForSource(ctx, relPath))
|
|
|
|
}
|
|
|
|
|
|
|
|
// OutputPath is a Path representing a file path rooted from the build directory
|
|
|
|
type OutputPath struct {
|
|
|
|
basePath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = OutputPath{}
|
|
|
|
|
2017-04-11 00:47:24 +02:00
|
|
|
// PathForOutput joins the provided paths and returns an OutputPath that is
|
|
|
|
// validated to not escape the build dir.
|
|
|
|
// On error, it will return a usable, but invalid OutputPath, and report a ModuleError.
|
|
|
|
func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath {
|
|
|
|
path := validatePath(ctx, pathComponents...)
|
2017-02-01 23:12:44 +01:00
|
|
|
return OutputPath{basePath{path, pathConfig(ctx), ""}}
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p OutputPath) writablePath() {}
|
|
|
|
|
|
|
|
func (p OutputPath) String() string {
|
|
|
|
return filepath.Join(p.config.buildDir, p.path)
|
|
|
|
}
|
|
|
|
|
2016-03-24 21:14:12 +01:00
|
|
|
func (p OutputPath) RelPathString() string {
|
|
|
|
return p.path
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// Join creates a new OutputPath with paths... joined with the current path. The
|
|
|
|
// provided paths... may not use '..' to escape from the current path.
|
|
|
|
func (p OutputPath) Join(ctx PathContext, paths ...string) OutputPath {
|
|
|
|
path := validatePath(ctx, paths...)
|
|
|
|
return PathForOutput(ctx, p.path, path)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathForIntermediates returns an OutputPath representing the top-level
|
|
|
|
// intermediates directory.
|
|
|
|
func PathForIntermediates(ctx PathContext, paths ...string) OutputPath {
|
|
|
|
path := validatePath(ctx, paths...)
|
|
|
|
return PathForOutput(ctx, ".intermediates", path)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModuleSrcPath is a Path representing a file rooted from a module's local source dir
|
|
|
|
type ModuleSrcPath struct {
|
2017-02-01 23:07:55 +01:00
|
|
|
SourcePath
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = ModuleSrcPath{}
|
|
|
|
var _ genPathProvider = ModuleSrcPath{}
|
|
|
|
var _ objPathProvider = ModuleSrcPath{}
|
|
|
|
var _ resPathProvider = ModuleSrcPath{}
|
|
|
|
|
|
|
|
// PathForModuleSrc returns a ModuleSrcPath representing the paths... under the
|
|
|
|
// module's local source directory.
|
2016-05-19 00:37:25 +02:00
|
|
|
func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath {
|
2017-02-01 23:12:44 +01:00
|
|
|
p := validatePath(ctx, paths...)
|
|
|
|
path := ModuleSrcPath{PathForSource(ctx, ctx.ModuleDir(), p)}
|
|
|
|
path.basePath.rel = p
|
|
|
|
return path
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// OptionalPathForModuleSrc returns an OptionalPath. The OptionalPath contains a
|
|
|
|
// valid path if p is non-nil.
|
2016-05-19 00:37:25 +02:00
|
|
|
func OptionalPathForModuleSrc(ctx ModuleContext, p *string) OptionalPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
if p == nil {
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
return OptionalPathForPath(PathForModuleSrc(ctx, *p))
|
|
|
|
}
|
|
|
|
|
2016-11-03 04:43:13 +01:00
|
|
|
func (p ModuleSrcPath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath {
|
2017-02-01 23:07:55 +01:00
|
|
|
return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (p ModuleSrcPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
|
2017-02-01 23:07:55 +01:00
|
|
|
return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (p ModuleSrcPath) resPathWithName(ctx ModuleContext, name string) ModuleResPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
// TODO: Use full directory if the new ctx is not the current ctx?
|
|
|
|
return PathForModuleRes(ctx, p.path, name)
|
|
|
|
}
|
|
|
|
|
2017-02-01 23:12:44 +01:00
|
|
|
func (p ModuleSrcPath) WithSubDir(ctx ModuleContext, subdir string) ModuleSrcPath {
|
|
|
|
subdir = PathForModuleSrc(ctx, subdir).String()
|
|
|
|
var err error
|
|
|
|
rel, err := filepath.Rel(subdir, p.path)
|
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf("source file %q is not under path %q", p.path, subdir)
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
p.rel = rel
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// ModuleOutPath is a Path representing a module's output directory.
|
|
|
|
type ModuleOutPath struct {
|
|
|
|
OutputPath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = ModuleOutPath{}
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
// PathForVndkRefDump returns an OptionalPath representing the path of the reference
|
|
|
|
// abi dump for the given module. This is not guaranteed to be valid.
|
|
|
|
func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNdk, isSourceDump bool) OptionalPath {
|
|
|
|
archName := ctx.Arch().ArchType.Name
|
|
|
|
var sourceOrBinaryDir string
|
|
|
|
var vndkOrNdkDir string
|
|
|
|
var ext string
|
|
|
|
if isSourceDump {
|
2017-04-20 15:53:59 +02:00
|
|
|
ext = ".lsdump.gz"
|
2017-02-08 22:45:53 +01:00
|
|
|
sourceOrBinaryDir = "source-based"
|
|
|
|
} else {
|
2017-04-20 15:53:59 +02:00
|
|
|
ext = ".bdump.gz"
|
2017-02-08 22:45:53 +01:00
|
|
|
sourceOrBinaryDir = "binary-based"
|
|
|
|
}
|
|
|
|
if vndkOrNdk {
|
|
|
|
vndkOrNdkDir = "vndk"
|
|
|
|
} else {
|
|
|
|
vndkOrNdkDir = "ndk"
|
|
|
|
}
|
|
|
|
refDumpFileStr := "prebuilts/abi-dumps/" + vndkOrNdkDir + "/" + version + "/" +
|
|
|
|
archName + "/" + sourceOrBinaryDir + "/" + fileName + ext
|
2017-04-11 00:47:24 +02:00
|
|
|
return ExistentPathForSource(ctx, "", refDumpFileStr)
|
2017-02-08 22:45:53 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// PathForModuleOut returns a Path representing the paths... under the module's
|
|
|
|
// output directory.
|
2016-05-19 00:37:25 +02:00
|
|
|
func PathForModuleOut(ctx ModuleContext, paths ...string) ModuleOutPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
p := validatePath(ctx, paths...)
|
|
|
|
return ModuleOutPath{PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir(), p)}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModuleGenPath is a Path representing the 'gen' directory in a module's output
|
|
|
|
// directory. Mainly used for generated sources.
|
|
|
|
type ModuleGenPath struct {
|
|
|
|
ModuleOutPath
|
|
|
|
path string
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = ModuleGenPath{}
|
|
|
|
var _ genPathProvider = ModuleGenPath{}
|
|
|
|
var _ objPathProvider = ModuleGenPath{}
|
|
|
|
|
|
|
|
// PathForModuleGen returns a Path representing the paths... under the module's
|
|
|
|
// `gen' directory.
|
2016-05-19 00:37:25 +02:00
|
|
|
func PathForModuleGen(ctx ModuleContext, paths ...string) ModuleGenPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
p := validatePath(ctx, paths...)
|
|
|
|
return ModuleGenPath{
|
|
|
|
PathForModuleOut(ctx, "gen", p),
|
|
|
|
p,
|
2015-07-15 03:55:36 +02:00
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-11-03 04:43:13 +01:00
|
|
|
func (p ModuleGenPath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
// TODO: make a different path for local vs remote generated files?
|
2016-11-03 04:43:13 +01:00
|
|
|
return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (p ModuleGenPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
|
|
|
|
}
|
2015-07-15 03:55:36 +02:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// ModuleObjPath is a Path representing the 'obj' directory in a module's output
|
|
|
|
// directory. Used for compiled objects.
|
|
|
|
type ModuleObjPath struct {
|
|
|
|
ModuleOutPath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = ModuleObjPath{}
|
|
|
|
|
|
|
|
// PathForModuleObj returns a Path representing the paths... under the module's
|
|
|
|
// 'obj' directory.
|
2017-04-11 00:47:24 +02:00
|
|
|
func PathForModuleObj(ctx ModuleContext, pathComponents ...string) ModuleObjPath {
|
|
|
|
p := validatePath(ctx, pathComponents...)
|
2015-09-24 00:26:20 +02:00
|
|
|
return ModuleObjPath{PathForModuleOut(ctx, "obj", p)}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModuleResPath is a a Path representing the 'res' directory in a module's
|
|
|
|
// output directory.
|
|
|
|
type ModuleResPath struct {
|
|
|
|
ModuleOutPath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Path = ModuleResPath{}
|
|
|
|
|
|
|
|
// PathForModuleRes returns a Path representing the paths... under the module's
|
|
|
|
// 'res' directory.
|
2017-04-11 00:47:24 +02:00
|
|
|
func PathForModuleRes(ctx ModuleContext, pathComponents ...string) ModuleResPath {
|
|
|
|
p := validatePath(ctx, pathComponents...)
|
2015-09-24 00:26:20 +02:00
|
|
|
return ModuleResPath{PathForModuleOut(ctx, "res", p)}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathForModuleInstall returns a Path representing the install path for the
|
|
|
|
// module appended with paths...
|
2017-07-07 01:59:48 +02:00
|
|
|
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) OutputPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
var outPaths []string
|
|
|
|
if ctx.Device() {
|
2017-06-07 21:31:57 +02:00
|
|
|
var partition string
|
2017-07-07 01:59:48 +02:00
|
|
|
if ctx.InstallInData() {
|
2017-06-07 21:31:57 +02:00
|
|
|
partition = "data"
|
2017-07-07 01:59:48 +02:00
|
|
|
} else if ctx.Vendor() {
|
|
|
|
partition = ctx.DeviceConfig().VendorPath()
|
2017-06-07 21:31:57 +02:00
|
|
|
} else {
|
|
|
|
partition = "system"
|
2015-12-21 23:55:28 +01:00
|
|
|
}
|
2017-03-30 07:00:18 +02:00
|
|
|
|
|
|
|
if ctx.InstallInSanitizerDir() {
|
|
|
|
partition = "data/asan/" + partition
|
2015-12-21 23:55:28 +01:00
|
|
|
}
|
|
|
|
outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition}
|
2015-09-24 00:26:20 +02:00
|
|
|
} else {
|
2017-09-22 21:28:24 +02:00
|
|
|
switch ctx.Os() {
|
|
|
|
case Linux:
|
|
|
|
outPaths = []string{"host", "linux-x86"}
|
|
|
|
case LinuxBionic:
|
|
|
|
// TODO: should this be a separate top level, or shared with linux-x86?
|
|
|
|
outPaths = []string{"host", "linux_bionic-x86"}
|
|
|
|
default:
|
|
|
|
outPaths = []string{"host", ctx.Os().String() + "-x86"}
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
2015-12-21 23:55:28 +01:00
|
|
|
if ctx.Debug() {
|
|
|
|
outPaths = append([]string{"debug"}, outPaths...)
|
|
|
|
}
|
2017-04-11 00:47:24 +02:00
|
|
|
outPaths = append(outPaths, pathComponents...)
|
2015-09-24 00:26:20 +02:00
|
|
|
return PathForOutput(ctx, outPaths...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// validateSafePath validates a path that we trust (may contain ninja variables).
|
2015-12-21 23:57:11 +01:00
|
|
|
// Ensures that each path component does not attempt to leave its component.
|
2017-04-11 00:47:24 +02:00
|
|
|
func validateSafePath(ctx PathContext, pathComponents ...string) string {
|
|
|
|
for _, path := range pathComponents {
|
2015-12-21 23:57:11 +01:00
|
|
|
path := filepath.Clean(path)
|
|
|
|
if path == ".." || strings.HasPrefix(path, "../") || strings.HasPrefix(path, "/") {
|
|
|
|
reportPathError(ctx, "Path is outside directory: %s", path)
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
// TODO: filepath.Join isn't necessarily correct with embedded ninja
|
|
|
|
// variables. '..' may remove the entire ninja variable, even if it
|
|
|
|
// will be expanded to multiple nested directories.
|
2017-04-11 00:47:24 +02:00
|
|
|
return filepath.Join(pathComponents...)
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2015-12-21 23:57:11 +01:00
|
|
|
// validatePath validates that a path does not include ninja variables, and that
|
|
|
|
// each path component does not attempt to leave its component. Returns a joined
|
|
|
|
// version of each path component.
|
2017-04-11 00:47:24 +02:00
|
|
|
func validatePath(ctx PathContext, pathComponents ...string) string {
|
|
|
|
for _, path := range pathComponents {
|
2015-09-24 00:26:20 +02:00
|
|
|
if strings.Contains(path, "$") {
|
|
|
|
reportPathError(ctx, "Path contains invalid character($): %s", path)
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2017-04-11 00:47:24 +02:00
|
|
|
return validateSafePath(ctx, pathComponents...)
|
2015-07-15 03:55:36 +02:00
|
|
|
}
|
2017-05-09 22:34:34 +02:00
|
|
|
|
|
|
|
type testPath struct {
|
|
|
|
basePath
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p testPath) String() string {
|
|
|
|
return p.path
|
|
|
|
}
|
|
|
|
|
|
|
|
func PathForTesting(paths ...string) Path {
|
|
|
|
p := validateSafePath(nil, paths...)
|
|
|
|
return testPath{basePath{path: p, rel: p}}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PathsForTesting(strs []string) Paths {
|
|
|
|
p := make(Paths, len(strs))
|
|
|
|
for i, s := range strs {
|
|
|
|
p[i] = PathForTesting(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|