Commit 050f3780 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/go: add more env variables to "go bug"

CL 31330 added more envvars to "go env".
This CL brings them to "go bug" as well.

Change-Id: Iae122072c8178007eda8b765aaa3f38c3c6e39a0
Reviewed-on: https://go-review.googlesource.com/32011
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent d8d44528
......@@ -39,7 +39,9 @@ func runBug(cmd *Command, args []string) {
fmt.Fprint(&buf, "#### System details\n\n")
fmt.Fprintln(&buf, "```")
fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
for _, e := range mkEnv() {
env := mkEnv()
env = append(env, extraEnvVars()...)
for _, e := range env {
fmt.Fprintf(&buf, "%s=\"%s\"\n", e.name, e.value)
}
printOSDetails(&buf)
......
......@@ -88,21 +88,24 @@ func findEnv(env []envVar, name string) string {
return ""
}
func runEnv(cmd *Command, args []string) {
env := mkEnv()
// Add these environment variables here so they do not leak
// into child processes.
// extraEnvVars returns environment variables that should not leak into child processes.
func extraEnvVars() []envVar {
var b builder
b.init()
cppflags, cflags, cxxflags, fflags, ldflags := b.cflags(&Package{})
env = append(env,
envVar{"PKG_CONFIG", b.pkgconfigCmd()},
envVar{"CGO_CFLAGS", strings.Join(cflags, " ")},
envVar{"CGO_CPPFLAGS", strings.Join(cppflags, " ")},
envVar{"CGO_CXXFLAGS", strings.Join(cxxflags, " ")},
envVar{"CGO_FFLAGS", strings.Join(fflags, " ")},
envVar{"CGO_LDFLAGS", strings.Join(ldflags, " ")},
)
return []envVar{
{"PKG_CONFIG", b.pkgconfigCmd()},
{"CGO_CFLAGS", strings.Join(cflags, " ")},
{"CGO_CPPFLAGS", strings.Join(cppflags, " ")},
{"CGO_CXXFLAGS", strings.Join(cxxflags, " ")},
{"CGO_FFLAGS", strings.Join(fflags, " ")},
{"CGO_LDFLAGS", strings.Join(ldflags, " ")},
}
}
func runEnv(cmd *Command, args []string) {
env := mkEnv()
env = append(env, extraEnvVars()...)
if len(args) > 0 {
for _, name := range args {
fmt.Printf("%s\n", findEnv(env, name))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment