mirror of
https://github.com/golang/go
synced 2024-11-21 21:34:40 -07:00
undo CL 5754088 / cae9a7c0db06
broke builders ««« original CL description cmd/go: respect $GOBIN always Before, we only consulted $GOBIN for source code found in $GOROOT, but that's confusing to explain and less useful. The new behavior lets users set GOBIN=$HOME/bin and have all go-compiled binaries installed there. Fixes #3269. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5754088 »»» TBR=bradfitz CC=golang-dev https://golang.org/cl/5794065
This commit is contained in:
parent
bccafa7210
commit
bf09a8c970
@ -393,12 +393,11 @@ For example, you should not set <code>$GOHOSTARCH</code> to
|
|||||||
|
|
||||||
<p><code>$GOBIN</code>
|
<p><code>$GOBIN</code>
|
||||||
<p>
|
<p>
|
||||||
The location where Go binaries will be installed.
|
The location where binaries from the main repository will be installed.
|
||||||
|
XXX THIS MAY CHANGE TO BE AN OVERRIDE EVEN FOR GOPATH ENTRIES XXX
|
||||||
The default is <code>$GOROOT/bin</code>.
|
The default is <code>$GOROOT/bin</code>.
|
||||||
After installing, you will want to arrange to add this
|
After installing, you will want to arrange to add this
|
||||||
directory to your <code>$PATH</code>, so you can use the tools.
|
directory to your <code>$PATH</code>, so you can use the tools.
|
||||||
If <code>$GOBIN</code> is set, the <a href="/cmd/go">go command</a>
|
|
||||||
installs all commands there.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><code>$GOARM</code> (arm, default=6)</p>
|
<p><code>$GOARM</code> (arm, default=6)</p>
|
||||||
|
@ -199,8 +199,6 @@ along with their dependencies.
|
|||||||
|
|
||||||
For more about the build flags, see 'go help build'.
|
For more about the build flags, see 'go help build'.
|
||||||
For more about specifying packages, see 'go help packages'.
|
For more about specifying packages, see 'go help packages'.
|
||||||
For more about where packages and binaries are installed,
|
|
||||||
see 'go help gopath'.
|
|
||||||
|
|
||||||
See also: go build, go get, go clean.
|
See also: go build, go get, go clean.
|
||||||
`,
|
`,
|
||||||
@ -304,13 +302,20 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gobin = os.Getenv("GOBIN")
|
|
||||||
goroot = filepath.Clean(runtime.GOROOT())
|
goroot = filepath.Clean(runtime.GOROOT())
|
||||||
|
gobin = defaultGobin()
|
||||||
gorootSrcPkg = filepath.Join(goroot, "src/pkg")
|
gorootSrcPkg = filepath.Join(goroot, "src/pkg")
|
||||||
gorootPkg = filepath.Join(goroot, "pkg")
|
gorootPkg = filepath.Join(goroot, "pkg")
|
||||||
gorootSrc = filepath.Join(goroot, "src")
|
gorootSrc = filepath.Join(goroot, "src")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func defaultGobin() string {
|
||||||
|
if s := os.Getenv("GOBIN"); s != "" {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return filepath.Join(goroot, "bin")
|
||||||
|
}
|
||||||
|
|
||||||
func (b *builder) init() {
|
func (b *builder) init() {
|
||||||
var err error
|
var err error
|
||||||
b.print = fmt.Print
|
b.print = fmt.Print
|
||||||
@ -382,24 +387,18 @@ func goFilesPackage(gofiles []string) *Package {
|
|||||||
pkg.load(&stk, bp, err)
|
pkg.load(&stk, bp, err)
|
||||||
pkg.localPrefix = dirToImportPath(dir)
|
pkg.localPrefix = dirToImportPath(dir)
|
||||||
pkg.ImportPath = "command-line-arguments"
|
pkg.ImportPath = "command-line-arguments"
|
||||||
pkg.target = ""
|
|
||||||
|
|
||||||
if pkg.Name == "main" {
|
if *buildO == "" {
|
||||||
_, elem := filepath.Split(gofiles[0])
|
if pkg.Name == "main" {
|
||||||
exe := elem[:len(elem)-len(".go")] + exeSuffix
|
_, elem := filepath.Split(gofiles[0])
|
||||||
if *buildO == "" {
|
*buildO = elem[:len(elem)-len(".go")] + exeSuffix
|
||||||
*buildO = exe
|
} else {
|
||||||
}
|
|
||||||
if gobin != "" {
|
|
||||||
pkg.target = filepath.Join(gobin, exe)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if *buildO == "" {
|
|
||||||
*buildO = pkg.Name + ".a"
|
*buildO = pkg.Name + ".a"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pkg.target = ""
|
||||||
|
pkg.Target = ""
|
||||||
pkg.Stale = true
|
pkg.Stale = true
|
||||||
pkg.Target = pkg.target
|
|
||||||
|
|
||||||
computeStale(pkg)
|
computeStale(pkg)
|
||||||
return pkg
|
return pkg
|
||||||
@ -463,13 +462,13 @@ func (b *builder) action(mode buildMode, depMode buildMode, p *Package) *action
|
|||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
a.link = p.Name == "main"
|
if p.local {
|
||||||
if p.local && (!a.link || p.target == "") {
|
|
||||||
// Imported via local path. No permanent target.
|
// Imported via local path. No permanent target.
|
||||||
mode = modeBuild
|
mode = modeBuild
|
||||||
}
|
}
|
||||||
a.objdir = filepath.Join(b.work, a.p.ImportPath, "_obj") + string(filepath.Separator)
|
a.objdir = filepath.Join(b.work, a.p.ImportPath, "_obj") + string(filepath.Separator)
|
||||||
a.objpkg = buildToolchain.pkgpath(b.work, a.p)
|
a.objpkg = buildToolchain.pkgpath(b.work, a.p)
|
||||||
|
a.link = p.Name == "main"
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case modeInstall:
|
case modeInstall:
|
||||||
|
@ -453,9 +453,7 @@ the final element, not the entire path. That is, the
|
|||||||
command with source in DIR/src/foo/quux is installed into
|
command with source in DIR/src/foo/quux is installed into
|
||||||
DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
|
DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
|
||||||
so that you can add DIR/bin to your PATH to get at the
|
so that you can add DIR/bin to your PATH to get at the
|
||||||
installed commands. If the GOBIN environment variable is
|
installed commands.
|
||||||
set, commands are installed to the directory it names instead
|
|
||||||
of DIR/bin.
|
|
||||||
|
|
||||||
Here's an example directory layout:
|
Here's an example directory layout:
|
||||||
|
|
||||||
|
@ -209,9 +209,7 @@ the final element, not the entire path. That is, the
|
|||||||
command with source in DIR/src/foo/quux is installed into
|
command with source in DIR/src/foo/quux is installed into
|
||||||
DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
|
DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
|
||||||
so that you can add DIR/bin to your PATH to get at the
|
so that you can add DIR/bin to your PATH to get at the
|
||||||
installed commands. If the GOBIN environment variable is
|
installed commands.
|
||||||
set, commands are installed to the directory it names instead
|
|
||||||
of DIR/bin.
|
|
||||||
|
|
||||||
Here's an example directory layout:
|
Here's an example directory layout:
|
||||||
|
|
||||||
|
@ -276,9 +276,6 @@ func expandScanner(err error) error {
|
|||||||
// load populates p using information from bp, err, which should
|
// load populates p using information from bp, err, which should
|
||||||
// be the result of calling build.Context.Import.
|
// be the result of calling build.Context.Import.
|
||||||
func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package {
|
func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package {
|
||||||
if gobin != "" {
|
|
||||||
bp.BinDir = gobin
|
|
||||||
}
|
|
||||||
p.copyBuild(bp)
|
p.copyBuild(bp)
|
||||||
|
|
||||||
// The localPrefix is the path we interpret ./ imports relative to.
|
// The localPrefix is the path we interpret ./ imports relative to.
|
||||||
@ -541,6 +538,7 @@ func loadPackage(arg string, stk *importStack) *Package {
|
|||||||
bp, err := build.ImportDir(filepath.Join(gorootSrc, arg), 0)
|
bp, err := build.ImportDir(filepath.Join(gorootSrc, arg), 0)
|
||||||
bp.ImportPath = arg
|
bp.ImportPath = arg
|
||||||
bp.Goroot = true
|
bp.Goroot = true
|
||||||
|
bp.BinDir = gobin
|
||||||
bp.Root = goroot
|
bp.Root = goroot
|
||||||
bp.SrcRoot = gorootSrc
|
bp.SrcRoot = gorootSrc
|
||||||
p := new(Package)
|
p := new(Package)
|
||||||
|
Loading…
Reference in New Issue
Block a user