rules

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseInto

func ParseInto(input string, rules *RuleSet, file string, line int) error

ParseInto parses 'input' into the rules RuleSet, from the file at 'file'.

Types

type AttrSet

type AttrSet struct {
	Regex    bool   // regular expression meta-rule
	Virtual  bool   // targets are not files
	Quiet    bool   // is not displayed as part of the build process
	NoMeta   bool   // cannot be matched by meta rules
	NonStop  bool   // does not stop if the recipe fails
	Rebuild  bool   // this rule is always out-of-date
	Linked   bool   // only run this rule if a sub-rule that requires it needs to run
	Implicit bool   // not listed in $input
	Dep      string // dependency file
	Order    bool
}

func ParseAttribs

func ParseAttribs(input string) (AttrSet, error)

func (*AttrSet) UpdateFrom added in v0.3.0

func (a *AttrSet) UpdateFrom(other AttrSet)

type BuildCommand added in v0.1.0

type BuildCommand struct {
	Directory string   `json:"directory"`
	Prereqs   []string `json:"prereqs"`
	Inputs    []string `json:"inputs"`
	Outputs   []string `json:"outputs"`
	Commands  []string `json:"command"`
	Name      string   `json:"name"`
}

type BuildRules added in v0.1.0

type BuildRules []BuildCommand

type CleanTool added in v0.1.0

type CleanTool struct {
	NoExec bool
	Db     *Database
	W      io.Writer
}

func (*CleanTool) Run added in v0.1.0

func (t *CleanTool) Run(g *Graph, args []string) error

func (*CleanTool) String added in v0.1.0

func (t *CleanTool) String() string

type CommandsTool added in v0.1.0

type CommandsTool struct {
	W io.Writer
}

func (*CommandsTool) Run added in v0.1.0

func (t *CommandsTool) Run(g *Graph, args []string) error

func (*CommandsTool) String added in v0.1.0

func (t *CommandsTool) String() string

type CompCommand added in v0.1.0

type CompCommand struct {
	Directory string `json:"directory"`
	File      string `json:"file"`
	Command   string `json:"command"`
}

type CompileDbTool added in v0.1.0

type CompileDbTool struct {
	W   io.Writer
	All bool
}

func (*CompileDbTool) Run added in v0.1.0

func (t *CompileDbTool) Run(g *Graph, args []string) error

func (*CompileDbTool) String added in v0.1.0

func (t *CompileDbTool) String() string

type Database

type Database struct {
	// contains filtered or unexported fields
}

func NewCacheDatabase

func NewCacheDatabase(dir, wd string) *Database

func NewDatabase

func NewDatabase(dir string) *Database

func (Database) AddOutput added in v0.4.0

func (d Database) AddOutput(file string)

func (Database) AddOutputDir added in v0.4.0

func (d Database) AddOutputDir(dir string)

func (*Database) Reload added in v0.4.1

func (db *Database) Reload()

func (*Database) Save

func (db *Database) Save() error

func (Database) WriteBytesTo added in v0.0.4

func (d Database) WriteBytesTo(w io.Writer) error

type DbTool added in v1.1.1

type DbTool struct {
	Db *Database
	W  io.Writer
}

func (*DbTool) Run added in v1.1.1

func (t *DbTool) Run(g *Graph, args []string) error

func (*DbTool) String added in v1.1.1

func (t *DbTool) String() string

type DirectRule

type DirectRule struct {
	// contains filtered or unexported fields
}

A DirectRule specifies how to build a fully specified list of targets from a list of prereqs.

func NewDirectRule

func NewDirectRule(targets []string, prereqs []prereq, recipe []string, attrs AttrSet) DirectRule

func NewDirectRuleBase added in v1.0.0

func NewDirectRuleBase(targets []string, prereqs []string, recipe []string, attrs AttrSet) DirectRule

func (*DirectRule) Equals added in v0.0.4

func (r *DirectRule) Equals(other *DirectRule) bool

func (*DirectRule) String

func (r *DirectRule) String() string

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(basedir string, db *Database, threads int, printer Printer, info InfoFn, opts Options) *Executor

func (*Executor) Exec

func (e *Executor) Exec(g *Graph) (bool, error)

Exec runs all commands and returns true if something was rebuilt.

type File added in v0.0.4

type File struct {
	ModTime time.Time
	Size    int64
	// TODO: optimize with a short hash
	Full   uint64 // hash of the full file
	Path   string
	Exists bool
}

func NewFile added in v0.0.4

func NewFile(path string) File

func (File) Equals added in v0.0.4

func (f File) Equals(path string) bool

type Files added in v0.0.4

type Files struct {
	// map from file name to file hash/data
	Data map[string]File
}

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph(rs *RuleSet, target string, updated map[string]bool) (g *Graph, err error)

func (*Graph) ExpandRecipes

func (g *Graph) ExpandRecipes(vm VM) error

ExpandRecipes evaluates all variables and expressions in the recipes for the build

func (*Graph) Size

func (g *Graph) Size() int

type GraphTool added in v0.1.0

type GraphTool struct {
	W io.Writer
}

func (*GraphTool) Run added in v0.1.0

func (t *GraphTool) Run(g *Graph, args []string) error

func (*GraphTool) String added in v0.1.0

func (t *GraphTool) String() string

type InfoFn added in v0.0.3

type InfoFn func(msg string)

type ListTool added in v0.1.0

type ListTool struct {
	W io.Writer
}

func (*ListTool) Run added in v0.1.0

func (t *ListTool) Run(g *Graph, args []string) error

func (*ListTool) String added in v0.1.0

func (t *ListTool) String() string

type MetaRule

type MetaRule struct {
	// contains filtered or unexported fields
}

A MetaRule specifies the targets to build based on a pattern.

func (*MetaRule) Match

func (r *MetaRule) Match(target string) ([]int, *Pattern)

Match returns the submatch and pattern used to perform the match, if there is one.

func (*MetaRule) String added in v0.2.0

func (r *MetaRule) String() string

type MultiError added in v0.0.3

type MultiError []error

func (MultiError) Error added in v0.0.3

func (e MultiError) Error() string

type Options

type Options struct {
	NoExec       bool   // don't execute recipes
	Shell        string // use shell for executing commands
	AbortOnError bool   // stop if an error happens in a recipe
	BuildAll     bool   // build all rules even if they are up-to-date
	Hash         bool   // use hashes to determine whether a file has been modified
}

type PathTool added in v0.3.6

type PathTool struct {
	W    io.Writer
	Path string
}

func (*PathTool) Run added in v0.3.6

func (t *PathTool) Run(g *Graph, args []string) error

func (*PathTool) String added in v0.3.6

func (t *PathTool) String() string

type Pattern

type Pattern struct {
	Suffix bool
	Regex  *regexp.Regexp
}

type Prereqs added in v0.1.0

type Prereqs struct {
	// map from hash of targets to files
	Hashes map[uint64]*Files
}

type Printer added in v0.0.4

type Printer interface {
	Print(cmd, dir string, name string, step int)
	SetSteps(nsteps int)
	Update()
	NeedsUpdate() bool
	Done(name string)
	Clear()
}

type Recipes added in v0.0.4

type Recipes struct {
	// map from hash of targets to hash of recipe contents
	Hashes map[uint64]uint64
}

type Rule

type Rule interface {
	// contains filtered or unexported methods
}

type RuleSet

type RuleSet struct {
	// contains filtered or unexported fields
}

func MergeRuleSets added in v1.0.0

func MergeRuleSets(first *RuleSet, rsets []*RuleSet) *RuleSet

func NewRuleSet

func NewRuleSet(dir string) *RuleSet

func (*RuleSet) Add

func (rs *RuleSet) Add(r Rule)

func (*RuleSet) AllTargets added in v0.1.0

func (rs *RuleSet) AllTargets() []string

func (*RuleSet) MainTarget added in v0.0.4

func (rs *RuleSet) MainTarget() string

type StatusTool added in v0.1.1

type StatusTool struct {
	W    io.Writer
	Db   *Database
	Hash bool
}

func (*StatusTool) Run added in v0.1.1

func (t *StatusTool) Run(g *Graph, args []string) error

func (*StatusTool) String added in v0.1.1

func (t *StatusTool) String() string

type TargetsTool added in v0.1.0

type TargetsTool struct {
	W io.Writer
}

func (*TargetsTool) Run added in v0.1.0

func (t *TargetsTool) Run(g *Graph, args []string) error

func (*TargetsTool) String added in v0.1.0

func (t *TargetsTool) String() string

type Tool added in v0.1.0

type Tool interface {
	Run(g *Graph, args []string) error
	String() string
}

type UpdateReason added in v0.1.1

type UpdateReason int
const (
	UpToDate UpdateReason = iota
	OnlyPrereqs
	Rebuild
	NoExist
	ForceUpdate
	HashModified
	TimeModified
	RecipeModified
	Untracked
	Prereq
	LinkedUpdate
	UpToDateDynamic
)

func (UpdateReason) String added in v0.1.1

func (u UpdateReason) String() string

type VM

type VM interface {
	ExpandFuncs() (func(string) (string, error), func(string) (string, error))
	SetVar(name string, val interface{})
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL