1

update .build.yml, remove hangzig

This commit is contained in:
Motiejus Jakštys 2021-06-19 16:45:33 +03:00 committed by Motiejus Jakštys
parent a3606b7404
commit b5c8f85ece
4 changed files with 33 additions and 68 deletions

View File

@ -13,35 +13,30 @@ tasks:
-o bazel -o bazel
chmod +x bazel chmod +x bazel
- test_default: | - test_default: |
cd bazel-zig-cc; ../bazel run \ cd bazel-zig-cc; ./build-and-file \
//test:hello //test:hello | \
grep -q "ELF 64-bit.* x86-64.* dynamically linked"
- test_x86_64-linux-gnu: | - test_x86_64-linux-gnu: |
cd bazel-zig-cc; ../bazel run \ cd bazel-zig-cc; ./build-and-file \
--platforms @zig_sdk//:x86_64-linux-gnu //test:hello --platforms @zig_sdk//:x86_64-linux-gnu //test:hello | \
file $(./getpath @zig_sdk//:x86_64-linux-gnu //test:hello) | \ grep -q "ELF 64-bit.* x86-64.* dynamically linked"
tee /dev/stderr | grep -q "ELF 64-bit.* x86-64.* dynamically linked"
- test_x86_64-linux-musl: | - test_x86_64-linux-musl: |
cd bazel-zig-cc; ../bazel run \ cd bazel-zig-cc; ./build-and-file \
--platforms @zig_sdk//:x86_64-linux-musl //test:hello --extra_toolchains @zig_sdk//:x86_64-linux-musl_toolchain //test:hello | \
file $(./getpath @zig_sdk//:x86_64-linux-musl //test:hello) | \ grep -q "ELF 64-bit.* x86-64.* statically linked"
tee /dev/stderr | grep -q "ELF 64-bit.* x86-64.* statically linked"
- test_aarch64-linux-gnu: | - test_aarch64-linux-gnu: |
cd bazel-zig-cc; ../bazel build \ cd bazel-zig-cc; ./build-and-file \
--platforms @zig_sdk//:aarch64-linux-gnu //test:hello --platforms @zig_sdk//:aarch64-linux-gnu //test:hello | \
file $(./getpath @zig_sdk//:aarch64-linux-gnu //test:hello) | \ grep -q "ELF 64-bit.* ARM aarch64.* dynamically linked"
tee /dev/stderr | grep -q "ELF 64-bit.* ARM aarch64.* dynamically linked"
- test_aarch64-linux-musl: | - test_aarch64-linux-musl: |
cd bazel-zig-cc; ../bazel build \ cd bazel-zig-cc; ./build-and-file \
--platforms @zig_sdk//:aarch64-linux-musl //test:hello --extra_toolchains @zig_sdk//:aarch64-linux-musl_toolchain //test:hello | \
file $(./getpath @zig_sdk//:aarch64-linux-musl //test:hello) | \ grep -q "ELF 64-bit.* ARM aarch64.* statically linked"
tee /dev/stderr | grep -q "ELF 64-bit.* ARM aarch64.* statically linked"
- test_x86_64-macos-gnu: | - test_x86_64-macos-gnu: |
cd bazel-zig-cc; ../bazel build \ cd bazel-zig-cc; ./build-and-file \
--platforms @zig_sdk//:x86_64-macos-gnu //test:hello --platforms @zig_sdk//:x86_64-macos-gnu //test:hello | \
file $(./getpath @zig_sdk//:x86_64-macos-gnu //test:hello) | \ grep -q "Mach-O 64-bit x86_64 executable"
tee /dev/stderr | grep -q "Mach-O 64-bit x86_64 executable"
- test_aarch64-macos-gnu: | - test_aarch64-macos-gnu: |
cd bazel-zig-cc; ../bazel build \ cd bazel-zig-cc; ./build-and-file \
--platforms @zig_sdk//:aarch64-macos-gnu //test:hello --platforms @zig_sdk//:aarch64-macos-gnu //test:hello | \
file $(./getpath @zig_sdk//:aarch64-macos-gnu //test:hello) | \ grep -q "Mach-O 64-bit arm64 executable"
tee /dev/stderr | grep -q "Mach-O 64-bit arm64 executable"

12
build-and-file Executable file
View 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

View File

@ -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}'

34
hangzig
View File

@ -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