~motiejus/bazel-zig-cc

bazel-zig-cc/ci/test -rwxr-xr-x 1.8 KiB
1cd04478 — Motiejus Jakštys rename/fix the package 16 hours ago
                                                                                
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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
. .envrc

_build_and_file() {
    file "$(bazel run --color=yes --curses=yes --run_under=echo "$@")" | \
        tee /dev/stderr
}

_test() {
    local name=$1
    local glob=$2
    shift; shift;
    >&2 echo "================================================================"
    >&2 echo "Testing $name and looking for '$glob':"
    >&2 echo "  bazel build $* //test:hello"
    >&2 echo
    if _build_and_file "$@" //test:hello | grep -q "$glob"; then
        >&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"

_test "darwin_amd64" \
  "Mach-O 64-bit x86_64 executable" \
    --platforms @io_bazel_rules_go//go/toolchain:darwin_amd64_cgo

# 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" \
#    --platforms @io_bazel_rules_go//go/toolchain:darwin_arm64_cgo

_test "linux_amd64_gnu" \
    "ELF 64-bit.* x86-64.* dynamically linked" \
    --platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo

_test "linux_amd64_musl" \
    "ELF 64-bit.* x86-64.* statically linked" \
    --platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
    --extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain

_test "linux_arm64_gnu" \
    "ELF 64-bit.* ARM aarch64.* dynamically linked" \
    --platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo

_test "linux_arm64_musl" \
    "ELF 64-bit.* ARM aarch64.* statically linked" \
    --platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo \
    --extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain