Home | History | Annotate | Download | only in src
      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
      9 # architectures. It is used by the "all-compile" trybot builder,
     10 # as a smoke test to quickly flag portability issues.
     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 ./make.bash || exit 1
     36 GOROOT="$(cd .. && pwd)"
     37 
     38 # put linux, nacl first in the target list to get all the architectures up front.
     39 targets="$((../bin/go tool dist list | sed -n 's/^\(.*\)\/\(.*\)/\1-\2/p'; echo linux-386-387 linux-arm-arm5) | sort | egrep -v android-arm | egrep "$pattern" | egrep 'linux|nacl')
     40 $(../bin/go tool dist list | sed -n 's/^\(.*\)\/\(.*\)/\1-\2/p' | egrep -v 'android-arm|darwin-arm' | egrep "$pattern" | egrep -v 'linux|nacl')"
     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/.*-//')
     49     unset GO386 GOARM
     50     if [ "$GOARCH" = "arm5" ]; then
     51         export GOARCH=arm
     52         export GOARM=5
     53     fi
     54     if [ "$GOARCH" = "387" ]; then
     55         export GOARCH=386
     56         export GO386=387
     57     fi
     58     if ! "$GOROOT/bin/go" build -a std cmd; then
     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
     71