diff --git a/.build.yml b/.build.yml index b3cbd59..0729b00 100644 --- a/.build.yml +++ b/.build.yml @@ -13,35 +13,30 @@ tasks: -o bazel chmod +x bazel - test_default: | - cd bazel-zig-cc; ../bazel run \ - //test:hello + cd bazel-zig-cc; ./build-and-file \ + //test:hello | \ + grep -q "ELF 64-bit.* x86-64.* dynamically linked" - test_x86_64-linux-gnu: | - cd bazel-zig-cc; ../bazel run \ - --platforms @zig_sdk//:x86_64-linux-gnu //test:hello - file $(./getpath @zig_sdk//:x86_64-linux-gnu //test:hello) | \ - tee /dev/stderr | grep -q "ELF 64-bit.* x86-64.* dynamically linked" + cd bazel-zig-cc; ./build-and-file \ + --platforms @zig_sdk//:x86_64-linux-gnu //test:hello | \ + grep -q "ELF 64-bit.* x86-64.* dynamically linked" - test_x86_64-linux-musl: | - cd bazel-zig-cc; ../bazel run \ - --platforms @zig_sdk//:x86_64-linux-musl //test:hello - file $(./getpath @zig_sdk//:x86_64-linux-musl //test:hello) | \ - tee /dev/stderr | grep -q "ELF 64-bit.* x86-64.* statically linked" + cd bazel-zig-cc; ./build-and-file \ + --extra_toolchains @zig_sdk//:x86_64-linux-musl_toolchain //test:hello | \ + grep -q "ELF 64-bit.* x86-64.* statically linked" - test_aarch64-linux-gnu: | - cd bazel-zig-cc; ../bazel build \ - --platforms @zig_sdk//:aarch64-linux-gnu //test:hello - file $(./getpath @zig_sdk//:aarch64-linux-gnu //test:hello) | \ - tee /dev/stderr | grep -q "ELF 64-bit.* ARM aarch64.* dynamically linked" + cd bazel-zig-cc; ./build-and-file \ + --platforms @zig_sdk//:aarch64-linux-gnu //test:hello | \ + grep -q "ELF 64-bit.* ARM aarch64.* dynamically linked" - test_aarch64-linux-musl: | - cd bazel-zig-cc; ../bazel build \ - --platforms @zig_sdk//:aarch64-linux-musl //test:hello - file $(./getpath @zig_sdk//:aarch64-linux-musl //test:hello) | \ - tee /dev/stderr | grep -q "ELF 64-bit.* ARM aarch64.* statically linked" + cd bazel-zig-cc; ./build-and-file \ + --extra_toolchains @zig_sdk//:aarch64-linux-musl_toolchain //test:hello | \ + grep -q "ELF 64-bit.* ARM aarch64.* statically linked" - test_x86_64-macos-gnu: | - cd bazel-zig-cc; ../bazel build \ - --platforms @zig_sdk//:x86_64-macos-gnu //test:hello - file $(./getpath @zig_sdk//:x86_64-macos-gnu //test:hello) | \ - tee /dev/stderr | grep -q "Mach-O 64-bit x86_64 executable" + cd bazel-zig-cc; ./build-and-file \ + --platforms @zig_sdk//:x86_64-macos-gnu //test:hello | \ + grep -q "Mach-O 64-bit x86_64 executable" - test_aarch64-macos-gnu: | - cd bazel-zig-cc; ../bazel build \ - --platforms @zig_sdk//:aarch64-macos-gnu //test:hello - file $(./getpath @zig_sdk//:aarch64-macos-gnu //test:hello) | \ - tee /dev/stderr | grep -q "Mach-O 64-bit arm64 executable" + cd bazel-zig-cc; ./build-and-file \ + --platforms @zig_sdk//:aarch64-macos-gnu //test:hello | \ + grep -q "Mach-O 64-bit arm64 executable" diff --git a/build-and-file b/build-and-file new file mode 100755 index 0000000..bc54c1c --- /dev/null +++ b/build-and-file @@ -0,0 +1,12 @@ +#!/bin/bash + +# 'bazel' binary is stored in $HOME in builds.sr.ht. +export PATH=$PATH:$HOME + +bazel build "$@" + +execpath=$(bazel aquery "$@" 2>/dev/null | \ + awk "/action 'GoLink/{f=1};/Outputs: / &&f{print;exit}" | \ + awk -F'\\[|\\]' '{print $2}') + +file "$execpath" | tee /dev/stderr diff --git a/getpath b/getpath deleted file mode 100755 index 4ffed00..0000000 --- a/getpath +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# in builds.sr.ht, 'bazel' binary is stored in $HOME. -exec env PATH=$PATH:$HOME \ - bazel aquery \ - --platforms "$1" "$2" 2>/dev/null | \ - awk "/action 'GoLink/{f=1};/Outputs: / &&f{print;exit}" | \ - awk -F'\\[|\\]' '{print $2}' diff --git a/hangzig b/hangzig deleted file mode 100755 index 723fbee..0000000 --- a/hangzig +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -euo pipefail - -readonly bzl=https://github.com/bazelbuild/bazelisk/releases/download/v1.9.0/bazelisk-linux-amd64 - -set -x - -outside() { - git clean -ffxd --exclude bazel - if [[ ! -x bazel ]]; then - rm -f bazel - curl -L "$bzl" -o bazel - chmod +x bazel - fi - exec docker run -ti --rm -v $(pwd):/x -w /x --name hangzig \ - --cpuset-cpus 0-1 \ - -m 4096MB \ - -e CC=/usr/bin/false \ - debian:testing ./hangzig inside - } - -inside() { - apt-get update && apt-get install -y ca-certificates - exec ./bazel build -s --platforms @zig_sdk//:aarch64-macos-gnu //test:gognu -} - -case "${1:-}" in - "") - outside;; - inside) - inside;; - *) - exit 1; -esac