1
Fork 0

[contrib/] zig sdk test instructions

nix
Motiejus Jakštys 2022-06-28 13:57:48 +03:00
parent db2f187aa9
commit 956711690f
2 changed files with 59 additions and 17 deletions

28
contrib/makerel Normal file
View File

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

View File

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