Skip to content

Commit 45ae4b3

Browse files
committed
build: fail unsupported examples/benches on wasi during runtime
1 parent 612d425 commit 45ae4b3

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

bench/flow.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ fn client(startup: *coro.ResetEvent, mode: ClientMode) !void {
203203
}
204204

205205
pub fn main() !void {
206+
if (builtin.target.os.tag == .wasi) return error.UnsupportedPlatform;
206207
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
207208
defer _ = gpa.deinit();
208209
const allocator = gpa.allocator();

bench/ping_pongs.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// provided by mrjbq7
22

3+
const builtin = @import("builtin");
34
const std = @import("std");
45
const aio = @import("aio");
56
const coro = @import("coro");
@@ -92,6 +93,7 @@ fn client(startup: *coro.ResetEvent) !void {
9293
}
9394

9495
pub fn main() !void {
96+
if (builtin.target.os.tag == .wasi) return error.UnsupportedPlatform;
9597
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
9698
defer _ = gpa.deinit();
9799
var scheduler = try coro.Scheduler.init(gpa.allocator(), .{});

build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ pub fn build(b: *std.Build) void {
6969
.coro,
7070
.coro_wttr,
7171
}) |example| {
72+
const os = target.query.os_tag orelse builtin.os.tag;
7273
const exe = b.addExecutable(.{
7374
.name = @tagName(example),
7475
.root_source_file = b.path("examples/" ++ @tagName(example) ++ ".zig"),
7576
.target = target,
7677
.optimize = optimize,
7778
.sanitize_thread = sanitize,
78-
.single_threaded = if (example == .coro_wttr) false else single_threaded,
79+
.single_threaded = if (example == .coro_wttr and os != .wasi) false else single_threaded,
7980
.strip = false,
8081
});
8182
exe.root_module.addImport("aio", aio);

examples/coro.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const builtin = @import("builtin");
12
const std = @import("std");
23
const aio = @import("aio");
34
const coro = @import("coro");
@@ -81,6 +82,7 @@ fn client(startup: *coro.ResetEvent) !void {
8182
}
8283

8384
pub fn main() !void {
85+
if (builtin.target.os.tag == .wasi) return error.UnsupportedPlatform;
8486
// var mem: [4096 * 1024]u8 = undefined;
8587
// var fba = std.heap.FixedBufferAllocator.init(&mem);
8688
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};

examples/coro_wttr.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ fn loader(completed: *std.atomic.Value(u32), max: *const u32) !void {
6666
}
6767

6868
pub fn main() !void {
69+
if (builtin.target.os.tag == .wasi) return error.UnsupportedPlatform;
6970
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
7071
defer _ = gpa.deinit();
7172
const allocator = gpa.allocator();

0 commit comments

Comments
 (0)