mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
CLI: resolve zig lib directory before using it
Fixes issues with trailing slashes and things like this.
This commit is contained in:
parent
58d3ee2a08
commit
7717cacacb
@ -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;
|
||||
}
|
||||
|
||||
13
src/main.zig
13
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)});
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user