bake

package module
v0.0.0-...-9b306a7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: BSD-3-Clause Imports: 21 Imported by: 0

README

bake

Bake is a distributed build system built for the Flynn project.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDependency is set on a build if a dependent build has an error.
	ErrDependency = errors.New("dependency error")

	// ErrCanceled is set on a build if the build was canceled early.
	ErrCanceled = errors.New("build canceled")
)
View Source
var ErrSnapshotTargetNotFound = errors.New("snapshot target not found")

ErrSnapshotTargetNotFound is returned when operating on a target that doesn't exist.

View Source
var ErrUnregisteredFileSystem = errors.New("unregistered file system")

ErrUnregisteredFileSystem is returned when a file system has not been registered.

Functions

func MatchTarget

func MatchTarget(pattern string, t *Target) (matched bool, err error)

MatchTarget returns true if t's name or outputs match pattern.

func RegisterFileSystem

func RegisterFileSystem(typ string, fn NewFileSystemFunc)

RegisterFileSystem registers a filesystem constructor by type.

Types

type Build

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

Build represents a build step.

func (*Build) Close

func (b *Build) Close() error

Close recursively closes the build's readers and its dependencies readers.

func (*Build) Dependencies

func (b *Build) Dependencies() []*Build

Dependencies returns a list of builds that b depends on.

func (*Build) Done

func (b *Build) Done(err error)

Done marks the build as complete and sets the error, if any. Calling this method twice on a build will cause it to panic.

func (*Build) Err

func (b *Build) Err() error

Err returns the error that occurred on the build, if any.

func (*Build) Name

func (b *Build) Name() string

Name returns the target's name. Returns a blank string if a top-level build.

func (*Build) RootErr

func (b *Build) RootErr() error

RootErr recursively searches the build tree and finds the build error.

func (*Build) Stderr

func (b *Build) Stderr() io.ReadCloser

Stderr returns the standard error stream.

func (*Build) Stdout

func (b *Build) Stdout() io.ReadCloser

Stdout returns the standard output stream.

func (*Build) Target

func (b *Build) Target() *Target

Target returns the build target.

func (*Build) Wait

func (b *Build) Wait()

Wait blocks until the build has finished.

type Builder

type Builder struct {

	// Used for tracking read/write access during build steps.
	FileSystem FileSystem

	// Used for persisting the last state of the file system.
	Snapshot *Snapshot

	Output io.Writer
	// contains filtered or unexported fields
}

Builder processes targets to produce an output Build.

func NewBuilder

func NewBuilder() *Builder

NewBuilder returns a new instance of Builder.

func (*Builder) Build

func (b *Builder) Build(build *Build)

Build recursively executes build steps in parallel.

type Builds

type Builds []*Build

Builds represents a

type Command

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

Command represents an executable command.

type ExecCommand

type ExecCommand struct {
	Args []string
}

ExecCommand represents a command that is executed against the OS's exec().

type File

type File struct {
	Name     string
	Size     int64
	Mode     os.FileMode
	ModTime  int64
	Children map[string]File
}

File represents a physical file or directory in a package.

type FileSystem

type FileSystem interface {
	Open() error
	Close() error

	// The underlying path being served.
	Path() string

	// Creates a new root path for the file system where changes can be tracked.
	CreateRoot() FileSystemRoot
}

FileSystem represents a way to mount the build filesystem.

func NewFileSystem

func NewFileSystem(typ string, opt FileSystemOptions) (FileSystem, error)

NewFileSystem returns a new instance of FileSystem for a given type.

type FileSystemOptions

type FileSystemOptions struct {
	// Underlying path to serve
	Path string

	// Directory to mount to.
	MountPath string
}

FileSystemOptions represents a list of options passed to a file sytem on creation.

type FileSystemRoot

type FileSystemRoot interface {
	Path() string
	Readset() map[string]struct{}
	Writeset() map[string]struct{}
}

FileSystemRoot represents a copy of the file system root. It can be used for tracking reads & writes.

type Label

type Label struct {
	Package string
	Target  string
}

Label represents a reference to a project and target. An empty package represents the default package. An empty target represents the default target.

func ParseLabel

func ParseLabel(s string) Label

ParseLabel parses a URI string into a label.

func (Label) String

func (l Label) String() string

String returns the string representation of l.

type NewFileSystemFunc

type NewFileSystemFunc func(FileSystemOptions) (FileSystem, error)

NewFileSystemFunc is a function for creating a new file system.

type Package

type Package struct {
	Name    string
	Targets []*Target
}

Package represents a collection of targets.

func (*Package) MatchTargets

func (p *Package) MatchTargets(pattern string) ([]*Target, error)

MatchTargets returns a list of targets matching a glob pattern. Matches pattern against target name or output files.

func (*Package) Target

func (p *Package) Target(name string) *Target

Target returns a target by name or by output.

func (*Package) TargetNames

func (p *Package) TargetNames() []string

TargetNames returns a sorted list of all target names.

type Parser

type Parser struct {

	// Package being built by the parser.
	// It is incrementally added to on every parse.
	Package *Package
	// contains filtered or unexported fields
}

Parser represents a recursive directory parser.

func NewParser

func NewParser() *Parser

NewParser returns a new instance of Parser.

func (*Parser) ParseDir

func (p *Parser) ParseDir(path string) error

ParseDir recursively parses all bakefiles in a directory tree. If a directory contains a Bakefile then it is parsed and added to the package. All targets and their names are relative from path.

type Planner

type Planner struct {

	// Used to determine dirty targets since last build.
	Snapshot *Snapshot
	// contains filtered or unexported fields
}

Planner represents the object that creates a build plan. This type is not safe for multiple goroutines.

func NewPlanner

func NewPlanner(pkg *Package) *Planner

NewPlanner returns a new instance of Planner.

func (*Planner) Plan

func (p *Planner) Plan(patterns []string) (*Build, error)

Plan creates a build plan for a target in a package.

type ShellCommand

type ShellCommand struct {
	Source string
}

ShellCommand represents a command that executes a shell script against /bin/sh.

type Snapshot

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

Snapshot represents the state of the build system. This includes the targets, their list of file dependencies, and file states.

func NewSnapshot

func NewSnapshot(path, root string) *Snapshot

NewSnapshot returns a new instance of Snapshot.

func (*Snapshot) AddTarget

func (ss *Snapshot) AddTarget(t *Target, inputs []string) error

AddTarget adds a target to the snapshot.

If the target already exists then it is merged with the existing record. The file dependencies of target are checked for changes and updated if needed.

func (*Snapshot) IsTargetDirty

func (ss *Snapshot) IsTargetDirty(t *Target) (bool, error)

IsTargetDirty returns true if a target has changed or its file inputs have changed.

func (*Snapshot) Path

func (ss *Snapshot) Path() string

Path returns the path that the snapshot was initialized with.

func (*Snapshot) Root

func (ss *Snapshot) Root() string

Root returns the project root that the snapshot was initialized with.

type Target

type Target struct {
	// Unique identifier for the target within the package.
	Name string

	// Indicates that the target does not produce a file.
	// For example, "test" or "clean".
	Phony bool

	// Text shown to users instead of commands.
	Title string

	// The working directory that commands are run from.
	WorkDir string

	// The commands to execute to build the target.
	Commands []Command

	// Depedent target names.
	Dependencies []string

	// Files to be retained after build.
	// Any files written that are not declared here are assumed to be temporary files.
	Outputs []string
}

Target represents a buildable rule.

Directories

Path Synopsis
cmd
p9
Package internal is a generated protocol buffer package.
Package internal is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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