Corrected the environment in windowsconstgen.go so that we can run it from test.sh. Phew!
This commit is contained in:
parent
e2063cf946
commit
9d18f04a7c
10
test.sh
10
test.sh
|
@ -4,13 +4,9 @@ if [ ! -f tools/windowsconstgen.go ]; then
|
||||||
fi
|
fi
|
||||||
set -e
|
set -e
|
||||||
if [ x$GOOS = xwindows ]; then
|
if [ x$GOOS = xwindows ]; then
|
||||||
# have to build windowsconstgen as the host, otherwise weird things happen
|
# have to invoke go run with the host $GOOS/$GOARCH
|
||||||
wcg=`mktemp /tmp/windowsconstgenXXXXXXXXXXXX`
|
GOOS= GOARCH= go run tools/windowsconstgen.go . 386 "$@"
|
||||||
GOOS= GOARCH= go build -o $wcg tools/windowsconstgen.go
|
GOOS= GOARCH= go run tools/windowsconstgen.go . amd64 "$@"
|
||||||
# but we can run it regardless of $GOOS/$GOARCH
|
|
||||||
$wcg . 386 "$@"
|
|
||||||
$wcg . amd64 "$@"
|
|
||||||
rm $wcg
|
|
||||||
fi
|
fi
|
||||||
cd test
|
cd test
|
||||||
go build "$@"
|
go build "$@"
|
||||||
|
|
|
@ -182,7 +182,16 @@ func main() {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
cmd.Stdout = f
|
cmd.Stdout = f
|
||||||
cmd.Stderr = os.Stderr
|
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,
|
cmd.Env = append(cmd.Env,
|
||||||
"GOOS=windows",
|
"GOOS=windows",
|
||||||
"GOARCH=" + targetarch,
|
"GOARCH=" + targetarch,
|
||||||
|
|
Loading…
Reference in New Issue