Skip to content

Commit 94d8bcb

Browse files
committed
update to zig master 0.10.0 and gyro v0.7.0
1 parent ed3c1a3 commit 94d8bcb

File tree

14 files changed

+120
-70
lines changed

14 files changed

+120
-70
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
pull_request:
88
branches:
99
- main
10+
schedule:
11+
- cron: '0 0 * * *' # run at 00:00 UTC
1012

1113
jobs:
1214
build_nix:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
zig-cache
2+
zig-*
3+
wasmtime*
24
.DS_Store
35
*.swp
46
.gyro

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# wasmtime-zig
2-
[<img alt="github" src="https://img.shields.io/badge/github-kubkon/wasmtime--zig-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/kubkon/wasmtime-zig)
2+
[<img alt="github" src="https://img.shields.io/badge/github-zigwasm/wasmtime--zig-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/kubkon/wasmtime-zig)
33
[<img alt="build status" src="https://img.shields.io/github/workflow/status/kubkon/wasmtime-zig/CI/master?style=for-the-badge" height="20">](https://github.com/kubkon/wasmtime-zig/actions?query=branch%3Amaster)
44

55
Zig embedding of [Wasmtime]
@@ -13,7 +13,7 @@ but expected, and things might just not work as expected yet.
1313

1414
## Building
1515

16-
To build this library, you will need Zig nightly 0.8.0, as well as [`gyro`] package manager.
16+
To build this library, you will need Zig nightly 0.10.0, as well as [`gyro`] package manager (`v0.7.0`).
1717

1818
[`gyro`]: https://github.com/mattnite/gyro
1919

build.zig

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,22 @@ pub fn build(b: *std.build.Builder) !void {
3030
simple_exe.setBuildMode(mode);
3131
simple_exe.addPackage(.{
3232
.name = "wasmtime",
33-
.path = "src/main.zig",
33+
.source = .{ .path = "src/main.zig" },
3434
.dependencies = &.{pkgs.wasm},
3535
});
36-
if (builtin.os.tag == .windows) {
37-
simple_exe.linkSystemLibrary("wasmtime.dll");
38-
} else {
39-
simple_exe.linkSystemLibrary("wasmtime");
36+
switch (builtin.os.tag) {
37+
.windows => {
38+
simple_exe.linkSystemLibrary("wasmtime.dll");
39+
simple_exe.linkSystemLibrary("unwind");
40+
},
41+
.linux => {
42+
simple_exe.linkSystemLibrary("wasmtime");
43+
simple_exe.linkSystemLibrary("unwind");
44+
},
45+
.macos => {
46+
simple_exe.linkSystemLibrary("wasmtime");
47+
},
48+
else => unreachable,
4049
}
4150
simple_exe.linkLibC();
4251
simple_exe.step.dependOn(b.getInstallStep());

ci/install_gyro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
GYRO_VERSION=$1
7+
GYRO=$2
8+
9+
curl -sL "https://github.com/mattnite/gyro/releases/download/$GYRO_VERSION/$GYRO.tar.gz" -o "$GYRO.tar.gz"
10+
tar xf "$GYRO.tar.gz"

ci/install_wasmtime

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
WASMTIME_VERSION=$1
7+
WASMTIME=$2
8+
9+
curl -sL "https://github.com/bytecodealliance/wasmtime/releases/download/$WASMTIME_VERSION/$WASMTIME.tar.xz" -o "$WASMTIME.tar.xz"
10+
tar xf "$WASMTIME.tar.xz"

ci/linux_ci

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,29 @@
33
set -x
44
set -e
55

6-
ZIG="zig-linux-x86_64-0.8.0-dev.2667+44de88498"
6+
ARCH="x86_64"
7+
OS="linux"
8+
ARCH_OS="${ARCH}-${OS}"
9+
OS_ARCH="${OS}-${ARCH}"
10+
11+
ZIG_SRC="https://ziglang.org/download/index.json"
12+
ZIG_VERSION=$(curl -s ${ZIG_SRC} | jq -r '.master.version')
13+
ZIG="zig-${OS_ARCH}-$ZIG_VERSION"
14+
ZIG_MASTER=$(curl -s ${ZIG_SRC} | jq -r --arg ARCH_OS "$ARCH_OS" '.master[$ARCH_OS].tarball')
15+
716
WASMTIME_VERSION="v0.24.0"
8-
WASMTIME="wasmtime-$WASMTIME_VERSION-x86_64-linux-c-api"
9-
GYRO_VERSION="0.2.3"
10-
GYRO="gyro-$GYRO_VERSION-linux-x86_64"
17+
WASMTIME="wasmtime-$WASMTIME_VERSION-${ARCH_OS}-c-api"
18+
GYRO_VERSION="0.7.0"
19+
GYRO="gyro-$GYRO_VERSION-${OS_ARCH}"
1120

12-
wget -nv "https://ziglang.org/builds/$ZIG.tar.xz"
21+
# TODO: make this nice
22+
curl -sL "${ZIG_MASTER}" -o "$ZIG.tar.xz"
1323
tar xf "$ZIG.tar.xz"
1424
export PATH="$(pwd)/$ZIG:$PATH"
1525

16-
wget -nv "https://github.com/bytecodealliance/wasmtime/releases/download/$WASMTIME_VERSION/$WASMTIME.tar.xz"
17-
tar xf "$WASMTIME.tar.xz"
26+
./ci/install_wasmtime $WASMTIME_VERSION $WASMTIME
1827

19-
wget -nv "https://github.com/mattnite/gyro/releases/download/$GYRO_VERSION/$GYRO.tar.gz"
20-
tar xf "$GYRO.tar.gz"
28+
./ci/install_gyro $GYRO_VERSION $GYRO
2129
export PATH="$(pwd)/$GYRO/bin:$PATH"
2230

23-
gyro build
24-
gyro build test
25-
gyro build run -Dexample=simple --search-prefix "$(pwd)/$WASMTIME"
26-
gyro build run -Dexample=gcd --search-prefix "$(pwd)/$WASMTIME"
27-
gyro build run -Dexample=linking --search-prefix "$(pwd)/$WASMTIME"
28-
gyro build run -Dexample=memory --search-prefix "$(pwd)/$WASMTIME"
29-
gyro build run -Dexample=interrupt --search-prefix "$(pwd)/$WASMTIME"
30-
31+
./ci/run_gyro $WASMTIME

ci/macos_ci

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
set -x
44
set -e
55

6-
ZIG="zig-macos-x86_64-0.8.0-dev.2670+d8d92dafe"
6+
ARCH="x86_64"
7+
OS="macos"
8+
ARCH_OS="${ARCH}-${OS}"
9+
OS_ARCH="${OS}-${ARCH}"
10+
11+
ZIG_SRC="https://ziglang.org/download/index.json"
12+
ZIG_VERSION=$(curl -s ${ZIG_SRC} | jq -r '.master.version')
13+
ZIG="zig-${OS_ARCH}-$ZIG_VERSION"
14+
ZIG_MASTER=$(curl -s ${ZIG_SRC} | jq -r --arg ARCH_OS "$ARCH_OS" '.master[$ARCH_OS].tarball')
15+
716
WASMTIME_VERSION="v0.24.0"
817
WASMTIME="wasmtime-$WASMTIME_VERSION-x86_64-macos-c-api"
9-
GYRO_VERSION="0.2.3"
18+
GYRO_VERSION="0.7.0"
1019
GYRO="gyro-$GYRO_VERSION-macos-x86_64"
1120

12-
curl -L "https://ziglang.org/builds/$ZIG.tar.xz" -o "$ZIG.tar.xz"
21+
curl -sL "${ZIG_MASTER}" -o "$ZIG.tar.xz"
1322
tar xf "$ZIG.tar.xz"
1423
export PATH="$(pwd)/$ZIG:$PATH"
1524

16-
curl -L "https://github.com/bytecodealliance/wasmtime/releases/download/$WASMTIME_VERSION/$WASMTIME.tar.xz" -o "$WASMTIME.tar.xz"
17-
tar xf "$WASMTIME.tar.xz"
25+
./ci/install_wasmtime $WASMTIME_VERSION $WASMTIME
1826

19-
curl -L "https://github.com/mattnite/gyro/releases/download/$GYRO_VERSION/$GYRO.tar.gz" -o "$GYRO.tar.gz"
20-
tar xf "$GYRO.tar.gz"
27+
./ci/install_gyro $GYRO_VERSION $GYRO
2128
export PATH="$(pwd)/$GYRO/bin:$PATH"
2229

23-
gyro build
24-
gyro build test
25-
gyro build run -Dexample=simple --search-prefix "$(pwd)/$WASMTIME"
26-
gyro build run -Dexample=gcd --search-prefix "$(pwd)/$WASMTIME"
27-
gyro build run -Dexample=linking --search-prefix "$(pwd)/$WASMTIME"
28-
gyro build run -Dexample=memory --search-prefix "$(pwd)/$WASMTIME"
29-
gyro build run -Dexample=interrupt --search-prefix "$(pwd)/$WASMTIME"
30-
30+
./ci/run_gyro $WASMTIME

ci/run_gyro

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
WASMTIME=$1
7+
8+
gyro build
9+
gyro build test
10+
gyro build run -Dexample=simple --search-prefix "$(pwd)/$WASMTIME"
11+
gyro build run -Dexample=gcd --search-prefix "$(pwd)/$WASMTIME"
12+
gyro build run -Dexample=linking --search-prefix "$(pwd)/$WASMTIME"
13+
gyro build run -Dexample=memory --search-prefix "$(pwd)/$WASMTIME"
14+
gyro build run -Dexample=interrupt --search-prefix "$(pwd)/$WASMTIME"

ci/win_ci

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
set -x
44
set -e
55

6-
ZIG="zig-windows-x86_64-0.8.0-dev.2667+44de88498"
6+
ARCH="x86_64"
7+
OS="windows"
8+
ARCH_OS="${ARCH}-${OS}"
9+
OS_ARCH="${OS}-${ARCH}"
10+
11+
ZIG_SRC="https://ziglang.org/download/index.json"
12+
ZIG_VERSION=$(curl -s ${ZIG_SRC} | jq -r '.master.version')
13+
ZIG="zig-${OS_ARCH}-$ZIG_VERSION"
14+
ZIG_MASTER=$(curl -s ${ZIG_SRC} | jq -r --arg ARCH_OS "$ARCH_OS" '.master[$ARCH_OS].tarball')
15+
716
WASMTIME_VERSION="v0.24.0"
8-
WASMTIME="wasmtime-$WASMTIME_VERSION-x86_64-windows-c-api"
9-
GYRO_VERSION="0.2.3"
10-
GYRO="gyro-$GYRO_VERSION-windows-x86_64"
17+
WASMTIME="wasmtime-$WASMTIME_VERSION-${ARCH_OS}-c-api"
18+
GYRO_VERSION="0.7.0"
19+
GYRO="gyro-$GYRO_VERSION-${OS_ARCH}"
1120

12-
curl -L "https://ziglang.org/builds/$ZIG.zip" -o "$ZIG.zip"
21+
curl -sL "${ZIG_MASTER}" -o "$ZIG.zip"
1322
7z x "$ZIG.zip"
1423
export PATH="$(pwd)/$ZIG:$PATH"
1524

16-
curl -L "https://github.com/bytecodealliance/wasmtime/releases/download/$WASMTIME_VERSION/$WASMTIME.zip" -o "$WASMTIME.zip"
25+
curl -sL "https://github.com/bytecodealliance/wasmtime/releases/download/$WASMTIME_VERSION/$WASMTIME.zip" -o "$WASMTIME.zip"
1726
7z x "$WASMTIME.zip"
1827

19-
curl -L "https://github.com/mattnite/gyro/releases/download/$GYRO_VERSION/$GYRO.zip" -o "$GYRO.zip"
28+
curl -sL "https://github.com/mattnite/gyro/releases/download/$GYRO_VERSION/$GYRO.zip" -o "$GYRO.zip"
2029
7z x "$GYRO.zip"
2130
export PATH="$(pwd)/$GYRO/bin:$PATH"
2231

23-
gyro build
24-
gyro build test
25-
gyro build run -Dexample=simple --search-prefix "$(pwd)/$WASMTIME"
26-
gyro build run -Dexample=gcd --search-prefix "$(pwd)/$WASMTIME"
27-
gyro build run -Dexample=linking --search-prefix "$(pwd)/$WASMTIME"
28-
gyro build run -Dexample=memory --search-prefix "$(pwd)/$WASMTIME"
29-
gyro build run -Dexample=interrupt --search-prefix "$(pwd)/$WASMTIME"
30-
32+
./ci/run_gyro $WASMTIME

0 commit comments

Comments
 (0)