Skip to content

Commit 15e2d68

Browse files
mochalinsjinzhongjia
authored andcommitted
scm: Fix Zig build examples from dependency
1 parent 2702d04 commit 15e2d68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

build.zig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,17 @@ fn build_examples(b: *Build, webui: *Compile) !void {
134134

135135
const examples_path = (if (zig_ver < 12) (Build.LazyPath{ .path = "examples/C" }) else b.path("examples/C")).getPath(b);
136136
var examples_dir = if (zig_ver < 12)
137-
try std.fs.cwd().openIterableDir(examples_path, .{})
137+
std.fs.cwd().openIterableDir(examples_path, .{}) catch |e| switch (e) {
138+
// Do not attempt building examples if directory does not exist.
139+
error.FileNotFound => return,
140+
else => return e,
141+
}
138142
else
139-
try std.fs.cwd().openDir(examples_path, .{ .iterate = true });
143+
std.fs.cwd().openDir(examples_path, .{ .iterate = true }) catch |e| switch (e) {
144+
// Do not attempt building examples if directory does not exist.
145+
error.FileNotFound => return,
146+
else => return e,
147+
};
140148
defer examples_dir.close();
141149

142150
var paths = examples_dir.iterate();

0 commit comments

Comments
 (0)