...
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.
10#
11# Originally the Go build system used it as a smoke test to quickly
12# flag portability issues in builders named "misc-compile" or "all-compile".
13# As of CL 464955, the build system uses make.bash -compile-only instead,
14# so this script no longer runs in any automated fashion.
15#
16# Options:
17# -e: stop at first failure
18
19if [ ! -f run.bash ]; then
20 echo 'buildall.bash must be run from $GOROOT/src' 1>&2
21 exit 1
22fi
23
24sete=false
25if [ "$1" = "-e" ]; then
26 sete=true
27 shift
28fi
29
30if [ "$sete" = true ]; then
31 set -e
32fi
33
34pattern="$1"
35if [ "$pattern" = "" ]; then
36 pattern=.
37fi
38
39./make.bash || exit 1
40GOROOT="$(cd .. && pwd)"
41
42gettargets() {
43 ../bin/go tool dist list | sed -e 's|/|-|' |
44 egrep -v '^(android|ios)' # need C toolchain even for cross-compiling
45 echo linux-arm-arm5
46}
47
48selectedtargets() {
49 gettargets | grep -E "$pattern"
50}
51
52# put linux first in the target list to get all the architectures up front.
53linux_targets() {
54 selectedtargets | grep 'linux' | sort
55}
56
57non_linux_targets() {
58 selectedtargets | grep -v 'linux' | sort
59}
60
61# Note words in $targets are separated by both newlines and spaces.
62targets="$(linux_targets) $(non_linux_targets)"
63
64failed=false
65for target in $targets
66do
67 echo ""
68 echo "### Building $target"
69 export GOOS=$(echo $target | sed 's/-.*//')
70 export GOARCH=$(echo $target | sed 's/.*-//')
71 unset GOARM
72 if [ "$GOARCH" = "arm5" ]; then
73 export GOARCH=arm
74 export GOARM=5
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
86done
87
88if [ "$failed" = "true" ]; then
89 echo "" 1>&2
90 echo "Build(s) failed." 1>&2
91 exit 1
92fi
View as plain text