blob: 5820b4d5893e359426e63535b28c5118390c017a [file] [log] [blame]
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -07001#!/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 Fitzpatrick35748912015-04-29 15:08:49 -07009# architectures. It is used by the "all-compile" trybot builder,
10# as a smoke test to quickly flag portability issues.
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070011#
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
Daniel Martí027500c2017-03-09 20:50:24 +000022 sete=true
23 shift
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070024fi
25
26if [ "$sete" = true ]; then
Daniel Martí027500c2017-03-09 20:50:24 +000027 set -e
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070028fi
29
30pattern="$1"
31if [ "$pattern" = "" ]; then
Daniel Martí027500c2017-03-09 20:50:24 +000032 pattern=.
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070033fi
34
Shenghou Ma0b9866f2015-05-16 20:05:58 -040035./make.bash || exit 1
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070036GOROOT="$(cd .. && pwd)"
37
Ian Lance Taylorafa02472016-11-23 08:45:15 -080038gettargets() {
Daniel Martí027500c2017-03-09 20:50:24 +000039 ../bin/go tool dist list | sed -e 's|/|-|'
40 echo linux-386-387
41 echo linux-arm-arm5
Ian Lance Taylorafa02472016-11-23 08:45:15 -080042}
43
44selectedtargets() {
Daniel Martí027500c2017-03-09 20:50:24 +000045 gettargets | egrep -v 'android-arm|darwin-arm' | egrep "$pattern"
Ian Lance Taylorafa02472016-11-23 08:45:15 -080046}
47
Shenghou Mac8579e52016-02-25 00:52:16 -050048# put linux, nacl first in the target list to get all the architectures up front.
Ian Lance Taylorafa02472016-11-23 08:45:15 -080049linux_nacl_targets() {
Daniel Martí027500c2017-03-09 20:50:24 +000050 selectedtargets | egrep 'linux|nacl' | sort
Ian Lance Taylorafa02472016-11-23 08:45:15 -080051}
52
53non_linux_nacl_targets() {
Daniel Martí027500c2017-03-09 20:50:24 +000054 selectedtargets | egrep -v 'linux|nacl' | sort
Ian Lance Taylorafa02472016-11-23 08:45:15 -080055}
56
57# Note words in $targets are separated by both newlines and spaces.
58targets="$(linux_nacl_targets) $(non_linux_nacl_targets)"
Shenghou Mac8579e52016-02-25 00:52:16 -050059
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070060failed=false
61for target in $targets
62do
Daniel Martí027500c2017-03-09 20:50:24 +000063 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 Fitzpatrick3eed4222015-04-29 12:01:55 -070082done
83
84if [ "$failed" = "true" ]; then
Daniel Martí027500c2017-03-09 20:50:24 +000085 echo "" 1>&2
86 echo "Build(s) failed." 1>&2
87 exit 1
Brad Fitzpatrick3eed4222015-04-29 12:01:55 -070088fi