@@ -192,6 +192,7 @@ pub fn build(b: *std.Build) void {
192192 const optimize = b .standardOptimizeOption (.{});
193193 const test_coverage = b .option (bool , "coverage" , "Generate a coverage report with kcov" );
194194 const test_focus_on_rule = b .option ([]const u8 , "test_focus_on_rule" , "Only run integration tests for this rule" );
195+ const io = b .graph .io ;
195196
196197 const zlinter_lib_module = b .addModule ("zlinter" , .{
197198 .root_source_file = b .path ("src/lib/zlinter.zig" ),
@@ -488,11 +489,11 @@ pub fn build(b: *std.Build) void {
488489 const rules_path = rules_lazy_path .getPath3 (b , step );
489490 _ = step .addDirectoryWatchInput (rules_lazy_path ) catch @panic ("OOM" );
490491
491- var rules_dir = rules_path .root_dir .handle .openDir (rules_path .subPathOrDot (), .{ .iterate = true }) catch @panic ("unable to open rules/ directory" );
492- defer rules_dir .close ();
492+ var rules_dir = rules_path .root_dir .handle .openDir (io , rules_path .subPathOrDot (), .{ .iterate = true }) catch @panic ("unable to open rules/ directory" );
493+ defer rules_dir .close (io );
493494 {
494495 var it = rules_dir .walk (b .allocator ) catch @panic ("OOM" );
495- while (it .next () catch @panic ("OOM" )) | entry | {
496+ while (it .next (io ) catch @panic ("OOM" )) | entry | {
496497 if (! std .mem .endsWith (u8 , entry .basename , ".zig" )) continue ;
497498 doc_build_run .addFileArg (b .path (b .pathJoin (&.{ "src/rules" , entry .path })));
498499 }
@@ -595,7 +596,9 @@ fn addWatchInput(
595596) ! void {
596597 const src_dir_path = file_or_dir .getPath3 (b , step );
597598
599+ const io = b .graph .io ;
598600 var src_dir = src_dir_path .root_dir .handle .openDir (
601+ io ,
599602 src_dir_path .subPathOrDot (),
600603 .{ .iterate = true },
601604 ) catch | e | switch (e ) {
@@ -608,14 +611,14 @@ fn addWatchInput(
608611 .@"0.15" , .@"0.16" = > @panic (b .fmt ("Unable to open directory '{f}': {t}" , .{ src_dir_path , e })),
609612 },
610613 };
611- defer src_dir .close ();
614+ defer src_dir .close (io );
612615
613616 const needs_dir_derived = try step .addDirectoryWatchInput (file_or_dir );
614617
615618 var it = try src_dir .walk (b .allocator );
616619 defer it .deinit ();
617620
618- while (try it .next ()) | entry | {
621+ while (try it .next (io )) | entry | {
619622 switch (entry .kind ) {
620623 .directory = > if (needs_dir_derived ) {
621624 const entry_path = try src_dir_path .join (b .allocator , entry .path );
@@ -867,6 +870,7 @@ const ZlinterRun = struct {
867870 fn make (step : * std.Build.Step , _ : std.Build.Step.MakeOptions ) ! void {
868871 const run : * ZlinterRun = @alignCast (@fieldParentPtr ("step" , step ));
869872 const b = run .step .owner ;
873+ const io = b .graph .io ;
870874 const arena = b .allocator ;
871875
872876 var cwd_buff : [std .fs .max_path_bytes ]u8 = undefined ;
@@ -1021,13 +1025,12 @@ const ZlinterRun = struct {
10211025
10221026 var timer = try std .time .Timer .start ();
10231027
1024- std .debug .lockStdErr ();
1025- defer std .debug .unlockStdErr ();
1026-
1027- child .spawn () catch | err | {
1028+ _ = std .debug .lockStderr (&.{});
1029+ defer std .debug .unlockStderr ();
1030+ child .spawn (io ) catch | err | {
10281031 return run .step .fail ("Unable to spawn zlinter: {s}" , .{@errorName (err )});
10291032 };
1030- errdefer _ = child .kill () catch {};
1033+ errdefer _ = child .kill (io ) catch {};
10311034
10321035 {
10331036 if (b .verbose )
@@ -1042,15 +1045,15 @@ const ZlinterRun = struct {
10421045 },
10431046 .@"0.15" , .@"0.16" = > {
10441047 var buffer : [1024 ]u8 = undefined ;
1045- var writer = stdin_file .writer (& buffer );
1048+ var writer = stdin_file .writer (io , & buffer );
10461049 writer .interface .writeInt (usize , build_info_zon_bytes .len , .little ) catch @panic ("stdin write failed" );
10471050 writer .interface .writeAll (build_info_zon_bytes ) catch @panic ("stdin write failed" );
10481051 writer .interface .flush () catch @panic ("Flush failed" );
10491052 },
10501053 }
10511054 }
10521055
1053- const term = try child .wait ();
1056+ const term = try child .wait (io );
10541057
10551058 step .result_duration_ns = timer .read ();
10561059 step .result_peak_rss = child .resource_usage_statistics .getMaxRss () orelse 0 ;
@@ -1092,8 +1095,9 @@ const ZlinterRun = struct {
10921095fn readHtmlTemplate (b : * std.Build , path : std.Build.LazyPath ) ! []const u8 {
10931096 const rules_path = path .getPath3 (b , null );
10941097
1095- var file = try rules_path .root_dir .handle .openFile (rules_path .subPathOrDot (), .{});
1096- defer file .close ();
1098+ const io = b .graph .io ;
1099+ var file = try rules_path .root_dir .handle .openFile (io , rules_path .subPathOrDot (), .{});
1100+ defer file .close (io );
10971101
10981102 var file_buffer : [1024 ]u8 = undefined ;
10991103 var file_reader = file .reader (b .graph .io , & file_buffer );
@@ -1146,11 +1150,11 @@ fn readHtmlTemplate(b: *std.Build, path: std.Build.LazyPath) ![]const u8 {
11461150/// Normalised representation of the current working directory
11471151const BuildCwd = struct {
11481152 path : []const u8 ,
1149- dir : std.fs .Dir ,
1153+ dir : std.Io .Dir ,
11501154
11511155 pub fn init (buff : * [std .fs .max_path_bytes ]u8 ) BuildCwd {
11521156 return .{
1153- .dir = std .fs .cwd (),
1157+ .dir = std .Io . Dir .cwd (),
11541158 .path = std .process .getCwd (buff ) catch unreachable ,
11551159 };
11561160 }
@@ -1182,22 +1186,23 @@ const BuildCwd = struct {
11821186 };
11831187 errdefer b .allocator .free (relative );
11841188
1185- if (relative .len != 0 and isReadable (& self .dir , relative )) {
1189+ if (relative .len != 0 and isReadable (b , & self .dir , relative )) {
11861190 return b .path (relative );
11871191 } else {
11881192 b .allocator .free (relative );
11891193 return null ;
11901194 }
11911195 } else {
1192- if (isReadable (& self .dir , to )) {
1196+ if (isReadable (b , & self .dir , to )) {
11931197 return b .path (b .dupe (to ));
11941198 }
11951199 }
11961200 return null ;
11971201 }
11981202
1199- fn isReadable (from : * const std.fs .Dir , sub_path : []const u8 ) bool {
1203+ fn isReadable (b : * std.Build , from : * const std.Io .Dir , sub_path : []const u8 ) bool {
12001204 _ = from .access (
1205+ b .graph .io ,
12011206 sub_path ,
12021207 .{ .read = true },
12031208 ) catch return false ;
0 commit comments