diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-20 21:30:16 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-20 21:30:16 +0000 |
commit | f0e064fb9a99259eb91d6e355deca7dc16ca3c85 (patch) | |
tree | e4dce54032eeb6f0868277e245ff6a364cccc0ea /libgo | |
parent | 04425c27c7118241802bab6d05207e7d63f8cf88 (diff) |
cmd: Use correct install tool dir with gccgo
When using the go command built from gccgo to build and
install a go tool, use the value from runtime GCCGOTOOLDIR as
the install directory.
This also fixes the output from 'go tool' when used with the
gccgo-built go command, to only include the go tools and not
other binaries found in the same directory.
Reviewed-on: https://go-review.googlesource.com/16516
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230677 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/cmd/go/pkg.go | 6 | ||||
-rw-r--r-- | libgo/go/cmd/go/tool.go | 23 |
2 files changed, 27 insertions, 2 deletions
diff --git a/libgo/go/cmd/go/pkg.go b/libgo/go/cmd/go/pkg.go index ff5236e90ab..3270a8b5236 100644 --- a/libgo/go/cmd/go/pkg.go +++ b/libgo/go/cmd/go/pkg.go @@ -785,7 +785,11 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package if goTools[p.ImportPath] == toTool { // This is for 'go tool'. // Override all the usual logic and force it into the tool directory. - p.target = filepath.Join(gorootPkg, "tool", full) + if buildContext.Compiler == "gccgo" { + p.target = filepath.Join(runtime.GCCGOTOOLDIR, elem) + } else { + p.target = filepath.Join(gorootPkg, "tool", full) + } } if p.target != "" && buildContext.GOOS == "windows" { p.target += ".exe" diff --git a/libgo/go/cmd/go/tool.go b/libgo/go/cmd/go/tool.go index 937ca1f306c..4b9493937aa 100644 --- a/libgo/go/cmd/go/tool.go +++ b/libgo/go/cmd/go/tool.go @@ -39,6 +39,12 @@ var ( toolN bool ) +// List of go tools found in the gccgo tool directory. +// Other binaries could be in the same directory so don't +// show those with the 'go tool' command. + +var gccgoTools = []string{"cgo", "fix", "cover", "godoc", "vet"} + func init() { cmdTool.Flag.BoolVar(&toolN, "n", false, "") } @@ -146,6 +152,21 @@ func listTools() { if toolIsWindows && strings.HasSuffix(name, toolWindowsExtension) { name = name[:len(name)-len(toolWindowsExtension)] } - fmt.Println(name) + + // The tool directory used by gccgo will have other binaries + // in additions to go tools. Only display go tools for this list. + + if buildContext.Compiler == "gccgo" { + for _, tool := range gccgoTools { + if tool == name { + fmt.Println(name) + } + } + } else { + + // Not gccgo, list all the tools found in this dir + + fmt.Println(name) + } } } |