Skip to content

Commit

Permalink
fix(#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
RonaldZielaznicki committed Oct 18, 2024
1 parent 3d5599b commit 09a9219
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub fn build(b: *Build) !void {

// For some reason, msvc target needs atls.lib to be in the 'zig build' working directory.
// Addomg tp the library path like this has no effect:
dxc_exe.addLibraryPath(b.path(lib_dir_path));
dxc_exe.addLibraryPath(.{ .cwd_relative = lib_dir_path });
// So instead we must copy the lib into this directory:
try std.fs.cwd().copyFile(lib_path, std.fs.cwd(), "atls.lib", .{});
try std.fs.cwd().copyFile(pdb_path, std.fs.cwd(), pdb_name, .{});
Expand Down
16 changes: 8 additions & 8 deletions msvc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const RegistryUtf8 = struct {
const value_utf16le = try registry_utf16le.getString(allocator, subkey_utf16le, value_name_utf16le);
defer allocator.free(value_utf16le);

const value_utf8: []u8 = std.unicode.utf16leToUtf8Alloc(allocator, value_utf16le) catch |err| switch (err) {
const value_utf8: []u8 = std.unicode.utf16LeToUtf8Alloc(allocator, value_utf16le) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
else => return error.StringNotFound,
};
Expand Down Expand Up @@ -368,7 +368,7 @@ pub const Windows10Sdk = struct {
error.OutOfMemory => return error.OutOfMemory,
};

if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
allocator.free(path_maybe_with_trailing_slash);
return error.PathTooLong;
}
Expand Down Expand Up @@ -414,7 +414,7 @@ pub const Windows10Sdk = struct {

/// Check whether this version is enumerated in registry.
fn isValidVersion(windows10sdk: *const Windows10Sdk) bool {
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var buf: [std.fs.max_path_bytes]u8 = undefined;
const reg_query_as_utf8 = std.fmt.bufPrint(buf[0..], "{s}\\{s}\\Installed Options", .{ WINDOWS_KIT_REG_KEY, windows10sdk.version }) catch |err| switch (err) {
error.NoSpaceLeft => return false,
};
Expand Down Expand Up @@ -458,7 +458,7 @@ pub const Windows81Sdk = struct {

error.OutOfMemory => return error.OutOfMemory,
};
if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
allocator.free(path_maybe_with_trailing_slash);
return error.PathTooLong;
}
Expand All @@ -475,7 +475,7 @@ pub const Windows81Sdk = struct {
errdefer allocator.free(path);

const version: []const u8 = version81: {
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var buf: [std.fs.max_path_bytes]u8 = undefined;
const sdk_lib_dir_path = std.fmt.bufPrint(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) {
error.NoSpaceLeft => return error.PathTooLong,
};
Expand Down Expand Up @@ -822,7 +822,7 @@ pub const MsvcLibDir = struct {
error.OutOfMemory => return error.OutOfMemory,
else => continue,
};
if (source_directories_value.len > (std.fs.MAX_PATH_BYTES * 30)) { // note(bratishkaerik): guessing from the fact that on my computer it has 15 pathes and at least some of them are not of max length
if (source_directories_value.len > (std.fs.max_path_bytes * 30)) { // note(bratishkaerik): guessing from the fact that on my computer it has 15 pathes and at least some of them are not of max length
allocator.free(source_directories_value);
continue;
}
Expand All @@ -836,7 +836,7 @@ pub const MsvcLibDir = struct {
const msvc_dir: []const u8 = msvc_dir: {
const msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());

if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {
if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {
allocator.free(msvc_include_dir_maybe_with_trailing_slash);
return error.PathNotFound;
}
Expand Down Expand Up @@ -904,7 +904,7 @@ pub const MsvcLibDir = struct {
else => break :try_vs7_key,
};

if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
allocator.free(path_maybe_with_trailing_slash);
break :try_vs7_key;
}
Expand Down

0 comments on commit 09a9219

Please sign in to comment.