Home | History | Annotate | Download | only in work

Lines Matching defs:Action

5 // Action graph creation (planning).
34 actionCache map[cacheKey]*Action // a cache of already-constructed actions
56 // NOTE: Much of Action would not need to be exported if not for test.
59 // An Action represents a single action in the action graph.
60 type Action struct {
61 Mode string // description of action operation
62 Package *load.Package // the package this action works on
63 Deps []*Action // actions that must happen before this one
64 Func func(*Builder, *Action) error // the action itself (nil = no-op)
69 triggers []*Action // inverse of deps
73 TryCache func(*Builder, *Action) bool // callback for cache bypass
77 Target string // goal of the action: the created package or executable
79 actionID cache.ActionID // cache ID of action input
80 buildID string // build ID of action output
89 Failed bool // whether the action failed
92 // BuildActionID returns the action ID section of a's build ID.
93 func (a *Action) BuildActionID() string { return actionID(a.buildID) }
96 func (a *Action) BuildContentID() string { return contentID(a.buildID) }
99 func (a *Action) BuildID() string { return a.buildID }
103 func (a *Action) BuiltTarget() string { return a.built }
106 type actionQueue []*Action
112 func (q *actionQueue) Push(x interface{}) { *q = append(*q, x.(*Action)) }
120 func (q *actionQueue) push(a *Action) {
124 func (q *actionQueue) pop() *Action {
125 return heap.Pop(q).(*Action)
143 // cacheKey is the key for the action cache.
149 func actionGraphJSON(a *Action) string {
150 var workq []*Action
151 var inWorkq = make(map[*Action]int)
153 add := func(a *Action) {
193 fmt.Fprintf(os.Stderr, "go: writing debug action graph: %v\n", err)
214 b.actionCache = make(map[cacheKey]*Action)
253 // so it is safe to call during action graph construction, but it must not
254 // be called during action graph execution.
293 // cacheAction looks up {mode, p} in the cache and returns the resulting action.
294 // If the cache has no such action, f() is recorded and returned.
297 func (b *Builder) cacheAction(mode string, p *load.Package, f func() *Action) *Action {
306 // AutoAction returns the "right" action for go build or go install of p.
307 func (b *Builder) AutoAction(mode, depMode BuildMode, p *load.Package) *Action {
314 // CompileAction returns the action for compiling and possibly installing
315 // (according to mode) the given package. The resulting action is only
317 // depMode is the action (build or install) to use when building dependencies.
319 func (b *Builder) CompileAction(mode, depMode BuildMode, p *load.Package) *Action {
329 // Construct package build action.
330 a := b.cacheAction("build", p, func() *Action {
331 a := &Action{
364 // Construct install action.
372 // VetAction returns the action for running go vet on package p.
373 // It depends on the action for compiling p.
376 func (b *Builder) VetAction(mode, depMode BuildMode, p *load.Package) *Action {
377 // Construct vet action.
378 a := b.cacheAction("vet", p, func() *Action {
388 a := &Action{
391 Deps: []*Action{a1, aFmt},
406 // LinkAction returns the action for linking p into an executable
408 // depMode is the action (build or install) to use when compiling dependencies.
409 func (b *Builder) LinkAction(mode, depMode BuildMode, p *load.Package) *Action {
410 // Construct link action.
411 a := b.cacheAction("link", p, func() *Action {
412 a := &Action{
419 a.Deps = []*Action{a1}
450 // In order for that linkActionID call to compute the right action ID, all the
453 a1.Deps = append(a1.Deps, &Action{Mode: "nop", Deps: a.Deps[1:]})
464 // installAction returns the action for installing the result of a1.
465 func (b *Builder) installAction(a1 *Action, mode BuildMode) *Action {
466 // Because we overwrite the build action with the install action below,
467 // a1 may already be an install action fetched from the "build" cache key,
477 // If there's no actual action to build a1,
485 return b.cacheAction(a1.Mode+"-install", p, func() *Action {
491 // Make a private copy of a1 (the build action),
493 buildAction := new(Action)
496 // Overwrite a1 with the install action.
498 // point at a1 for the build action; now they will
499 // point at a1 and get the install action.
500 // We also leave a1 in the action cache as the result
504 *a1 = Action{
509 Deps: []*Action{buildAction},
521 // addTransitiveLinkDeps adds to the link action a all packages
530 func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) {
534 // TODO(rsc): Eliminate the standard ones from the action graph,
536 workq := []*Action{a1}
551 a2 = a2.Deps[0] // walk children of "build" action
576 // addInstallHeaderAction adds an install header action to a, if needed.
577 // The action a should be an install action as generated by either
579 // and so a.Deps[0] is the corresponding build action.
580 func (b *Builder) addInstallHeaderAction(a *Action) {
593 ah := &Action{
596 Deps: []*Action{a.Deps[0]},
605 // buildmodeShared takes the "go build" action a1 into the building of a shared library of a1.Deps.
607 func (b *Builder) buildmodeShared(mode, depMode BuildMode, args []string, pkgs []*load.Package, a1 *Action) *Action {
615 // linkSharedAction takes a grouping action a1 corresponding to a list of built packages
616 // and returns an action that links them together into a shared library with the name shlib.
619 func (b *Builder) linkSharedAction(mode, depMode BuildMode, shlib string, a1 *Action) *Action {
622 a := b.cacheAction("build-shlib "+shlib, nil, func() *Action {
627 a1 = &Action{
653 a := &Action{
658 Deps: []*Action{a1},
662 add := func(a1 *Action, pkg string, force bool) {
701 a = b.cacheAction("install-shlib "+shlib, nil, func() *Action {
724 a := &Action{
728 Deps: []*Action{buildAction},
736 a.Deps = append(a.Deps, &Action{
741 Deps: []*Action{a.Deps[0]},