File: buildall.bash

package info (click to toggle)
golang-1.11 1.11.12-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 107,360 kB
  • sloc: asm: 88,993; ansic: 8,174; perl: 2,007; sh: 1,804; xml: 623; python: 346; makefile: 123; cpp: 22; f90: 8; awk: 7
file content (88 lines) | stat: -rwxr-xr-x 1,818 bytes parent folder | download | duplicates (27)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# Copyright 2015 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# Usage: buildall.sh [-e] [pattern]
#
# buildall.bash builds the standard library for all Go-supported
# architectures. It is used by the "all-compile" trybot builder,
# as a smoke test to quickly flag portability issues.
#
# Options:
#   -e: stop at first failure

if [ ! -f run.bash ]; then
	echo 'buildall.bash must be run from $GOROOT/src' 1>&2
	exit 1
fi

sete=false
if [ "$1" = "-e" ]; then
	sete=true
	shift
fi

if [ "$sete" = true ]; then
	set -e
fi

pattern="$1"
if [ "$pattern" = "" ]; then
	pattern=.
fi

./make.bash || exit 1
GOROOT="$(cd .. && pwd)"

gettargets() {
	../bin/go tool dist list | sed -e 's|/|-|'
	echo linux-386-387
	echo linux-arm-arm5
}

selectedtargets() {
	gettargets | egrep -v 'android-arm|darwin-arm' | egrep "$pattern"
}

# put linux, nacl first in the target list to get all the architectures up front.
linux_nacl_targets() {
	selectedtargets | egrep 'linux|nacl' | sort
}

non_linux_nacl_targets() {
	selectedtargets | egrep -v 'linux|nacl' | sort
}

# Note words in $targets are separated by both newlines and spaces.
targets="$(linux_nacl_targets) $(non_linux_nacl_targets)"

failed=false
for target in $targets
do
	echo ""
	echo "### Building $target"
	export GOOS=$(echo $target | sed 's/-.*//')
	export GOARCH=$(echo $target | sed 's/.*-//')
	unset GO386 GOARM
	if [ "$GOARCH" = "arm5" ]; then
		export GOARCH=arm
		export GOARM=5
	fi
	if [ "$GOARCH" = "387" ]; then
		export GOARCH=386
		export GO386=387
	fi
	if ! "$GOROOT/bin/go" build -a std cmd; then
		failed=true
		if $sete; then
			exit 1
		fi
	fi
done

if [ "$failed" = "true" ]; then
	echo "" 1>&2
	echo "Build(s) failed." 1>&2
	exit 1
fi