2021-10-18 15:12:31 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
. .envrc
|
|
|
|
|
|
|
|
_build_and_file() {
|
2021-10-21 11:39:46 +03:00
|
|
|
file "$(bazel run --color=yes --curses=yes --run_under=echo "$@")" | \
|
2021-10-21 11:38:24 +03:00
|
|
|
tee /dev/stderr
|
2021-10-18 15:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
_test() {
|
|
|
|
local name=$1
|
|
|
|
local glob=$2
|
|
|
|
shift; shift;
|
|
|
|
>&2 echo "================================================================"
|
2022-02-03 14:36:22 +02:00
|
|
|
>&2 echo "Building everything under //test/... for $name"
|
|
|
|
>&2 echo
|
|
|
|
>&2 echo " bazel build --color=yes --curses=yes $* //test/..."
|
|
|
|
>&2 echo
|
|
|
|
bazel build --color=yes --curses=yes "$@" //test/...
|
|
|
|
>&2 echo
|
2021-10-18 15:12:31 +03:00
|
|
|
>&2 echo "Testing $name and looking for '$glob':"
|
|
|
|
>&2 echo
|
2022-02-03 14:58:05 +02:00
|
|
|
>&2 echo " bazel build $* //test/go:go"
|
2022-02-03 14:36:22 +02:00
|
|
|
>&2 echo
|
2022-02-03 14:58:05 +02:00
|
|
|
if _build_and_file "$@" //test/go:go | grep -q "$glob"; then
|
2021-10-18 15:12:31 +03:00
|
|
|
>&2 echo "OK $name"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
>&2 echo "FAIL $name: glob does not match"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_test "Host" \
|
|
|
|
"ELF 64-bit.* x86-64.* dynamically linked"
|
|
|
|
|
2021-10-20 07:54:01 +03:00
|
|
|
_test "darwin_amd64" \
|
|
|
|
"Mach-O 64-bit x86_64 executable" \
|
2022-02-03 14:06:01 +02:00
|
|
|
--platforms @zig_sdk//:darwin_amd64_platform
|
2021-10-20 07:54:01 +03:00
|
|
|
|
2021-12-13 03:33:24 +02:00
|
|
|
# hello world on darwin/arm64 requires OSX SDK via `zig cc --sysroot=<...>`.
|
|
|
|
# see https://github.com/ziglang/zig/issues/10299#issuecomment-989595215
|
|
|
|
#_test "darwin_arm64" \
|
|
|
|
# "Mach-O 64-bit arm64 executable" \
|
2022-02-03 14:06:01 +02:00
|
|
|
# --platforms @zig_sdk//:darwin_arm64_platform
|
2021-10-20 07:54:01 +03:00
|
|
|
|
2021-10-18 15:12:31 +03:00
|
|
|
_test "linux_amd64_gnu" \
|
|
|
|
"ELF 64-bit.* x86-64.* dynamically linked" \
|
2022-02-03 14:06:01 +02:00
|
|
|
--platforms @zig_sdk//:linux_amd64_platform
|
2021-10-18 15:12:31 +03:00
|
|
|
|
|
|
|
_test "linux_amd64_musl" \
|
|
|
|
"ELF 64-bit.* x86-64.* statically linked" \
|
2022-02-03 14:06:01 +02:00
|
|
|
--platforms @zig_sdk//:linux_amd64_platform \
|
2021-10-18 15:12:31 +03:00
|
|
|
--extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain
|
|
|
|
|
|
|
|
_test "linux_arm64_gnu" \
|
|
|
|
"ELF 64-bit.* ARM aarch64.* dynamically linked" \
|
2022-02-03 14:06:01 +02:00
|
|
|
--platforms @zig_sdk//:linux_arm64_platform
|
2021-10-18 15:12:31 +03:00
|
|
|
|
|
|
|
_test "linux_arm64_musl" \
|
|
|
|
"ELF 64-bit.* ARM aarch64.* statically linked" \
|
2022-02-03 14:06:01 +02:00
|
|
|
--platforms @zig_sdk//:linux_arm64_platform \
|
2021-10-18 15:12:31 +03:00
|
|
|
--extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain
|