builder

package
v0.0.0-...-0d25880 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	Signature string
	Path      string
	Payload   []byte
}

An Artifact describes a payload that is built using data matching a signature and wich should be deployed at a specific location at the workspace.

func (Artifact) Apply

func (a Artifact) Apply(workdir string)

Apply the artifact to the workdir

type Builder

type Builder struct {
	Verbose       bool
	Variables     utils.Variables
	WorkspaceRoot string
	// contains filtered or unexported fields
}

The Builder is the controller responsible for creating a deterministic execution order between the tasks registered with the Builder. It is also responsible for keeping the Artifacts resulted from the execution of the Tasks and deploying them in case of their existence. The Builder is also responsible for keeping a Task register that will be used when creating implicitly declared Tasks.

func NewBuilder

func NewBuilder(ctxt context.Context,
	workspaceRoot string,
	workerCount int,
	verbose bool,
	build, host, target string,
	downloadDir, toolsDir, cacheDir, stampDir string) *Builder

NewBuilder creates a new builder with some workspace level definitions

func (*Builder) Add

func (b *Builder) Add(task *Task, op Operation) *Task

Add a new task to the builder. If the task already existed the existing task will be returned and provided task will be nulled, in order to detect erroneous reuse of duplicated task.

func (*Builder) Build

func (b *Builder) Build(tasks ...*Task)

Build will use the registered targets and try to build the provided targets, which also needs to be part of the environment...

func (*Builder) DumpTasks

func (b *Builder) DumpTasks()

DumpTasks will show all registered tasks in the builder

func (*Builder) EstablishPath

func (b *Builder) EstablishPath(perm os.FileMode, paths ...string) string

EstablishPath will make sure a path exists within the environment. If the supplied path is relative, it will be relative to WorkspaceRoot. The returned path is the absolute path to the directory. It returns the absolute path to the directory

func (*Builder) Execute

func (b *Builder) Execute(t *Task)

Execute a task. If parallell execution is applied then the call should be properly embedded in a go routine and safe-guarded by mutexes.

func (*Builder) GetFreeWorker

func (b *Builder) GetFreeWorker() *Worker

GetFreeWorker returns the first worker that indicates it has nothing to do.

func (*Builder) IsAssignedToWorker

func (b *Builder) IsAssignedToWorker(t *Task) bool

IsAssignedToWorker checks to see if there is a worker working on the Target

func (*Builder) IsStamped

func (b *Builder) IsStamped(t *Task) bool

IsStamped checks to see if the Task t is already built

func (*Builder) ReportWorkerUtilization

func (b *Builder) ReportWorkerUtilization()

ReportWorkerUtilization prints how many tasks each user have executed

func (*Builder) Stamp

func (b *Builder) Stamp(t *Task)

Stamp will create a stamp in the stamp directory, marking that the task t is done.

func (*Builder) Task

func (b *Builder) Task(id string) *Task

Task retrievs the MakeTarget based on the ID. It will panic in case the target does not exist in the environment

func (*Builder) WorkspacePath

func (b *Builder) WorkspacePath(paths ...string) string

WorkspacePath returns a path within the workspace. If paths is a absolute path, it will be checked to see if it's within the workspace, and panic if not.

type Operation

type Operation func(utils.Variables) *Artifact

An Operation is the functionality associated with a task

func Message

func Message(v utils.Variables, msg string) Operation

Message creates an operation that only prints a message

type Task

type Task struct {
	// The ID must match the Id of the operation in builder
	ID           string
	Dependencies []*Task
	Variables    utils.Variables
	Signature    string
	RunAlways    bool
	// contains filtered or unexported fields
}

A Task is a combination of an Operation and a set of Variables to call the opration with

func NewTask

func NewTask(b *Builder, id string) *Task

NewTask creates a new Task of type TaskImpl

func (*Task) AllDependenciesDone

func (t *Task) AllDependenciesDone() bool

AllDependenciesDone checks if all the dependencies

func (*Task) AssignDefaultSignature

func (t *Task) AssignDefaultSignature()

AssignDefaultSignature will generate an md5 signature based on the id and a sorted list of the task variables.

func (*Task) DependsOn

func (t *Task) DependsOn(d ...*Task)

DependsOn states a dependency to a another task.

func (*Task) DependsOnSerial

func (t *Task) DependsOnSerial(d ...*Task)

DependsOnSerial makes t depend on d_N, d_N on d_N-1, etc

func (*Task) DumpStr

func (t *Task) DumpStr(deps bool) string

DumpStr will show interesting stuff in da string...

func (*Task) GetDependencies

func (t *Task) GetDependencies() []*Task

GetDependencies ...

func (*Task) GetID

func (t *Task) GetID() string

GetID ...

func (Task) IDSig

func (t Task) IDSig() string

IDSig returns id:Signature

func (*Task) IsDone

func (t *Task) IsDone() bool

IsDone ...

func (*Task) MarkDone

func (t *Task) MarkDone()

MarkDone marks the Target as done

func (*Task) RunAlwaysSignature

func (t *Task) RunAlwaysSignature()

RunAlwaysSignature generates a random signature that will make sure it is always run

type Worker

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

Worker can be assigned by the environment to work on a target

func NewWorker

func NewWorker(ctxt context.Context, wdchan chan bool) *Worker

NewWorker creates a new worker in a context and atttached to the channel it should report to when work is done.

func (*Worker) Free

func (w *Worker) Free() bool

Free reports if the Worker is free to take up new works

func (*Worker) Work

func (w *Worker) Work(b *Builder, t *Task)

Work tells the worker to start working on making the target.

func (*Worker) WorkingOn

func (w *Worker) WorkingOn() *Task

WorkingOn reports what the Worker currently is working on, if anything...

Jump to

Keyboard shortcuts

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