diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-04-04 14:05:49 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-04-04 14:05:49 -0400 |
| commit | dc7e8b2fdcc35bc78abfe2413201ca6a74aa20d4 (patch) | |
| tree | fe0f72cfbe5c2421ac245277f405c6b5ac56ef9f /build.zig | |
| parent | 12cdea452524e4b852cb433728c834a7b0203b67 (diff) | |
| download | zig-dc7e8b2fdcc35bc78abfe2413201ca6a74aa20d4.tar.gz zig-dc7e8b2fdcc35bc78abfe2413201ca6a74aa20d4.zip | |
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.
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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, |
