Skip to content

Commit

Permalink
build: add go env GOROOT as default GOROOT_BOOTSTRAP value
Browse files Browse the repository at this point in the history
This change also added the same check in make.bash to make.rc,
which makes sure $GOROOT_BOOTSTRAP != $GOROOT.

Fixes #14339

Change-Id: I2758f4a845bae42ace02492fc6a911f6d6247d26
Reviewed-on: https://go-review.googlesource.com/57753
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
crvv authored and ianlancetaylor committed Aug 25, 2017
1 parent 3d62000 commit a164a2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/make.bash
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ rm -f ./runtime/runtime_defs.go
echo '##### Building Go bootstrap tool.'
echo cmd/dist
export GOROOT="$(cd .. && pwd)"
GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4}
export GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4}
for go_exe in $(type -ap go); do
if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then
goroot=$(GOROOT='' $go_exe env GOROOT)
if [ "$goroot" != "$GOROOT" ]; then
GOROOT_BOOTSTRAP=$goroot
fi
fi
done
if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then
echo "ERROR: Cannot find $GOROOT_BOOTSTRAP/bin/go." >&2
echo "Set \$GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." >&2
Expand Down
15 changes: 15 additions & 0 deletions src/make.rc
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,26 @@ echo cmd/dist
GOROOT = `{cd .. && pwd}
if(! ~ $#GOROOT_BOOTSTRAP 1)
GOROOT_BOOTSTRAP = $home/go1.4
for(p in $path){
if(! test -x $GOROOT_BOOTSTRAP/bin/go){
if(go_exe = `{path=$p whatis go}){
goroot = `{GOROOT='' $go_exe env GOROOT}
if(! ~ $goroot $GOROOT){
GOROOT_BOOTSTRAP = $goroot
}
}
}
}
if(! test -x $GOROOT_BOOTSTRAP/bin/go){
echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2]
echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2]
exit bootstrap
}
if(~ $GOROOT_BOOTSTRAP $GOROOT){
echo 'ERROR: $GOROOT_BOOTSTRAP must not be set to $GOROOT' >[1=2]
echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2]
exit bootstrap
}
rm -f cmd/dist/dist
GOROOT=$GOROOT_BOOTSTRAP GOOS='' GOARCH='' $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist

Expand Down

0 comments on commit a164a2f

Please sign in to comment.