diff --git a/contrib/makerel b/contrib/makerel new file mode 100644 index 0000000..63d37ce --- /dev/null +++ b/contrib/makerel @@ -0,0 +1,28 @@ +#!/bin/bash +set -euo pipefail + +zigdir=out/zig-x86_64-linux-musl-baseline + +if [[ ! "$PWD" =~ /zig-bootstrap$ ]]; then + >&2 echo "expected to be in zig-bootstrap directory. Bailing" + exit 1 +fi + + +if [[ ! -f "$zigdir/bin/zig" ]]; then + >&2 echo "$zigdir/bin/zig not found. Please run:" + >&2 echo " ./build -j\$(nproc) x86_64-linux-musl baseline" + exit 1 +fi + +pushd "$zigdir" + vsn=$(bin/zig version) + outdir="zig-linux-x86_64-$vsn" + mkdir -p "$outdir" + cp -r "bin/zig" "$outdir" + cp -r "lib/zig" "$outdir/lib" + tar -cf "$outdir.tar" "$outdir" + xz -vk --fast "$outdir.tar" +popd + +echo "$zigdir/$outdir.tar.xz is ready for use" diff --git a/contrib/own_zig.md b/contrib/own_zig.md index c7d77cb..75c5c4d 100644 --- a/contrib/own_zig.md +++ b/contrib/own_zig.md @@ -3,23 +3,37 @@ How to test a different version of zig Assume you want to test an unreleased version of zig. Here's how: -- build zig in `build/` directory, following the official instructions. -- pack it to something that looks like a release using this script: +1. Clone zig-bootstrap: -```bash -#!/bin/bash -set -xeuo pipefail + $ git clone https://github.com/ziglang/zig-bootstrap + $ cd zig-bootstrap -archversion="zig-linux-x86_64-$(git describe)" -dst="$HOME/rel/$archversion/" -rm -fr "$dst" -mkdir -p "$dst"/docs -cp zig "$dst" -cp -r ../lib "$dst" -tar -C "$HOME/rel" -cJf "$HOME/$archversion.tar.xz" . -``` +2. Copy over zig/ from ~/zig: -- send it to jakstys.lt or your mirror. -- point toolchain/defs.bzl to the new version. -- run tests (probably locally, where zig was built). -- running this on sr.ht is left as an exercise for further tests. + $ rm -fr zig + $ tar -C ~/zig archive --format=tar --prefix=zig/ master | tar -xv + +3. Build it (assuming `x86_64-linux`): + + $ vim build # edit ZIG_VERSION + $ ./build -j$(nproc) x86_64-linux-musl baseline + +4. Pack the release tarball: + + $ ~/code/bazel-zig-cc/makerel + +This gives us a usable Zig SDK. Now: + +- Send the .tar.gz it to your mirror. +- Point toolchain/defs.bzl to the new version. +- Run tests. + +Links +----- + +- [ziglang/release-cutter][1], a script that creates binaries for [ziglang.org/download][2]. +- [ziglang/zig-bootstrap][3], a set of scripts that compile a static Zig. + +[1]: https://github.com/ziglang/release-cutter/blob/master/script +[2]: https://ziglang.org/download +[3]: https://github.com/ziglang/zig-bootstrap