Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 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 |
Brad Fitzpatrick | 3574891 | 2015-04-29 15:08:49 -0700 | [diff] [blame] | 9 | # architectures. It is used by the "all-compile" trybot builder, |
| 10 | # as a smoke test to quickly flag portability issues. |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 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 | # put linux, nacl first in the target list to get all the architectures up front. |
Shenghou Ma | 965d00f8 | 2015-05-06 22:10:28 -0400 | [diff] [blame] | 36 | targets="$((ls runtime | sed -n 's/^rt0_\(.*\)_\(.*\)\.s/\1-\2/p'; echo linux-386-387 linux-arm-arm5) | sort | egrep -v android-arm | egrep "$pattern" | egrep 'linux|nacl') |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 37 | $(ls runtime | sed -n 's/^rt0_\(.*\)_\(.*\)\.s/\1-\2/p' | egrep -v 'android-arm|darwin-arm' | egrep "$pattern" | egrep -v 'linux|nacl')" |
| 38 | |
| 39 | ./make.bash |
| 40 | GOROOT="$(cd .. && pwd)" |
| 41 | |
| 42 | failed=false |
| 43 | for target in $targets |
| 44 | do |
| 45 | echo "" |
| 46 | echo "### Building $target" |
| 47 | export GOOS=$(echo $target | sed 's/-.*//') |
| 48 | export GOARCH=$(echo $target | sed 's/.*-//') |
Shenghou Ma | 965d00f8 | 2015-05-06 22:10:28 -0400 | [diff] [blame] | 49 | unset GO386 GOARM |
| 50 | if [ "$GOARCH" = "arm5" ]; then |
| 51 | export GOARCH=arm |
| 52 | export GOARM=5 |
| 53 | fi |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 54 | if [ "$GOARCH" = "387" ]; then |
| 55 | export GOARCH=386 |
| 56 | export GO386=387 |
| 57 | fi |
Josh Bleecher Snyder | 9b66cf6 | 2015-04-29 16:10:23 -0700 | [diff] [blame] | 58 | if ! "$GOROOT/bin/go" build -a std cmd; then |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 59 | failed=true |
| 60 | if $sete; then |
| 61 | exit 1 |
| 62 | fi |
| 63 | fi |
| 64 | done |
| 65 | |
| 66 | if [ "$failed" = "true" ]; then |
| 67 | echo "" 1>&2 |
| 68 | echo "Build(s) failed." 1>&2 |
| 69 | exit 1 |
| 70 | fi |