Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB interface { // Has tells whether the database contains the given entry. Has(context.Context, []byte) (bool, error) // Add adds an entry to the database. Add(context.Context, []byte) error }
DB is a database for storing hashes. It must permit concurrent operations safely. It may expire entries to save space.
type Fn ¶
Fn is an mg.Fn (see https://pkg.go.dev/github.com/magefile/mage/mg#Fn) that knows how to skip rebuilding a target that is up-to-date with respect to its sources. "Up-to-date" here does not refer to file modtimes, but rather to content hashes: the existing target was computed from sources that are byte-for-byte the same now as they were when the target was built.
type JRule ¶
type JRule struct { Sources []string `json:"sources"` Targets []string `json:"targets"` Command []string `json:"command"` Dir string `json:"dir"` }
JRule is a Rule that lists a set of source files and a set of target files, and includes a command for producing targets from sources.
func JDir ¶ added in v0.2.0
JDir parses a file named .mghash.json in the given directory, if there is one, returning the JRules it contains. The default directory for any JRules not specifying one is dir.
type Rule ¶
type Rule interface { fmt.Stringer // RuleHash produces the hash of this rule. // This should be a strong, collision-resistant value // that is sensitive to changes in the rule itself // but not in any of its sources or targets. RuleHash() []byte // ContentHash produces a hash that incorporates information about the rule // combined with the state of all sources and targets. // This should be a strong, collision-resistant value. ContentHash(context.Context) ([]byte, error) // Run is a function that can generate this rule's targets. Run(context.Context) error }
Rule knows how to report a hash representing itself, and another hash representing itself plus the state of all sources and targets; and how to produce its targets from its sources.