Documentation ¶
Index ¶
- Variables
- func Glob(pattern string, excludes []string) (matches, deps []string, err error)
- func GlobPatternList(patterns []string, prefix string) (globedList []string, depDirs []string, err error)
- func GlobWithDepFile(glob, fileListFile, depFile string, excludes []string) (files []string, err error)
- func HasGlob(in []string) bool
- func IsGlob(pattern string) bool
- func PrefixPaths(paths []string, prefix string) []string
- func ReplaceExtension(path string, extension string) string
- func ReplaceExtensions(paths []string, extension string) []string
- func WriteFileIfChanged(filename string, data []byte, perm os.FileMode) error
- type FileSystem
Constants ¶
This section is empty.
Variables ¶
var GlobLastRecursiveErr = errors.New("pattern ** as last path element")
var GlobMultipleRecursiveErr = errors.New("pattern contains multiple **")
Functions ¶
func Glob ¶
Glob returns the list of files that match the given pattern but do not match the given exclude patterns, along with the list of directories and other dependencies that were searched to construct the file list. The supported glob and exclude patterns are equivalent to filepath.Glob, with an extension that recursive glob (** matching zero or more complete path entries) is supported. Glob also returns a list of directories that were searched.
In general ModuleContext.GlobWithDeps or SingletonContext.GlobWithDeps should be used instead, as they will automatically set up dependencies to rerun the primary builder when the list of matching files changes.
func GlobPatternList ¶
func GlobWithDepFile ¶
func GlobWithDepFile(glob, fileListFile, depFile string, excludes []string) (files []string, err error)
GlobWithDepFile finds all files that match glob. It compares the list of files against the contents of fileListFile, and rewrites fileListFile if it has changed. It also writes all of the the directories it traversed as a depenencies on fileListFile to depFile.
The format of glob is either path/*.ext for a single directory glob, or path/**/*.ext for a recursive glob.
Returns a list of file paths, and an error.
In general ModuleContext.GlobWithDeps or SingletonContext.GlobWithDeps should be used instead, as they will automatically set up dependencies to rerun the primary builder when the list of matching files changes.
func HasGlob ¶
HasGlob returns true if any string in the list contains any glob characters (*, ?, or [).
func PrefixPaths ¶
PrefixPaths returns a list of paths consisting of prefix joined with each element of paths. The resulting paths are "clean" in the filepath.Clean sense.
func ReplaceExtension ¶
func ReplaceExtensions ¶
func WriteFileIfChanged ¶
WriteFileIfChanged wraps ioutil.WriteFile, but only writes the file if the files does not already exist with identical contents. This can be used along with ninja restat rules to skip rebuilding downstream rules if no changes were made by a rule.
Types ¶
type FileSystem ¶
type FileSystem interface { Open(name string) (io.ReadCloser, error) Exists(name string) (bool, bool, error) Glob(pattern string, excludes []string) (matches, dirs []string, err error) IsDir(name string) (bool, error) // contains filtered or unexported methods }
var OsFs FileSystem = osFs{}
func MockFs ¶
func MockFs(files map[string][]byte) FileSystem