Patrick Williams | d849ec7 | 2016-08-17 14:59:38 -0500 | [diff] [blame] | 1 | Index: go/src/make.bash |
| 2 | =================================================================== |
| 3 | --- go.orig/src/make.bash |
| 4 | +++ go/src/make.bash |
| 5 | @@ -143,12 +143,23 @@ if [ "$1" = "--no-clean" ]; then |
| 6 | buildall="" |
| 7 | shift |
| 8 | fi |
| 9 | -./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap |
| 10 | -# Delay move of dist tool to now, because bootstrap may clear tool directory. |
| 11 | -mv cmd/dist/dist "$GOTOOLDIR"/dist |
| 12 | -echo |
| 13 | |
| 14 | -if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then |
| 15 | +do_host_build="yes" |
| 16 | +do_target_build="yes" |
| 17 | +if [ "$1" = "--target-only" ]; then |
| 18 | + do_host_build="no" |
| 19 | + shift |
| 20 | +elif [ "$1" = "--host-only" ]; then |
| 21 | + do_target_build="no" |
| 22 | + shift |
| 23 | +fi |
| 24 | + |
| 25 | +if [ "$do_host_build" = "yes" ]; then |
| 26 | + ./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap |
| 27 | + # Delay move of dist tool to now, because bootstrap may clear tool directory. |
| 28 | + mv cmd/dist/dist "$GOTOOLDIR"/dist |
| 29 | + echo |
| 30 | + |
| 31 | echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH." |
| 32 | # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however, |
| 33 | # use the host compiler, CC, from `cmd/dist/dist env` instead. |
| 34 | @@ -157,11 +168,20 @@ if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOH |
| 35 | echo |
| 36 | fi |
| 37 | |
| 38 | -echo "##### Building packages and commands for $GOOS/$GOARCH." |
| 39 | -CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd |
| 40 | -echo |
| 41 | +if [ "$do_target_build" = "yes" ]; then |
| 42 | + GO_INSTALL="${GO_TARGET_INSTALL:-std cmd}" |
| 43 | + echo "##### Building packages and commands for $GOOS/$GOARCH." |
| 44 | + if [ "$GOHOSTOS" = "$GOOS" -a "$GOHOSTARCH" = "$GOARCH" -a "$do_host_build" = "yes" ]; then |
| 45 | + rm -rf ./host-tools |
| 46 | + mkdir ./host-tools |
| 47 | + mv "$GOTOOLDIR"/* ./host-tools |
| 48 | + GOTOOLDIR="$PWD/host-tools" |
| 49 | + fi |
| 50 | + GOTOOLDIR="$GOTOOLDIR" CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v ${GO_INSTALL} |
| 51 | + echo |
| 52 | |
| 53 | -rm -f "$GOTOOLDIR"/go_bootstrap |
| 54 | + rm -f "$GOTOOLDIR"/go_bootstrap |
| 55 | +fi |
| 56 | |
| 57 | if [ "$1" != "--no-banner" ]; then |
| 58 | "$GOTOOLDIR"/dist banner |