Black Lives Matter. Support the Equal Justice Initiative.

Text file src/buildall.bash

Documentation: Index

     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
    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
    22	sete=true
    23	shift
    24fi
    25
    26if [ "$sete" = true ]; then
    27	set -e
    28fi
    29
    30pattern="$1"
    31if [ "$pattern" = "" ]; then
    32	pattern=.
    33fi
    34
    35./make.bash || exit 1
    36GOROOT="$(cd .. && pwd)"
    37
    38gettargets() {
    39	../bin/go tool dist list | sed -e 's|/|-|'
    40	echo linux-386-387
    41	echo linux-arm-arm5
    42}
    43
    44selectedtargets() {
    45	gettargets | egrep -v 'android-arm|darwin-arm64' | egrep "$pattern"
    46}
    47
    48# put linux first in the target list to get all the architectures up front.
    49linux_targets() {
    50	selectedtargets | grep 'linux' | sort
    51}
    52
    53non_linux_targets() {
    54	selectedtargets | grep -v 'linux' | sort
    55}
    56
    57# Note words in $targets are separated by both newlines and spaces.
    58targets="$(linux_targets) $(non_linux_targets)"
    59
    60failed=false
    61for target in $targets
    62do
    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
    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
    86done
    87
    88if [ "$failed" = "true" ]; then
    89	echo "" 1>&2
    90	echo "Build(s) failed." 1>&2
    91	exit 1
    92fi

View as plain text