Skip folder named zig while searching for zig executable on *nix

This commit is contained in:
root 2020-11-23 22:20:22 -06:00
parent b208a33286
commit 60ad93ca34

View File

@ -31,17 +31,17 @@ pub fn config(step: *std.build.Step) anyerror!void {
const full_path = try std.fs.path.join(allocator, &[_][]const u8{ const full_path = try std.fs.path.join(allocator, &[_][]const u8{
path, path,
zig_exe, zig_exe,
}); });
defer allocator.free(full_path); defer allocator.free(full_path);
// Skip folders named zig // Skip folders named zig
const file = std.fs.openFileAbsolute(full_path, .{}) catch continue; const file = std.fs.openFileAbsolute(full_path, .{}) catch continue;
const stat = file.stat() catch continue; const stat = file.stat() catch continue;
const is_dir = stat.kind == .Directory ; const is_dir = stat.kind == .Directory;
if(is_dir) continue ; if (is_dir) continue;
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; 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; break :find_zig;
} }
} }