summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-05-25 16:50:52 -0400
committerPietro Gagliardi <[email protected]>2014-05-25 16:50:52 -0400
commit9d18f04a7c12f1dfe9d698fd17c36c930c9b742a (patch)
treedbe5d443dc73620eb3e01e6a921d8da3d4ab3ef6 /tools
parente2063cf94667b7317b90a54521e2f1345f2685d2 (diff)
Corrected the environment in windowsconstgen.go so that we can run it from test.sh. Phew!
Diffstat (limited to 'tools')
-rw-r--r--tools/windowsconstgen.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/windowsconstgen.go b/tools/windowsconstgen.go
index 448b549..0617eb1 100644
--- a/tools/windowsconstgen.go
+++ b/tools/windowsconstgen.go
@@ -182,7 +182,16 @@ func main() {
defer f.Close()
cmd.Stdout = f
cmd.Stderr = os.Stderr
- cmd.Env = append(cmd.Env, os.Environ()...) // otherwise $PATH doesn't get carried over and things mysteriously fail
+ // we need to preserve the environment EXCEPT FOR the variables we're overriding
+ // thanks to raggi and smw in irc.freenode.net/#go-nuts
+ for _, ev := range os.Environ() {
+ if strings.HasPrefix(ev, "GOOS=") ||
+ strings.HasPrefix(ev, "GOARCH=") ||
+ strings.HasPrefix(ev, "CGO_ENABLED=") {
+ continue
+ }
+ cmd.Env = append(cmd.Env, ev)
+ }
cmd.Env = append(cmd.Env,
"GOOS=windows",
"GOARCH=" + targetarch,