Documentation ¶
Overview ¶
Package makex implements an experimental, incompatible `make`.
Index ¶
- Variables
- func ExpandAutoVars(rule Rule, s string) string
- func External(dir string, makefile []byte, args []string) ([]byte, error)
- func Flags(fs *flag.FlagSet, conf *Config, prefix string)
- func Marshal(mf *Makefile) ([]byte, error)
- func Quote(s string) string
- func QuoteList(ss []string) []string
- func Targets(rules []Rule) []string
- type BasicRule
- type Config
- type Errors
- type FileSystem
- type Makefile
- type Maker
- type Rule
- type RuleBuildError
Constants ¶
This section is empty.
Variables ¶
var Default = Config{
ParallelJobs: 1,
}
Functions ¶
func ExpandAutoVars ¶
ExpandAutoVars expands the automatic variables $@ (the current target path) and $^ (the space-separated list of prereqs) in s.
func Flags ¶
Flags adds makex command-line flags to an existing flag.FlagSet (or the global FlagSet if fs is nil).
func Marshal ¶
Marshal returns the textual representation of the Makefile, in the usual format:
target: prereqs recipes ...
func Quote ¶
Quote IS NOT A SAFE WAY TO ESCAPE USER INPUT. It hackily escapes special characters in s and surrounds it with quotation marks if needed, so that the shell interprets it as a single argument equal to s. DON'T RELY ON THIS FOR SECURITY.
TODO(sqs): come up with a safe way of escaping user input
Types ¶
type BasicRule ¶
BasicRule implements Rule.
Use BasicRule for rules that you don't need to introspect programmatically. If you need to store additional metadata about rules, create a separate type that implements Rule and holds the metadata.
type Config ¶
type Config struct { FS FileSystem ParallelJobs int Verbose bool DryRun bool }
type FileSystem ¶
type FileSystem interface { rwvfs.FileSystem Join(elem ...string) string }
A FileSystem is a file system that can be read, written, and walked. Given an existing rwvfs.FileSystem, use NewFileSystem to add the Join method (which will use the current OS's filepath.Separator).
func NewFileSystem ¶
func NewFileSystem(fs rwvfs.FileSystem) FileSystem
NewFileSystem returns a FileSystem with Join method (which will use the current OS's filepath.Separator).
type Makefile ¶
type Makefile struct {
Rules []Rule
}
Makefile represents a set of rules, each describing how to build a target.
func (*Makefile) DefaultRule ¶
DefaultRule is the first rule whose name does not begin with a ".", or nil if no such rule exists.
type Maker ¶
type Maker struct { // RuleOutput specifies the writers to receive the stdout and stderr output // from executing a rule's recipes. After executing a rule, out and err are // closed. If RuleOutput is nil, os.Stdout and // os.Stderr are used, respectively (but not closed after use). RuleOutput func(Rule) (out io.WriteCloser, err io.WriteCloser, logger *log.Logger) // Channels to monitor progress. If non-nil, these channels are called at // various stages of building targets. Ended is always called *after* // Succeeded or Failed. Started, Ended, Succeeded chan<- Rule Failed chan<- RuleBuildError *Config // contains filtered or unexported fields }
A Maker can build goals in a Makefile.
func (*Maker) DryRun ¶
DryRun prints information about what targets *would* be built if Run() was called.
func (*Maker) TargetSets ¶
TargetSets returns a topologically sorted list of sets of target names. To only get targets that are stale and need to be built, use TargetSetsNeedingBuild.
func (*Maker) TargetSetsNeedingBuild ¶
TargetSetsNeedingBuild returns a topologically sorted list of sets of target names that need to be built (i.e., that are stale).
type Rule ¶
A Rule describes a target file, a list of commands (recipes) used to create the target output file, and the files (which may also have corresponding rules) that must exist prior to running the recipes.
It is a slightly simplified representation of a standard "make" rule.
type RuleBuildError ¶
func (RuleBuildError) Error ¶
func (e RuleBuildError) Error() string