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 |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 22 | sete=true |
| 23 | shift |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 24 | fi |
| 25 | |
| 26 | if [ "$sete" = true ]; then |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 27 | set -e |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 28 | fi |
| 29 | |
| 30 | pattern="$1" |
| 31 | if [ "$pattern" = "" ]; then |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 32 | pattern=. |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 33 | fi |
| 34 | |
Shenghou Ma | 0b9866f | 2015-05-16 20:05:58 -0400 | [diff] [blame] | 35 | ./make.bash || exit 1 |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 36 | GOROOT="$(cd .. && pwd)" |
| 37 | |
Ian Lance Taylor | afa0247 | 2016-11-23 08:45:15 -0800 | [diff] [blame] | 38 | gettargets() { |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 39 | ../bin/go tool dist list | sed -e 's|/|-|' |
| 40 | echo linux-386-387 |
| 41 | echo linux-arm-arm5 |
Ian Lance Taylor | afa0247 | 2016-11-23 08:45:15 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | selectedtargets() { |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 45 | gettargets | egrep -v 'android-arm|darwin-arm' | egrep "$pattern" |
Ian Lance Taylor | afa0247 | 2016-11-23 08:45:15 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Shenghou Ma | c8579e5 | 2016-02-25 00:52:16 -0500 | [diff] [blame] | 48 | # put linux, nacl first in the target list to get all the architectures up front. |
Ian Lance Taylor | afa0247 | 2016-11-23 08:45:15 -0800 | [diff] [blame] | 49 | linux_nacl_targets() { |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 50 | selectedtargets | egrep 'linux|nacl' | sort |
Ian Lance Taylor | afa0247 | 2016-11-23 08:45:15 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | non_linux_nacl_targets() { |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 54 | selectedtargets | egrep -v 'linux|nacl' | sort |
Ian Lance Taylor | afa0247 | 2016-11-23 08:45:15 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | # Note words in $targets are separated by both newlines and spaces. |
| 58 | targets="$(linux_nacl_targets) $(non_linux_nacl_targets)" |
Shenghou Ma | c8579e5 | 2016-02-25 00:52:16 -0500 | [diff] [blame] | 59 | |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 60 | failed=false |
| 61 | for target in $targets |
| 62 | do |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 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 | if ! "$GOROOT/bin/go" build -a std cmd; then |
| 77 | failed=true |
| 78 | if $sete; then |
| 79 | exit 1 |
| 80 | fi |
| 81 | fi |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 82 | done |
| 83 | |
| 84 | if [ "$failed" = "true" ]; then |
Daniel Martí | 027500c | 2017-03-09 20:50:24 +0000 | [diff] [blame] | 85 | echo "" 1>&2 |
| 86 | echo "Build(s) failed." 1>&2 |
| 87 | exit 1 |
Brad Fitzpatrick | 3eed422 | 2015-04-29 12:01:55 -0700 | [diff] [blame] | 88 | fi |