@@ -26,7 +26,7 @@ pub fn createDisk(dimmer: Interface, size: u64, content: Content) std.Build.Lazy
2626
2727 const write_files = b .addWriteFiles ();
2828
29- const script_source , const variables = renderContent (write_files , b .allocator , content );
29+ const script_source , const variables = renderContent (write_files , b .allocator , content , dimmer . builder . graph . io );
3030
3131 const script_file = write_files .add ("image.dis" , script_source );
3232
@@ -69,6 +69,7 @@ fn renderContent(
6969 wfs : * std.Build.Step.WriteFile ,
7070 allocator : std.mem.Allocator ,
7171 content : Content ,
72+ io : std.Io ,
7273) struct { []const u8 , ContentWriter .VariableMap } {
7374 var code : std.Io.Writer.Allocating = .init (allocator );
7475 defer code .deinit ();
@@ -81,7 +82,7 @@ fn renderContent(
8182 .vars = & variables ,
8283 };
8384
84- cw .render (content ) catch @panic ("out of memory" );
85+ cw .render (content , io ) catch @panic ("out of memory" );
8586
8687 const source = std .mem .trim (
8788 u8 ,
@@ -109,7 +110,7 @@ const ContentWriter = struct {
109110 code : * std.Io.Writer ,
110111 vars : * VariableMap ,
111112
112- fn render (cw : ContentWriter , content : Content ) ! void {
113+ fn render (cw : ContentWriter , content : Content , io : std.Io ) ! void {
113114 // Always insert some padding before and after:
114115 try cw .code .writeAll (" " );
115116 errdefer cw .code .writeAll (" " ) catch {};
@@ -124,15 +125,15 @@ const ContentWriter = struct {
124125 },
125126
126127 .paste_file = > | data | {
127- try cw .code .print ("paste-file {f}" , .{cw .fmtLazyPath (data , .file )});
128+ try cw .code .print ("paste-file {f}" , .{cw .fmtLazyPath (data , .file , io )});
128129 },
129130
130131 .mbr_part_table = > | data | {
131132 try cw .code .writeAll ("mbr-part\n " );
132133
133134 if (data .bootloader ) | loader | {
134135 try cw .code .writeAll (" bootloader " );
135- try cw .render (loader .* );
136+ try cw .render (loader .* , io );
136137 try cw .code .writeAll ("\n " );
137138 }
138139
@@ -153,7 +154,7 @@ const ContentWriter = struct {
153154 try cw .code .print (" size {d}\n " , .{size });
154155 }
155156 try cw .code .writeAll (" contains" );
156- try cw .render (part .data );
157+ try cw .render (part .data , io );
157158 try cw .code .writeAll ("\n " );
158159 try cw .code .writeAll (" endpart\n " );
159160 } else {
@@ -195,7 +196,7 @@ const ContentWriter = struct {
195196 try cw .code .print (" size {d}\n " , .{size });
196197 }
197198 try cw .code .writeAll (" contains" );
198- try cw .render (part .data );
199+ try cw .render (part .data , io );
199200 try cw .code .writeAll ("\n " );
200201 try cw .code .writeAll (" endpart\n " );
201202 }
@@ -213,14 +214,14 @@ const ContentWriter = struct {
213214 });
214215 }
215216
216- try cw .renderFileSystemTree (data .tree );
217+ try cw .renderFileSystemTree (data .tree , io );
217218
218219 try cw .code .writeAll ("endfat\n " );
219220 },
220221 }
221222 }
222223
223- fn renderFileSystemTree (cw : ContentWriter , fs : FileSystem ) ! void {
224+ fn renderFileSystemTree (cw : ContentWriter , fs : FileSystem , io : std.Io ) ! void {
224225 for (fs .items ) | item | {
225226 switch (item ) {
226227 .empty_dir = > | dir | try cw .code .print ("mkdir {f}\n " , .{
@@ -229,16 +230,16 @@ const ContentWriter = struct {
229230
230231 .copy_dir = > | copy | try cw .code .print ("copy-dir {f} {f}\n " , .{
231232 fmtPath (copy .destination ),
232- cw .fmtLazyPath (copy .source , .directory ),
233+ cw .fmtLazyPath (copy .source , .directory , io ),
233234 }),
234235
235236 .copy_file = > | copy | try cw .code .print ("copy-file {f} {f}\n " , .{
236237 fmtPath (copy .destination ),
237- cw .fmtLazyPath (copy .source , .file ),
238+ cw .fmtLazyPath (copy .source , .file , io ),
238239 }),
239240
240241 .include_script = > | script | try cw .code .print ("!include {f}\n " , .{
241- cw .fmtLazyPath (script , .file ),
242+ cw .fmtLazyPath (script , .file , io ),
242243 }),
243244 }
244245 }
@@ -285,7 +286,7 @@ const ContentWriter = struct {
285286 }
286287 };
287288 const LazyPathFormatter = std .fmt .Alt (
288- struct { ContentWriter , std .Build .LazyPath , UsageHint },
289+ struct { ContentWriter , std .Build .LazyPath , UsageHint , std . Io },
289290 formatLazyPath ,
290291 );
291292 const UsageHint = enum { file , directory };
@@ -294,19 +295,20 @@ const ContentWriter = struct {
294295 cw : ContentWriter ,
295296 path : std.Build.LazyPath ,
296297 hint : UsageHint ,
298+ io : std.Io ,
297299 ) LazyPathFormatter {
298- return .{ .data = .{ cw , path , hint } };
300+ return .{ .data = .{ cw , path , hint , io } };
299301 }
300302
301303 fn fmtPath (path : []const u8 ) PathFormatter {
302304 return .{ .path = path };
303305 }
304306
305307 fn formatLazyPath (
306- data : struct { ContentWriter , std .Build .LazyPath , UsageHint },
308+ data : struct { ContentWriter , std .Build .LazyPath , UsageHint , std . Io },
307309 writer : * std.Io.Writer ,
308310 ) std.Io.Writer.Error ! void {
309- const cw , const path , const hint = data ;
311+ const cw , const path , const hint , const io = data ;
310312
311313 switch (path ) {
312314 .cwd_relative ,
@@ -319,12 +321,12 @@ const ContentWriter = struct {
319321 const rel_path = path .getPath2 (cw .wfs .step .owner , & cw .wfs .step );
320322
321323 const full_path = if (! std .fs .path .isAbsolute (rel_path ))
322- std .fs . cwd ().realpathAlloc ( cw .wfs .step .owner .allocator , rel_path ) catch @panic ("oom" )
324+ std .Io . Dir . cwd ().realPathFileAlloc ( io , rel_path , cw .wfs .step .owner .allocator ) catch @panic ("oom" )
323325 else
324326 rel_path ;
325327
326328 if (! std .fs .path .isAbsolute (full_path )) {
327- const cwd = std .fs . cwd ().realpathAlloc ( cw .wfs .step .owner .allocator , "." ) catch @panic ("oom" );
329+ const cwd = std .Io . Dir . cwd ().realPathFileAlloc ( io , "." , cw .wfs .step .owner .allocator ) catch @panic ("oom" );
328330 std .debug .print ("non-absolute path detected for {t}: cwd=\" {f}\" path=\" {f}\" \n " , .{
329331 path ,
330332 std .zig .fmtString (cwd ),
0 commit comments