{"modulePath":"github.com/sourcegraph/makex","version":"v0.0.0-20160708125403-3f62e8d29c0f","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package makex\n\nPackage makex implements an experimental, incompatible \\`make\\`.\n\n## Variables\n\n```go\nvar Default = Config{\n\tParallelJobs: 1,\n}\n```\n\n## Functions\n\n```go\nfunc ExpandAutoVars(rule Rule, s string) string\n```\nExpandAutoVars expands the automatic variables $@ (the current target path) and $^ (the space-separated list of prereqs) in s.\n\n```go\nfunc External(dir string, makefile []byte, args []string) ([]byte, error)\n```\nExternal runs makefile using the system \\`make\\` tool, optionally passing extra args.\n\n```go\nfunc Flags(fs *flag.FlagSet, conf *Config, prefix string)\n```\nFlags adds makex command-line flags to an existing flag.FlagSet (or the global FlagSet if fs is nil).\n\n```go\nfunc Marshal(mf *Makefile) ([]byte, error)\n```\nMarshal returns the textual representation of the Makefile, in the usual format:\n\n\ttarget: prereqs\n\t\trecipes\n\n\t...\n\n```go\nfunc Quote(s string) string\n```\nQuote 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.\n\nTODO(sqs): come up with a safe way of escaping user input\n\n```go\nfunc QuoteList(ss []string) []string\n```\nQuoteList IS NOT A SAFE WAY TO ESCAPE USER INPUT. It returns a list whose elements are the escaped elements of ss (using Quote). DON'T RELY ON THIS FOR SECURITY.\n\nTODO(sqs): come up with a safe way of escaping user input\n\n```go\nfunc Targets(rules []Rule) []string\n```\nTargets returns the list of targets defined by rules.\n\n## Types\n\n```go\ntype BasicRule struct {\n\tTargetFile  string\n\tPrereqFiles []string\n\tRecipeCmds  []string\n}\n```\nBasicRule implements Rule.\n\nUse 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.\n\n```go\nfunc (r *BasicRule) Prereqs() []string\n```\nPrereqs implements Rule.\n\n```go\nfunc (r *BasicRule) Recipes() []string\n```\nRecipes implements rule.\n\n```go\nfunc (r *BasicRule) Target() string\n```\nTarget implements Rule.\n\n```go\ntype Config struct {\n\tFS           FileSystem\n\tParallelJobs int\n\tVerbose      bool\n\tDryRun       bool\n}\n```\n\n```go\nfunc (c *Config) Expand(orig *Makefile) (*Makefile, error)\n```\nExpand returns a clone of mf with Prereqs filepath globs expanded. If rules contain globs, they are replaced with BasicRules with the globs expanded.\n\nOnly globs containing \"\\*\" are detected.\n\n```go\nfunc (c *Config) NewMaker(mf *Makefile, goals ...string) *Maker\n```\nNewMaker creates a new Maker, which can build goals in a Makefile.\n\n```go\ntype Errors []error\n```\n\n```go\nfunc (e Errors) Error() string\n```\n\n```go\ntype FileSystem interface {\n\trwvfs.FileSystem\n\tJoin(elem ...string) string\n}\n```\nA 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).\n\n```go\nfunc NewFileSystem(fs rwvfs.FileSystem) FileSystem\n```\nNewFileSystem returns a FileSystem with Join method (which will use the current OS's filepath.Separator).\n\n```go\ntype Makefile struct {\n\tRules []Rule\n}\n```\nMakefile represents a set of rules, each describing how to build a target.\n\n```go\nfunc Parse(data []byte) (*Makefile, error)\n```\nParse parses a Makefile into a \\*Makefile struct.\n\nTODO(sqs): super hacky.\n\n```go\nfunc (mf *Makefile) DefaultRule() Rule\n```\nDefaultRule is the first rule whose name does not begin with a \".\", or nil if no such rule exists.\n\n```go\nfunc (mf *Makefile) Rule(target string) Rule\n```\nRule returns the rule to make the specified target if it exists, or nil otherwise.\n\nTODO(sqs): support multiple rules for one target ([http://www.gnu.org/software/make/manual/html\\_node/Multiple-Rules.html](http://www.gnu.org/software/make/manual/html_node/Multiple-Rules.html)).\n\n```go\ntype Maker struct {\n\n\t// RuleOutput specifies the writers to receive the stdout and stderr output\n\t// from executing a rule's recipes. After executing a rule, out and err are\n\t// closed. If RuleOutput is nil, os.Stdout and\n\t// os.Stderr are used, respectively (but not closed after use).\n\tRuleOutput func(Rule) (out io.WriteCloser, err io.WriteCloser, logger *log.Logger)\n\n\t// Channels to monitor progress. If non-nil, these channels are called at\n\t// various stages of building targets. Ended is always called *after*\n\t// Succeeded or Failed.\n\tStarted, Ended, Succeeded chan\u003c- Rule\n\tFailed                    chan\u003c- RuleBuildError\n\n\t*Config\n\t// contains filtered or unexported fields\n}\n```\nA Maker can build goals in a Makefile.\n\n```go\nfunc (m *Maker) DryRun(w io.Writer) error\n```\nDryRun prints information about what targets \\*would\\* be built if Run() was called.\n\n```go\nfunc (m *Maker) Run() error\n```\nRun builds all stale targets.\n\n```go\nfunc (m *Maker) TargetSets() [][]string\n```\nTargetSets returns a topologically sorted list of sets of target names. To only get targets that are stale and need to be built, use TargetSetsNeedingBuild.\n\n```go\nfunc (m *Maker) TargetSetsNeedingBuild() ([][]string, error)\n```\nTargetSetsNeedingBuild returns a topologically sorted list of sets of target names that need to be built (i.e., that are stale).\n\n```go\ntype Rule interface {\n\tTarget() string\n\tPrereqs() []string\n\tRecipes() []string\n}\n```\nA 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.\n\nIt is a slightly simplified representation of a standard \"make\" rule.\n\n```go\ntype RuleBuildError struct {\n\tRule Rule\n\tErr  error\n}\n```\n\n```go\nfunc (e RuleBuildError) Error() string\n```\n\n","path":"github.com/sourcegraph/makex","name":"makex","synopsis":"Package makex implements an experimental, incompatible `make`.","isRedistributable":true}
