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.
    10  #
    11  # Originally the Go build system used it as a smoke test to quickly
    12  # flag portability issues in builders named "misc-compile" or "all-compile".
    13  # As of CL 464955, the build system uses make.bash -compile-only instead,
    14  # so this script no longer runs in any automated fashion.
    15  #
    16  # Options:
    17  #   -e: stop at first failure
    18  
    19  if [ ! -f run.bash ]; then
    20  	echo 'buildall.bash must be run from $GOROOT/src' 1>&2
    21  	exit 1
    22  fi
    23  
    24  sete=false
    25  if [ "$1" = "-e" ]; then
    26  	sete=true
    27  	shift
    28  fi
    29  
    30  if [ "$sete" = true ]; then
    31  	set -e
    32  fi
    33  
    34  pattern="$1"
    35  if [ "$pattern" = "" ]; then
    36  	pattern=.
    37  fi
    38  
    39  ./make.bash || exit 1
    40  GOROOT="$(cd .. && pwd)"
    41  
    42  gettargets() {
    43  	../bin/go tool dist list | sed -e 's|/|-|' |
    44  		grep -E -v '^(android|ios)' # need C toolchain even for cross-compiling
    45  	echo linux-arm-arm5
    46  }
    47  
    48  selectedtargets() {
    49  	gettargets | grep -E "$pattern"
    50  }
    51  
    52  # put linux first in the target list to get all the architectures up front.
    53  linux_targets() {
    54  	selectedtargets | grep 'linux' | sort
    55  }
    56  
    57  non_linux_targets() {
    58  	selectedtargets | grep -v 'linux' | sort
    59  }
    60  
    61  # Note words in $targets are separated by both newlines and spaces.
    62  targets="$(linux_targets) $(non_linux_targets)"
    63  
    64  failed=false
    65  for target in $targets
    66  do
    67  	echo ""
    68  	echo "### Building $target"
    69  	export GOOS=$(echo $target | sed 's/-.*//')
    70  	export GOARCH=$(echo $target | sed 's/.*-//')
    71  	unset GOARM
    72  	if [ "$GOARCH" = "arm5" ]; then
    73  		export GOARCH=arm
    74  		export GOARM=5
    75  	fi
    76  
    77  	# Build and vet everything.
    78  	# cmd/go/internal/work/exec.go enables the same vet flags during go test of std cmd
    79  	# and should be kept in sync with any vet flag changes here.
    80  	if ! "$GOROOT/bin/go" build std cmd || ! "$GOROOT/bin/go" vet -unsafeptr=false std cmd; then
    81  		failed=true
    82  		if $sete; then
    83  			exit 1
    84  		fi
    85  	fi
    86  done
    87  
    88  if [ "$failed" = "true" ]; then
    89  	echo "" 1>&2
    90  	echo "Build(s) failed." 1>&2
    91  	exit 1
    92  fi
    93  

View as plain text