...
Text file src/pkg/buildall.bash
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.sh [-e] [pattern]
7 #
8 # buildall.bash builds the standard library for all Go-supported
9 # architectures. It is used by the "all-compile" trybot builder,
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 echo linux-386-387
41 echo linux-arm-arm5
42 }
43
44 selectedtargets() {
45 gettargets | egrep -v 'android-arm|darwin-arm' | egrep "$pattern"
46 }
47
48 # put linux, nacl first in the target list to get all the architectures up front.
49 linux_nacl_targets() {
50 selectedtargets | egrep 'linux|nacl' | sort
51 }
52
53 non_linux_nacl_targets() {
54 selectedtargets | egrep -v 'linux|nacl' | sort
55 }
56
57 # Note words in $targets are separated by both newlines and spaces.
58 targets="$(linux_nacl_targets) $(non_linux_nacl_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 GO386 GOARM
68 if [ "$GOARCH" = "arm5" ]; then
69 export GOARCH=arm
70 export GOARM=5
71 fi
72 if [ "$GOARCH" = "387" ]; then
73 export GOARCH=386
74 export GO386=387
75 fi
76
77 # Build and vet everything.
78 # cmd/go/internal/work/exec.go enables the same vet flags during go test of std cmd
79 # and should be kept in sync with any vet flag changes here.
80 if ! "$GOROOT/bin/go" build std cmd || ! "$GOROOT/bin/go" vet -unsafeptr=false std cmd; then
81 failed=true
82 if $sete; then
83 exit 1
84 fi
85 fi
86 done
87
88 if [ "$failed" = "true" ]; then
89 echo "" 1>&2
90 echo "Build(s) failed." 1>&2
91 exit 1
92 fi
View as plain text