From b208a33286d62e9c06dd2df777b7a65cabff82ce Mon Sep 17 00:00:00 2001 From: root Date: Mon, 23 Nov 2020 22:14:50 -0600 Subject: [PATCH 1/2] Skip folder named zig while searching for zig executable on *nix --- build.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index fd928df..7d0cbab 100644 --- a/build.zig +++ b/build.zig @@ -31,11 +31,17 @@ pub fn config(step: *std.build.Step) anyerror!void { const full_path = try std.fs.path.join(allocator, &[_][]const u8{ path, zig_exe, - }); + }); defer allocator.free(full_path); + + // Skip folders named zig + const file = std.fs.openFileAbsolute(full_path, .{}) catch continue; + const stat = file.stat() catch continue; + const is_dir = stat.kind == .Directory ; + if(is_dir) continue ; var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; - zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue); + zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue); break :find_zig; } } From 60ad93ca34d3fc051df171ae01470b266f9559e9 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 23 Nov 2020 22:20:22 -0600 Subject: [PATCH 2/2] Skip folder named zig while searching for zig executable on *nix --- build.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index 7d0cbab..271a544 100644 --- a/build.zig +++ b/build.zig @@ -31,17 +31,17 @@ pub fn config(step: *std.build.Step) anyerror!void { const full_path = try std.fs.path.join(allocator, &[_][]const u8{ path, zig_exe, - }); + }); defer allocator.free(full_path); - + // Skip folders named zig const file = std.fs.openFileAbsolute(full_path, .{}) catch continue; const stat = file.stat() catch continue; - const is_dir = stat.kind == .Directory ; - if(is_dir) continue ; + const is_dir = stat.kind == .Directory; + if (is_dir) continue; var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; - zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue); + zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue); break :find_zig; } }