File: test_crosscompile.sh

package info (click to toggle)
golang-pty 1.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 244 kB
  • sloc: sh: 140; makefile: 3
file content (50 lines) | stat: -rwxr-xr-x 1,118 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env sh

# Test script checking that all expected os/arch compile properly.
# Does not actually test the logic, just the compilation so we make sure we don't break code depending on the lib.

echo2() {
    echo $@ >&2
}

trap end 0
end() {
    [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1)
}

cross() {
    os=$1
    shift
    echo2 "Build for $os."
    for arch in $@; do
	echo2 "  - $os/$arch"
	GOOS=$os GOARCH=$arch go build
    done
    echo2
}

set -e

cross linux     amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le
cross darwin    amd64 386 arm arm64
cross freebsd   amd64 386 arm
cross netbsd    amd64 386 arm
cross openbsd   amd64 386
cross dragonfly amd64
cross solaris   amd64

# Not expected to work but should still compile.
cross windows amd64 386 arm

# TODO: Fix compilation error on openbsd/arm.
# TODO: Merge the solaris PR.

# Some os/arch require a different compiler. Run in docker.
if ! hash docker; then
    # If docker is not present, stop here.
    return
fi

echo2 "Build for linux."
echo2 "  - linux/riscv"
docker build -t test -f Dockerfile.riscv .