...
Text file
src/buildall.bash
Documentation: Index
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
15if [ ! -f run.bash ]; then
16 echo 'buildall.bash must be run from $GOROOT/src' 1>&2
17 exit 1
18fi
19
20sete=false
21if [ "$1" = "-e" ]; then
22 sete=true
23 shift
24fi
25
26if [ "$sete" = true ]; then
27 set -e
28fi
29
30pattern="$1"
31if [ "$pattern" = "" ]; then
32 pattern=.
33fi
34
35./make.bash || exit 1
36GOROOT="$(cd .. && pwd)"
37
38gettargets() {
39 ../bin/go tool dist list | sed -e 's|/|-|'
40 echo linux-arm-arm5
41}
42
43selectedtargets() {
44 gettargets | egrep "$pattern"
45}
46
47# put linux first in the target list to get all the architectures up front.
48linux_targets() {
49 selectedtargets | grep 'linux' | sort
50}
51
52non_linux_targets() {
53 selectedtargets | grep -v 'linux' | sort
54}
55
56# Note words in $targets are separated by both newlines and spaces.
57targets="$(linux_targets) $(non_linux_targets)"
58
59failed=false
60for target in $targets
61do
62 echo ""
63 echo "### Building $target"
64 export GOOS=$(echo $target | sed 's/-.*//')
65 export GOARCH=$(echo $target | sed 's/.*-//')
66 unset GOARM
67 if [ "$GOARCH" = "arm5" ]; then
68 export GOARCH=arm
69 export GOARM=5
70 fi
71
72 # Build and vet everything.
73 # cmd/go/internal/work/exec.go enables the same vet flags during go test of std cmd
74 # and should be kept in sync with any vet flag changes here.
75 if ! "$GOROOT/bin/go" build std cmd || ! "$GOROOT/bin/go" vet -unsafeptr=false std cmd; then
76 failed=true
77 if $sete; then
78 exit 1
79 fi
80 fi
81done
82
83if [ "$failed" = "true" ]; then
84 echo "" 1>&2
85 echo "Build(s) failed." 1>&2
86 exit 1
87fi
View as plain text