Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for deprecated aliases in std #140

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn ci(
var previous_test_step = test_step;

for (ci_targets) |ci_target_str| {
const target = b.resolveTargetQuery(try std.zig.CrossTarget.parse(
const target = b.resolveTargetQuery(try std.Target.Query.parse(
.{ .arch_os_abi = ci_target_str },
));
const optimize: std.builtin.OptimizeMode =
Expand Down
22 changes: 11 additions & 11 deletions zigup.zig
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ pub fn loggySymlinkAbsolute(target_path: []const u8, sym_link_path: []const u8,

/// returns: true if the symlink was updated, false if it was already set to the given `target_path`
pub fn loggyUpdateSymlink(target_path: []const u8, sym_link_path: []const u8, flags: std.fs.Dir.SymLinkFlags) !bool {
var current_target_path_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var current_target_path_buffer: [std.fs.max_path_bytes]u8 = undefined;
if (std.fs.readLinkAbsolute(sym_link_path, &current_target_path_buffer)) |current_target_path| {
if (std.mem.eql(u8, target_path, current_target_path)) {
loginfo("symlink '{s}' already points to '{s}'", .{ sym_link_path, target_path });
Expand Down Expand Up @@ -631,7 +631,7 @@ fn cleanCompilers(allocator: Allocator, compiler_name_opt: ?[]const u8) !void {
}
}
}
fn readDefaultCompiler(allocator: Allocator, buffer: *[std.fs.MAX_PATH_BYTES + 1]u8) !?[]const u8 {
fn readDefaultCompiler(allocator: Allocator, buffer: *[std.fs.max_path_bytes + 1]u8) !?[]const u8 {
const path_link = try makeZigPathLinkString(allocator);
defer allocator.free(path_link);

Expand All @@ -651,7 +651,7 @@ fn readDefaultCompiler(allocator: Allocator, buffer: *[std.fs.MAX_PATH_BYTES + 1
return try allocator.dupe(u8, targetPathToVersion(target_exe));
}

const target_path = std.fs.readLinkAbsolute(path_link, buffer[0..std.fs.MAX_PATH_BYTES]) catch |e| switch (e) {
const target_path = std.fs.readLinkAbsolute(path_link, buffer[0..std.fs.max_path_bytes]) catch |e| switch (e) {
error.FileNotFound => return null,
else => return e,
};
Expand All @@ -662,7 +662,7 @@ fn targetPathToVersion(target_path: []const u8) []const u8 {
return std.fs.path.basename(std.fs.path.dirname(std.fs.path.dirname(target_path).?).?);
}

fn readMasterDir(buffer: *[std.fs.MAX_PATH_BYTES]u8, install_dir: *std.fs.Dir) !?[]const u8 {
fn readMasterDir(buffer: *[std.fs.max_path_bytes]u8, install_dir: *std.fs.Dir) !?[]const u8 {
if (builtin.os.tag == .windows) {
var file = install_dir.openFile("master", .{}) catch |e| switch (e) {
error.FileNotFound => return null,
Expand All @@ -678,15 +678,15 @@ fn readMasterDir(buffer: *[std.fs.MAX_PATH_BYTES]u8, install_dir: *std.fs.Dir) !
}

fn getDefaultCompiler(allocator: Allocator) !?[]const u8 {
var buffer: [std.fs.MAX_PATH_BYTES + 1]u8 = undefined;
var buffer: [std.fs.max_path_bytes + 1]u8 = undefined;
const slice_path = (try readDefaultCompiler(allocator, &buffer)) orelse return null;
const path_to_return = try allocator.alloc(u8, slice_path.len);
@memcpy(path_to_return, slice_path);
return path_to_return;
}

fn getMasterDir(allocator: Allocator, install_dir: *std.fs.Dir) !?[]const u8 {
var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var buffer: [std.fs.max_path_bytes]u8 = undefined;
const slice_path = (try readMasterDir(&buffer, install_dir)) orelse return null;
const path_to_return = try allocator.alloc(u8, slice_path.len);
@memcpy(path_to_return, slice_path);
Expand Down Expand Up @@ -773,7 +773,7 @@ fn verifyPathLink(allocator: Allocator, path_link: []const u8) !void {
break :blk "";
};

var path_it = std.mem.tokenize(u8, path_env, ";");
var path_it = std.mem.tokenizeScalar(u8, path_env, ';');
while (path_it.next()) |path| {
switch (try compareDir(path_link_dir_id, path)) {
.missing => continue,
Expand All @@ -789,7 +789,7 @@ fn verifyPathLink(allocator: Allocator, path_link: []const u8) !void {
try enforceNoZig(path_link, exe);
}

var ext_it = std.mem.tokenize(u8, pathext_env, ";");
var ext_it = std.mem.tokenizeScalar(u8, pathext_env, ';');
while (ext_it.next()) |ext| {
if (ext.len == 0) continue;
const basename = try std.mem.concat(allocator, u8, &.{ "zig", ext });
Expand All @@ -802,7 +802,7 @@ fn verifyPathLink(allocator: Allocator, path_link: []const u8) !void {
}
}
} else {
var path_it = std.mem.tokenize(u8, std.posix.getenv("PATH") orelse "", ":");
var path_it = std.mem.tokenizeScalar(u8, std.posix.getenv("PATH") orelse "", ':');
while (path_it.next()) |path| {
switch (try compareDir(path_link_dir_id, path)) {
.missing => continue,
Expand Down Expand Up @@ -924,8 +924,8 @@ const win32exelink = struct {
};
};
fn createExeLink(link_target: []const u8, path_link: []const u8) !void {
if (path_link.len > std.fs.MAX_PATH_BYTES) {
std.debug.print("Error: path_link (size {}) is too large (max {})\n", .{ path_link.len, std.fs.MAX_PATH_BYTES });
if (path_link.len > std.fs.max_path_bytes) {
std.debug.print("Error: path_link (size {}) is too large (max {})\n", .{ path_link.len, std.fs.max_path_bytes });
return error.AlreadyReported;
}
const file = std.fs.cwd().createFile(path_link, .{}) catch |err| switch (err) {
Expand Down