mirror of
https://github.com/ziglang/zig.git
synced 2025-01-23 02:16:29 +00:00
build.zig: better detection of using outside zig executable
As pointed out by gereeter, dirname("/") successfully returns "/" again. So checking for null is not sufficient.
This commit is contained in:
parent
12cdea4525
commit
dc7e8b2fdc
@ -352,11 +352,13 @@ fn findAndParseConfigH(b: *Builder) !Context {
|
||||
const max_bytes = 1 * 1024 * 1024;
|
||||
const config_h_text = dir.readFileAlloc(b.allocator, "config.h", max_bytes) catch |err| switch (err) {
|
||||
error.FileNotFound => {
|
||||
check_dir = fs.path.dirname(check_dir) orelse {
|
||||
const new_check_dir = fs.path.dirname(check_dir);
|
||||
if (new_check_dir == null or mem.eql(u8, new_check_dir.?, check_dir)) {
|
||||
std.debug.warn("Unable to find config.h file relative to Zig executable.\n", .{});
|
||||
std.debug.warn("`zig build` must be run using a Zig executable within the source tree.\n", .{});
|
||||
std.process.exit(1);
|
||||
};
|
||||
}
|
||||
check_dir = new_check_dir.?;
|
||||
continue;
|
||||
},
|
||||
else => |e| return e,
|
||||
|
Loading…
Reference in New Issue
Block a user