package work
import "cmd/go/internal/work"
Index ¶
- Variables
- func AddBuildFlags(cmd *base.Command, mask BuildFlagMask)
- func AddModCommonFlags(cmd *base.Command)
- func BuildInit()
- func BuildInstallFunc(b *Builder, a *Action) (err error)
- func CheckGOOSARCHPair(goos, goarch string) error
- func FindExecCmd() []string
- func InstallPackages(patterns []string, pkgs []*load.Package)
- type Action
- func (a *Action) BuildActionID() string
- func (a *Action) BuildContentID() string
- func (a *Action) BuildID() string
- func (a *Action) BuiltTarget() string
- type BuildFlagMask
- type BuildMode
- type Builder
- func (b *Builder) AutoAction(mode, depMode BuildMode, p *load.Package) *Action
- func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error)
- func (b *Builder) CompileAction(mode, depMode BuildMode, p *load.Package) *Action
- func (b *Builder) Do(root *Action)
- func (b *Builder) GccCmd(incdir, workdir string) []string
- func (b *Builder) GxxCmd(incdir, workdir string) []string
- func (b *Builder) Init()
- func (b *Builder) LinkAction(mode, depMode BuildMode, p *load.Package) *Action
- func (b *Builder) Mkdir(dir string) error
- func (b *Builder) NewObjdir() string
- func (b *Builder) PkgconfigCmd() string
- func (b *Builder) Showcmd(dir string, format string, args ...interface{})
- func (b *Builder) Symlink(oldname, newname string) error
- func (b *Builder) VetAction(mode, depMode BuildMode, p *load.Package) *Action
Variables ¶
var BuildToolchain toolchain = noToolchain{}
var CmdBuild = &base.Command{ UsageLine: "go build [-o output] [-i] [build flags] [packages]", Short: "compile packages and dependencies", Long: "" /* 6414 byte string literal not displayed */, }
var CmdInstall = &base.Command{ UsageLine: "go install [-i] [build flags] [packages]", Short: "compile and install packages and dependencies", Long: "" /* 760 byte string literal not displayed */, }
var ExecCmd []string
ExecCmd is the command to use to run user binaries. Normally it is empty, meaning run the binaries directly. If cross-compiling and running on a remote system or simulator, it is typically go_GOOS_GOARCH_exec, with the target GOOS and GOARCH substituted. The -exec flag overrides these defaults.
var GccgoName, GccgoBin string
var VetExplicit bool
VetExplicit records whether the vet flags were set explicitly on the command line.
var VetFlags []string
VetFlags are the default flags to pass to vet. The caller is expected to set them before executing any vet actions.
var VetTool string
VetTool is the path to an alternate vet tool binary. The caller is expected to set it (if needed) before executing any vet actions.
Functions ¶
func AddBuildFlags ¶
func AddBuildFlags(cmd *base.Command, mask BuildFlagMask)
AddBuildFlags adds the flags common to the build, clean, get, install, list, run, and test commands.
func AddModCommonFlags ¶
AddModCommonFlags adds the module-related flags common to build commands and 'go mod' subcommands.
func BuildInit ¶
func BuildInit()
func BuildInstallFunc ¶
BuildInstallFunc is the action for installing a single package or executable.
func CheckGOOSARCHPair ¶
func FindExecCmd ¶
func FindExecCmd() []string
FindExecCmd derives the value of ExecCmd to use. It returns that value and leaves ExecCmd set for direct use.
func InstallPackages ¶
Types ¶
type Action ¶
type Action struct { Mode string // description of action operation Package *load.Package // the package this action works on Deps []*Action // actions that must happen before this one Func func(*Builder, *Action) error // the action itself (nil = no-op) IgnoreFail bool // whether to run f even if dependencies fail TestOutput *bytes.Buffer // test output buffer Args []string // additional args for runProgram TryCache func(*Builder, *Action) bool // callback for cache bypass // Generated files, directories. Objdir string // directory for intermediate objects Target string // goal of the action: the created package or executable VetxOnly bool // Mode=="vet": only being called to supply info about dependencies Failed bool // whether the action failed // contains filtered or unexported fields }
An Action represents a single action in the action graph.
func (*Action) BuildActionID ¶
BuildActionID returns the action ID section of a's build ID.
func (*Action) BuildContentID ¶
BuildContentID returns the content ID section of a's build ID.
func (*Action) BuildID ¶
BuildID returns a's build ID.
func (*Action) BuiltTarget ¶
BuiltTarget returns the actual file that was built. This differs from Target when the result was cached.
type BuildFlagMask ¶
type BuildFlagMask int
const ( DefaultBuildFlags BuildFlagMask = 0 OmitModFlag BuildFlagMask = 1 << iota OmitModCommonFlags )
type BuildMode ¶
type BuildMode int
BuildMode specifies the build mode: are we just building things or also installing the results?
type Builder ¶
type Builder struct { WorkDir string // the temporary work directory (ends in filepath.Separator) Print func(args ...interface{}) (int, error) IsCmdList bool // running as part of go list; set p.Stale and additional fields below NeedError bool // list needs p.Error NeedExport bool // list needs p.Export NeedCompiledGoFiles bool // list needs p.CompiledGoFIles // contains filtered or unexported fields }
A Builder holds global state about a build. It does not hold per-package state, because we build packages in parallel, and the builder is shared.
func (*Builder) AutoAction ¶
AutoAction returns the "right" action for go build or go install of p.
func (*Builder) CFlags ¶
func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error)
CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo.
func (*Builder) CompileAction ¶
CompileAction returns the action for compiling and possibly installing (according to mode) the given package. The resulting action is only for building packages (archives), never for linking executables. depMode is the action (build or install) to use when building dependencies. To turn package main into an executable, call b.Link instead.
func (*Builder) Do ¶
do runs the action graph rooted at root.
func (*Builder) GccCmd ¶
gccCmd returns a gcc command line prefix defaultCC is defined in zdefaultcc.go, written by cmd/dist.
func (*Builder) GxxCmd ¶
gxxCmd returns a g++ command line prefix defaultCXX is defined in zdefaultcc.go, written by cmd/dist.
func (*Builder) Init ¶
func (b *Builder) Init()
func (*Builder) LinkAction ¶
LinkAction returns the action for linking p into an executable and possibly installing the result (according to mode). depMode is the action (build or install) to use when compiling dependencies.
func (*Builder) Mkdir ¶
mkdir makes the named directory.
func (*Builder) NewObjdir ¶
NewObjdir returns the name of a fresh object directory under b.WorkDir. It is up to the caller to call b.Mkdir on the result at an appropriate time. The result ends in a slash, so that file names in that directory can be constructed with direct string addition.
NewObjdir must be called only from a single goroutine at a time, so it is safe to call during action graph construction, but it must not be called during action graph execution.
func (*Builder) PkgconfigCmd ¶
PkgconfigCmd returns a pkg-config binary name defaultPkgConfig is defined in zdefaultcc.go, written by cmd/dist.
func (*Builder) Showcmd ¶
showcmd prints the given command to standard output for the implementation of -n or -x.
func (*Builder) Symlink ¶
symlink creates a symlink newname -> oldname.
func (*Builder) VetAction ¶
VetAction returns the action for running go vet on package p. It depends on the action for compiling p. If the caller may be causing p to be installed, it is up to the caller to make sure that the install depends on (runs after) vet.
Source Files ¶
action.go build.go buildid.go exec.go gc.go gccgo.go init.go security.go
- Version
- v1.14.13
- Published
- Dec 3, 2020
- Platform
- linux/amd64
- Imports
- 33 packages
- Last checked
- 2 minutes ago –
Tools for package owners.