Documentation
¶
Overview ¶
Package gomkore implements the core model of gomk for the representation of buildable projects. It uses idiomatic Go error handling, which can make writing gomk build scripts a bit cumbersome. However, this package serves as a solid foundation for implementing build strategies, such as updating artifacts depending on their prerequisites or propagating artifact changes to dependent artifacts. The core concepts are Project, Goal and Action. An easy-to-use wrapper for everyday use in build scripts is provided by the gomk package.
Index ¶
- func Clean(prj *Project, dryrun bool, tr *Trace) error
- type Abstract
- type Action
- func (a *Action) LastBuild() BuildID
- func (a *Action) Premise(i int) *Goal
- func (a *Action) Premises() []*Goal
- func (a *Action) Project() *Project
- func (a *Action) Result(i int) *Goal
- func (a *Action) Results() []*Goal
- func (a *Action) Run(tr *Trace, env *Env) (BuildID, error)
- func (a *Action) String() string
- func (a *Action) WriteHash(h hash.Hash, env *Env) (bool, error)
- type Artefact
- type BuildID
- type BuildTracer
- type Builder
- func (bd *Builder) Describe(*Action, *Env) string
- func (bd *Builder) Do(tr *Trace, a *Action, env *Env) error
- func (bd *Builder) Goals(gs ...*Goal) error
- func (bd *Builder) NamedGoals(prj *Project, names ...string) error
- func (bd *Builder) Project(prj *Project) error
- func (up *Builder) Trace() *Trace
- func (bd *Builder) WriteHash(h hash.Hash, a *Action, env *Env) (bool, error)
- type Changer
- type CleanTracer
- type Env
- type Goal
- func (g *Goal) CheckPreTimes(tr *Trace) (chgs []int, err error)
- func (g *Goal) IsAbstract() bool
- func (g *Goal) LockBuild() BuildID
- func (g *Goal) LockPreActions(gid uintptr)
- func (g *Goal) Name() string
- func (g *Goal) PostAction(i int) *Action
- func (g *Goal) PreAction(i int) *Action
- func (g *Goal) PremiseOf() []*Action
- func (g *Goal) Project() *Project
- func (g *Goal) ResultOf() []*Action
- func (g *Goal) String() string
- func (g *Goal) UnlockPreActions()
- func (g *Goal) UpdateConsistency(involved *Goal) error
- type GoalFactory
- type NonXEnvKeys
- type Operation
- type Project
- func (prj *Project) AbsPath(rel string) (string, error)
- func (prj *Project) Actions() []*Action
- func (prj *Project) Build() BuildID
- func (prj *Project) FindGoal(name string) *Goal
- func (prj *Project) Goal(atf Artefact) (*Goal, error)
- func (prj *Project) Goals(addTo []*Goal) []*Goal
- func (prj *Project) Key() any
- func (prj *Project) Leafs() (ls []*Goal)
- func (prj *Project) LockBuild() BuildID
- func (prj *Project) Name(in *Project) string
- func (prj *Project) NewAction(premises, results []*Goal, op Operation) (*Action, error)
- func (prj *Project) RelPath(p string) (dir string, err error)
- func (prj *Project) RelPathTo(base, relTarget string) (string, error)
- func (prj *Project) Roots() (rs []*Goal)
- func (prj *Project) StateAt(in *Project) (time.Time, error)
- func (prj *Project) String() string
- type RemovableArtefact
- type Trace
- func (t *Trace) Build() BuildID
- func (t *Trace) Ctx() context.Context
- func (t *Trace) Debug(msg string, args ...any)
- func (t *Trace) Info(msg string, args ...any)
- func (t *Trace) Path() string
- func (t *Trace) String() string
- func (t *Trace) TopID() uint64
- func (t *Trace) TopTag() string
- func (t *Trace) Warn(msg string, args ...any)
- type Tracer
- type TracerCommon
- type UpdateMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
An Action is something you can do in your Project to achieve at least one Goal. The actual implementation of the action is an Operation. An action without an operation is an "implicit" action, i.e. if all its premises are true, all results of the action are implicitly given.
func (*Action) Run ¶
Must not run concurrently, see Goal.LockPreActions and [tryLock]
type Artefact ¶
type Artefact interface { Key() any // Name returns the name of the artefact that must be unique in the Project. Name(in *Project) string // StateAs returns the time at which the artefact reached its current state. // If this cannot be provided, the zero Time is returned. StateAt(in *Project) (time.Time, error) }
Artefact represents the tangible outcome of a Goal being reached. A special case is the Abstract artefact.
type BuildTracer ¶ added in v0.11.13
type BuildTracer interface { TracerCommon RunAction(*Trace, *Action) RunImplicitAction(*Trace, *Action) ScheduleResTimeZero(t *Trace, a *Action, res *Goal) ScheduleNotPremises(t *Trace, a *Action, res *Goal) SchedulePreTimeZero(t *Trace, a *Action, res, pre *Goal) ScheduleOutdated(t *Trace, a *Action, res, pre *Goal) CheckGoal(t *Trace, g *Goal) GoalUpToDate(t *Trace, g *Goal) GoalNeedsActions(t *Trace, g *Goal, n int) }
type Builder ¶ added in v0.11.13
type Builder struct {
// contains filtered or unexported fields
}
TODO Add a "dry-run" option
func (*Builder) NamedGoals ¶ added in v0.11.13
type CleanTracer ¶ added in v0.11.13
type CleanTracer interface { TracerCommon RemoveArtefact(*Trace, *Goal) }
type Goal ¶
type Goal struct { UpdateMode UpdateMode Artefact Artefact Removable bool sync.Mutex // contains filtered or unexported fields }
A Goal is something you want to achieve in your Project. Each goal is associated with an Artefact – generally something tangible that is considered available and up-to-date when the goal is achieved. A special case is the Abstract artefact that simply provides a name for abstract goals. Abstract goals do not deliver tangible results.
Goals can be achieved through actions (Action). A goal can be the result of several actions at the same time. It then depends on the target's UpdateMode whether and how the actions contribute to the target. On the other hand, a goal can also be the premise for one or more actions. Such dependent actions should not be carried out before the goal is reached.
func (*Goal) CheckPreTimes ¶ added in v0.11.12
CheckPreTimes check if g needs to be updated according to the timestamps of all of its premises.
func (*Goal) IsAbstract ¶
func (*Goal) LockBuild ¶
LockBuild locks g once for the current build of g's project. If g was already locked for the build 0 is returned.
func (*Goal) LockPreActions ¶
func (*Goal) PostAction ¶ added in v0.11.12
PostAction returns Goal.PremiseOf()[i]
func (*Goal) PreAction ¶ added in v0.11.12
PreAction returns Goal.ResultOf()[i]
func (*Goal) UnlockPreActions ¶
func (g *Goal) UnlockPreActions()
func (*Goal) UpdateConsistency ¶
Requires 'involved' to really be involved
type GoalFactory ¶ added in v0.11.14
type NonXEnvKeys ¶
type NonXEnvKeys []string
func (NonXEnvKeys) Error ¶
func (e NonXEnvKeys) Error() string
func (NonXEnvKeys) Is ¶
func (NonXEnvKeys) Is(target error) bool
type Project ¶
func NewProject ¶
func (*Project) NewAction ¶
NewAction creates a new Action in project prj. There must be at least one result. All premises and results must belong to the same project prj.
type RemovableArtefact ¶ added in v0.11.13
type Tracer ¶ added in v0.11.13
type Tracer interface { BuildTracer CleanTracer }
type TracerCommon ¶ added in v0.11.13
type TracerCommon interface { Debug(t *Trace, msg string, args ...any) Info(t *Trace, msg string, args ...any) Warn(t *Trace, msg string, args ...any) StartProject(t *Trace, p *Project, activity string) DoneProject(t *Trace, p *Project, activity string, dt time.Duration) SetupActionEnv(t *Trace, env *Env) (*Env, error) CloseActionEnv(t *Trace, env *Env) error }
type UpdateMode ¶
type UpdateMode uint
const ( // All actions must be run to reach the goal. UpdAllActions UpdateMode = 0 // All actions with changed state must be run to reach the goal. UpdSomeActions UpdateMode = 1 // Only one of the actions with changed state has to be run to reach the // goal. UpdAnyAction UpdateMode = 2 // Only one action must have changed state. Then the goal is reached by // running that action. UpdOneAction UpdateMode = 3 // An unordered update mode allows actions of the current goal to be run in // any order or even concurrently. Otherwise, the actions must be run one // after the other in the specified order. UpdUnordered UpdateMode = 4 )
func (UpdateMode) Actions ¶
func (m UpdateMode) Actions() UpdateMode
func (UpdateMode) Ordered ¶
func (m UpdateMode) Ordered() bool