Text file src/buildall.bash

     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. It is used by the "misc-compile" trybot builders,
    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  gettargets() {
    39  	../bin/go tool dist list | sed -e 's|/|-|'
    40  	echo linux-arm-arm5
    41  }
    42  
    43  selectedtargets() {
    44  	gettargets | grep -E "$pattern"
    45  }
    46  
    47  # put linux first in the target list to get all the architectures up front.
    48  linux_targets() {
    49  	selectedtargets | grep 'linux' | sort
    50  }
    51  
    52  non_linux_targets() {
    53  	selectedtargets | grep -v 'linux' | sort
    54  }
    55  
    56  # Note words in $targets are separated by both newlines and spaces.
    57  targets="$(linux_targets) $(non_linux_targets)"
    58  
    59  failed=false
    60  for target in $targets
    61  do
    62  	echo ""
    63  	echo "### Building $target"
    64  	export GOOS=$(echo $target | sed 's/-.*//')
    65  	export GOARCH=$(echo $target | sed 's/.*-//')
    66  	unset GOARM
    67  	if [ "$GOARCH" = "arm5" ]; then
    68  		export GOARCH=arm
    69  		export GOARM=5
    70  	fi
    71  
    72  	# Build and vet everything.
    73  	# cmd/go/internal/work/exec.go enables the same vet flags during go test of std cmd
    74  	# and should be kept in sync with any vet flag changes here.
    75  	if ! "$GOROOT/bin/go" build std cmd || ! "$GOROOT/bin/go" vet -unsafeptr=false std cmd; then
    76  		failed=true
    77  		if $sete; then
    78  			exit 1
    79  		fi
    80  	fi
    81  done
    82  
    83  if [ "$failed" = "true" ]; then
    84  	echo "" 1>&2
    85  	echo "Build(s) failed." 1>&2
    86  	exit 1
    87  fi
    88  

View as plain text