Skip to content

Commit

Permalink
scm: Fix Zig build examples from dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mochalins authored and jinzhongjia committed Oct 12, 2024
1 parent 2702d04 commit 15e2d68
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,17 @@ fn build_examples(b: *Build, webui: *Compile) !void {

const examples_path = (if (zig_ver < 12) (Build.LazyPath{ .path = "examples/C" }) else b.path("examples/C")).getPath(b);
var examples_dir = if (zig_ver < 12)
try std.fs.cwd().openIterableDir(examples_path, .{})
std.fs.cwd().openIterableDir(examples_path, .{}) catch |e| switch (e) {
// Do not attempt building examples if directory does not exist.
error.FileNotFound => return,
else => return e,
}
else
try std.fs.cwd().openDir(examples_path, .{ .iterate = true });
std.fs.cwd().openDir(examples_path, .{ .iterate = true }) catch |e| switch (e) {
// Do not attempt building examples if directory does not exist.
error.FileNotFound => return,
else => return e,
};
defer examples_dir.close();

var paths = examples_dir.iterate();
Expand Down

0 comments on commit 15e2d68

Please sign in to comment.