commit 7717cacacbf86e069ff3ffebf4a1a24f1a74903f (tree)
parent 58d3ee2a08f5a1f1c66d5e3b4f215361073c6372
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 21 Nov 2022 16:46:45 -0700
CLI: resolve zig lib directory before using it
Fixes issues with trailing slashes and things like this.
Diffstat:
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/Cache.zig b/src/Cache.zig
@@ -31,6 +31,9 @@ const Compilation = @import("Compilation.zig");
const log = std.log.scoped(.cache);
pub fn addPrefix(cache: *Cache, directory: Compilation.Directory) void {
+ if (directory.path) |p| {
+ log.debug("Cache.addPrefix {d} {s}", .{ cache.prefixes_len, p });
+ }
cache.prefixes_buffer[cache.prefixes_len] = directory;
cache.prefixes_len += 1;
}
diff --git a/src/main.zig b/src/main.zig
@@ -2744,11 +2744,14 @@ fn buildOutputType(
}
const self_exe_path = try introspect.findZigExePath(arena);
- var zig_lib_directory: Compilation.Directory = if (override_lib_dir) |lib_dir| .{
- .path = lib_dir,
- .handle = fs.cwd().openDir(lib_dir, .{}) catch |err| {
- fatal("unable to open zig lib directory '{s}': {s}", .{ lib_dir, @errorName(err) });
- },
+ var zig_lib_directory: Compilation.Directory = if (override_lib_dir) |unresolved_lib_dir| l: {
+ const lib_dir = try fs.path.resolve(arena, &.{unresolved_lib_dir});
+ break :l .{
+ .path = lib_dir,
+ .handle = fs.cwd().openDir(lib_dir, .{}) catch |err| {
+ fatal("unable to open zig lib directory '{s}': {s}", .{ lib_dir, @errorName(err) });
+ },
+ };
} else introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| {
fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
};