build: use Zig via ziglang PyPI package

This avoids cluttering workdir with unpacked tarball
and will work automatically once PEP-723 is implemented.
This commit is contained in:
link2xt
2023-10-22 08:46:37 +00:00
parent c13bbd05cd
commit b4fe9e3eec
2 changed files with 18 additions and 10 deletions

View File

@@ -1,7 +1,13 @@
#!/usr/bin/env python
# /// pyproject
# [run]
# dependencies = [
# "ziglang==0.11.0"
# ]
# ///
import os
import subprocess
import sys
import os
def flag_filter(flag: str) -> bool:
@@ -34,7 +40,17 @@ def main():
args += ["-DBROKEN_CLANG_ATOMICS"]
subprocess.run(
["zig", "cc", "-target", zig_target, *zig_cpu_args, *args], check=True
[
sys.executable,
"-m",
"ziglang",
"cc",
"-target",
zig_target,
*zig_cpu_args,
*args,
],
check=True,
)

View File

@@ -10,14 +10,6 @@ unset RUSTFLAGS
# Pin Rust version to avoid uncontrolled changes in the compiler and linker flags.
export RUSTUP_TOOLCHAIN=1.72.0
ZIG_VERSION=0.11.0
# Download Zig
rm -fr "$ZIG_VERSION" "zig-linux-x86_64-$ZIG_VERSION.tar.xz"
wget "https://ziglang.org/builds/zig-linux-x86_64-$ZIG_VERSION.tar.xz"
tar xf "zig-linux-x86_64-$ZIG_VERSION.tar.xz"
export PATH="$PWD/zig-linux-x86_64-$ZIG_VERSION:$PATH"
rustup target add i686-unknown-linux-musl
CC="$PWD/scripts/zig-cc" \
TARGET_CC="$PWD/scripts/zig-cc" \