tools: change zig to install from a tarball (fixes: #1085) (#1089)

* tools: change zig to install from a tarball

Migrate from using snap, we install from a cheksumed tarball

* fix: add sudo

* fix: install zig to .zig in PWD

Co-authored-by: Albert Koczy <albert.koczy@asseco.pl>
This commit is contained in:
alufers 2022-08-23 21:43:17 +02:00 committed by GitHub
parent d111c8ddcf
commit 36ee7d238d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 4 deletions

4
.gitignore vendored
View File

@ -70,6 +70,10 @@ tests/.pytest_cache/
tests/binaries/*.o
tests/binaries/*.out
tests/binaries/gosample.x*
/tests/binaries/div_zero_binary/core
/tests/binaries/div_zero_binary/binary
# VS Code files
.vscode/
.zig/

View File

@ -23,10 +23,33 @@ install_apt() {
sudo apt-get install -y \
nasm \
gcc \
libc6-dev
test -f /usr/bin/go || sudo apt-get install -y golang
libc6-dev \
curl \
build-essential \
gdb
test -f /usr/bin/go || sudo apt-ge\t install -y golang
# Install zig to current directory
# We use zig to compile some test binaries as it is much easier than with gcc
sudo snap install zig --classic --edge
if ! command -v zig &> /dev/null
then
ZIG_TAR_URL="https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3685+dae7aeb33.tar.xz"
ZIG_TAR_SHA256="dfc8f5ecb651342f1fc2b2828362b62f74fadac9931bda785b80bf7ecfcfabb2"
curl --output /tmp/zig.tar.xz "${ZIG_TAR_URL}"
ACTUAL_SHA256=$(sha256sum /tmp/zig.tar.xz | cut -d' ' -f1)
if [ "${ACTUAL_SHA256}" != "${ZIG_TAR_SHA256}" ]; then
echo "Zig binary checksum mismatch"
echo "Expected: ${ZIG_TAR_SHA256}"
echo "Actual: ${ACTUAL_SHA256}"
exit 1
fi
tar -C /tmp -xJf /tmp/zig.tar.xz
mv /tmp/zig-linux-x86_64-* "$(pwd)/.zig" 2>/dev/null >/dev/null || true
echo "Zig installed to $(pwd)/.zig"
fi
}
if linux; then

View File

@ -1,4 +1,4 @@
ZIGCC = zig cc
ZIGCC = $(shell pwd)/../../.zig/zig cc
CC = gcc
DEBUG = 1