ImportComment string `json:",omitempty"` // path in import comment on package statement
Name string `json:",omitempty"` // package name
Doc string `json:",omitempty"` // package documentation string
- Target string `json:",omitempty"` // install path
+ Target string `json:",omitempty"` // installed target for this package (may be executable)
Shlib string `json:",omitempty"` // the shared library that contains this package (only set when -linkshared)
Goroot bool `json:",omitempty"` // is this package found in the Go root?
Standard bool `json:",omitempty"` // is this package part of the standard Go library?
// Unexported fields are not part of the public API.
Build *build.Package
Imports []*Package // this package's direct imports
- Target string // installed file for this package (may be executable)
ForceLibrary bool // this package is a library (even if named "main")
Cmdline bool // defined by files listed on command line
Local bool // imported via local path (./ or ../)
}
if p.Internal.Build.BinDir != "" {
// Install to GOBIN or bin of GOPATH entry.
- p.Internal.Target = filepath.Join(p.Internal.Build.BinDir, elem)
+ p.Target = filepath.Join(p.Internal.Build.BinDir, elem)
if !p.Goroot && strings.Contains(elem, "/") && cfg.GOBIN != "" {
// Do not create $GOBIN/goos_goarch/elem.
- p.Internal.Target = ""
+ p.Target = ""
p.Internal.GobinSubdir = true
}
}
if InstallTargetDir(p) == ToTool {
// This is for 'go tool'.
// Override all the usual logic and force it into the tool directory.
- p.Internal.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
+ p.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
}
- if p.Internal.Target != "" && cfg.BuildContext.GOOS == "windows" {
- p.Internal.Target += ".exe"
+ if p.Target != "" && cfg.BuildContext.GOOS == "windows" {
+ p.Target += ".exe"
}
} else if p.Internal.Local {
// Local import turned into absolute path.
// No permanent install target.
- p.Internal.Target = ""
+ p.Target = ""
} else {
- p.Internal.Target = p.Internal.Build.PkgObj
+ p.Target = p.Internal.Build.PkgObj
if cfg.BuildLinkshared {
- shlibnamefile := p.Internal.Target[:len(p.Internal.Target)-2] + ".shlibname"
+ shlibnamefile := p.Target[:len(p.Target)-2] + ".shlibname"
shlib, err := ioutil.ReadFile(shlibnamefile)
if err != nil && !os.IsNotExist(err) {
base.Fatalf("reading shlibname: %v", err)
// unsafe is a fake package.
if p.Standard && (p.ImportPath == "unsafe" || cfg.BuildContext.Compiler == "gccgo") {
- p.Internal.Target = ""
+ p.Target = ""
}
- p.Target = p.Internal.Target
// If cgo is not enabled, ignore cgo supporting sources
// just as we ignore go files containing import "C".
// if a rebuild is needed, that rebuild attempt will produce a useful error.
// (Some commands, such as 'go list', do not attempt to rebuild.)
if p.BinaryOnly {
- if p.Internal.Target == "" {
+ if p.Target == "" {
// Fail if a build is attempted.
return true, "no source code for package, but no install target"
}
- if _, err := os.Stat(p.Internal.Target); err != nil {
+ if _, err := os.Stat(p.Target); err != nil {
// Fail if a build is attempted.
return true, "no source code for package, but cannot access install target: " + err.Error()
}
}
// If there's no install target, we have to rebuild.
- if p.Internal.Target == "" {
+ if p.Target == "" {
return true, "no install target"
}
// Package is stale if completely unbuilt.
- fi, err := os.Stat(p.Internal.Target)
+ fi, err := os.Stat(p.Target)
if err != nil {
return true, "cannot stat install target"
}
// Package is stale if a dependency is, or if a dependency is newer.
for _, p1 := range p.Internal.Imports {
- if p1.Internal.Target != "" && olderThan(p1.Internal.Target) {
+ if p1.Target != "" && olderThan(p1.Target) {
return true, "newer dependency"
}
}
stk.Pop()
pkg.Internal.LocalPrefix = dirToImportPath(dir)
pkg.ImportPath = "command-line-arguments"
- pkg.Internal.Target = ""
+ pkg.Target = ""
if pkg.Name == "main" {
_, elem := filepath.Split(gofiles[0])
cfg.BuildO = exe
}
if cfg.GOBIN != "" {
- pkg.Internal.Target = filepath.Join(cfg.GOBIN, exe)
+ pkg.Target = filepath.Join(cfg.GOBIN, exe)
}
}
- pkg.Target = pkg.Internal.Target
pkg.Stale = true
pkg.StaleReason = "files named on command line"
base.Fatalf("no packages to build")
}
p := pkgs[0]
- p.Internal.Target = cfg.BuildO
+ p.Target = cfg.BuildO
p.Stale = true // must build - not up to date
p.StaleReason = "build -o flag in use"
a := b.AutoAction(ModeInstall, depMode, p)
// depMode is the action (build or install) to use when building dependencies.
// To turn package main into an executable, call b.Link instead.
func (b *Builder) CompileAction(mode, depMode BuildMode, p *load.Package) *Action {
- if mode == ModeInstall && p.Internal.Local && p.Internal.Target == "" {
+ if mode == ModeInstall && p.Internal.Local && p.Target == "" {
// Imported via local path. No permanent target.
mode = ModeBuild
}
if cfg.BuildToolchainName == "gccgo" {
// the target name is needed for cgo.
a.Mode = "gccgo stdlib"
- a.Target = p.Internal.Target
+ a.Target = p.Target
a.Func = nil
return a
}
}
- if !p.Stale && p.Internal.Target != "" && p.Name != "main" {
- // p.Stale==false implies that p.Internal.Target is up-to-date.
+ if !p.Stale && p.Target != "" && p.Name != "main" {
+ // p.Stale==false implies that p.Target is up-to-date.
// Record target name for use by actions depending on this one.
a.Mode = "use installed"
- a.Target = p.Internal.Target
+ a.Target = p.Target
a.Func = nil
a.built = a.Target
return a
Package: p,
}
- if !p.Stale && p.Internal.Target != "" {
- // p.Stale==false implies that p.Internal.Target is up-to-date.
+ if !p.Stale && p.Target != "" {
+ // p.Stale==false implies that p.Target is up-to-date.
// Record target name for use by actions depending on this one.
a.Mode = "use installed"
a.Func = nil
- a.Target = p.Internal.Target
+ a.Target = p.Target
a.built = a.Target
return a
}
name := "a.out"
if p.Internal.ExeName != "" {
name = p.Internal.ExeName
- } else if (cfg.Goos == "darwin" || cfg.Goos == "windows") && cfg.BuildBuildmode == "c-shared" && p.Internal.Target != "" {
+ } else if (cfg.Goos == "darwin" || cfg.Goos == "windows") && cfg.BuildBuildmode == "c-shared" && p.Target != "" {
// On OS X, the linker output name gets recorded in the
// shared library's LC_ID_DYLIB load command.
// The code invoking the linker knows to pass only the final
// we'll install it as; otherwise the library is only loadable as "a.out".
// On Windows, DLL file name is recorded in PE file
// export section, so do like on OS X.
- _, name = filepath.Split(p.Internal.Target)
+ _, name = filepath.Split(p.Target)
}
a.Target = a.Objdir + filepath.Join("exe", name) + cfg.ExeSuffix
a.built = a.Target
Package: p,
Objdir: a1.Objdir,
Deps: []*Action{a1},
- Target: p.Internal.Target,
- built: p.Internal.Target,
+ Target: p.Target,
+ built: p.Target,
}
b.addInstallHeaderAction(a)
return a
}
for _, a2 := range buildAction.Deps[0].Deps {
p := a2.Package
- if p.Internal.Target == "" {
+ if p.Target == "" {
continue
}
a.Deps = append(a.Deps, &Action{
Mode: "shlibname",
Package: p,
Func: (*Builder).installShlibname,
- Target: strings.TrimSuffix(p.Internal.Target, ".a") + ".shlibname",
+ Target: strings.TrimSuffix(p.Target, ".a") + ".shlibname",
Deps: []*Action{a.Deps[0]},
})
}