github.com/AndrienkoAleksandr/go@v0.0.19/src/buildall.bash (about) 1 #!/usr/bin/env bash 2 # Copyright 2015 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 # Usage: buildall.bash [-e] [pattern] 7 # 8 # buildall.bash builds the standard library for all Go-supported 9 # architectures. It is used by the "misc-compile" trybot builders, 10 # as a smoke test to quickly flag portability issues. 11 # 12 # Options: 13 # -e: stop at first failure 14 15 if [ ! -f run.bash ]; then 16 echo 'buildall.bash must be run from $GOROOT/src' 1>&2 17 exit 1 18 fi 19 20 sete=false 21 if [ "$1" = "-e" ]; then 22 sete=true 23 shift 24 fi 25 26 if [ "$sete" = true ]; then 27 set -e 28 fi 29 30 pattern="$1" 31 if [ "$pattern" = "" ]; then 32 pattern=. 33 fi 34 35 ./make.bash || exit 1 36 GOROOT="$(cd .. && pwd)" 37 38 gettargets() { 39 ../bin/go tool dist list | sed -e 's|/|-|' | 40 egrep -v '^(android|ios)' # need C toolchain even for cross-compiling 41 echo linux-arm-arm5 42 } 43 44 selectedtargets() { 45 gettargets | grep -E "$pattern" 46 } 47 48 # put linux first in the target list to get all the architectures up front. 49 linux_targets() { 50 selectedtargets | grep 'linux' | sort 51 } 52 53 non_linux_targets() { 54 selectedtargets | grep -v 'linux' | sort 55 } 56 57 # Note words in $targets are separated by both newlines and spaces. 58 targets="$(linux_targets) $(non_linux_targets)" 59 60 failed=false 61 for target in $targets 62 do 63 echo "" 64 echo "### Building $target" 65 export GOOS=$(echo $target | sed 's/-.*//') 66 export GOARCH=$(echo $target | sed 's/.*-//') 67 unset GOARM 68 if [ "$GOARCH" = "arm5" ]; then 69 export GOARCH=arm 70 export GOARM=5 71 fi 72 73 # Build and vet everything. 74 # cmd/go/internal/work/exec.go enables the same vet flags during go test of std cmd 75 # and should be kept in sync with any vet flag changes here. 76 if ! "$GOROOT/bin/go" build std cmd || ! "$GOROOT/bin/go" vet -unsafeptr=false std cmd; then 77 failed=true 78 if $sete; then 79 exit 1 80 fi 81 fi 82 done 83 84 if [ "$failed" = "true" ]; then 85 echo "" 1>&2 86 echo "Build(s) failed." 1>&2 87 exit 1 88 fi