Browse Source

Fix zig 0.15.0-dev.1149+4e6a04929 build errors

Arnold Filip 3 weeks ago
parent
commit
9ae739c4c9
2 changed files with 12 additions and 10 deletions
  1. 5 6
      build.zig
  2. 7 4
      test/tests.zig

+ 5 - 6
build.zig

@@ -126,19 +126,18 @@ pub fn build(b: *Build) !void {
     if (!validate_exercises()) std.process.exit(2);
 
     use_color_escapes = false;
-    if (std.io.getStdErr().supportsAnsiEscapeCodes()) {
+    if (std.fs.File.stderr().supportsAnsiEscapeCodes()) {
         use_color_escapes = true;
     } else if (builtin.os.tag == .windows) {
         const w32 = struct {
-            const WINAPI = std.os.windows.WINAPI;
             const DWORD = std.os.windows.DWORD;
             const ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
             const STD_ERROR_HANDLE: DWORD = @bitCast(@as(i32, -12));
-            extern "kernel32" fn GetStdHandle(id: DWORD) callconv(WINAPI) ?*anyopaque;
-            extern "kernel32" fn GetConsoleMode(console: ?*anyopaque, out_mode: *DWORD) callconv(WINAPI) u32;
-            extern "kernel32" fn SetConsoleMode(console: ?*anyopaque, mode: DWORD) callconv(WINAPI) u32;
+            const GetStdHandle = std.os.windows.kernel32.GetStdHandle;
+            const GetConsoleMode = std.os.windows.kernel32.GetConsoleMode;
+            const SetConsoleMode = std.os.windows.kernel32.SetConsoleMode;
         };
-        const handle = w32.GetStdHandle(w32.STD_ERROR_HANDLE);
+        const handle = w32.GetStdHandle(w32.STD_ERROR_HANDLE).?;
         var mode: w32.DWORD = 0;
         if (w32.GetConsoleMode(handle, &mode) != 0) {
             mode |= w32.ENABLE_VIRTUAL_TERMINAL_PROCESSING;

+ 7 - 4
test/tests.zig

@@ -161,7 +161,8 @@ const CheckNamedStep = struct {
         );
         defer stderr_file.close();
 
-        const stderr = stderr_file.reader();
+        var buffer: [4096]u8 = undefined;
+        const stderr = stderr_file.reader(&buffer);
         {
             // Skip the logo.
             const nlines = mem.count(u8, root.logo, "\n");
@@ -213,7 +214,8 @@ const CheckStep = struct {
         );
         defer stderr_file.close();
 
-        const stderr = stderr_file.reader();
+        var buffer: [4096]u8 = undefined;
+        const stderr = stderr_file.reader(&buffer);
         for (exercises) |ex| {
             if (ex.number() == 1) {
                 // Skip the logo.
@@ -298,7 +300,7 @@ fn check(
 }
 
 fn readLine(reader: fs.File.Reader, buf: []u8) !?[]const u8 {
-    if (try reader.readUntilDelimiterOrEof(buf, '\n')) |line| {
+    if (try reader.file.deprecatedReader().readUntilDelimiterOrEof(buf, '\n')) |line| {
         return mem.trimRight(u8, line, " \r\n");
     }
 
@@ -405,7 +407,8 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8
 /// difference that returns an error when the temp path cannot be created.
 pub fn makeTempPath(b: *Build) ![]const u8 {
     const rand_int = std.crypto.random.int(u64);
-    const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ Build.hex64(rand_int);
+    const rand_hex64 = std.fmt.hex(rand_int);
+    const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ rand_hex64;
     const path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch
         @panic("OOM");
     try b.cache_root.handle.makePath(tmp_dir_sub_path);