@@ -63,13 +63,13 @@ pub fn createDisk(dimmer: Interface, size: u64, content: Content) std.Build.Lazy
6363}
6464
6565fn renderContent (wfs : * std.Build.Step.WriteFile , allocator : std.mem.Allocator , content : Content ) struct { []const u8 , ContentWriter .VariableMap } {
66- var code : std . ArrayList ( u8 ) = .init (allocator );
66+ var code = std . Io . Writer . Allocating .init (allocator );
6767 defer code .deinit ();
6868
6969 var variables : ContentWriter.VariableMap = .init (allocator );
7070
7171 var cw : ContentWriter = .{
72- .code = code .writer () ,
72+ .code = & code .writer ,
7373 .wfs = wfs ,
7474 .vars = & variables ,
7575 };
@@ -99,7 +99,7 @@ const ContentWriter = struct {
9999 pub const VariableMap = std .StringArrayHashMap (struct { std .Build .LazyPath , ContentWriter .UsageHint });
100100
101101 wfs : * std.Build.Step.WriteFile ,
102- code : std .ArrayList ( u8 ) .Writer ,
102+ code : * std.Io .Writer ,
103103 vars : * VariableMap ,
104104
105105 fn render (cw : ContentWriter , content : Content ) ! void {
@@ -117,7 +117,7 @@ const ContentWriter = struct {
117117 },
118118
119119 .paste_file = > | data | {
120- try cw .code .print ("paste-file {}" , .{cw .fmtLazyPath (data , .file )});
120+ try cw .code .print ("paste-file {f }" , .{cw .fmtLazyPath (data , .file )});
121121 },
122122
123123 .mbr_part_table = > | data | {
@@ -176,7 +176,7 @@ const ContentWriter = struct {
176176 try cw .code .writeByte ('\n ' );
177177
178178 if (part .name ) | name | {
179- try cw .code .print (" name \" {}\" \n " , .{std .zig .fmtEscapes (name )});
179+ try cw .code .print (" name \" {f }\" \n " , .{std .zig .fmtString (name )});
180180 }
181181 if (part .offset ) | offset | {
182182 try cw .code .print (" offset {d}\n " , .{offset });
@@ -198,7 +198,7 @@ const ContentWriter = struct {
198198 @tagName (data .format ),
199199 });
200200 if (data .label ) | label | {
201- try cw .code .print (" label {}\n " , .{
201+ try cw .code .print (" label {f }\n " , .{
202202 fmtPath (label ),
203203 });
204204 }
@@ -213,29 +213,29 @@ const ContentWriter = struct {
213213 fn renderFileSystemTree (cw : ContentWriter , fs : FileSystem ) ! void {
214214 for (fs .items ) | item | {
215215 switch (item ) {
216- .empty_dir = > | dir | try cw .code .print ("mkdir {}\n " , .{
216+ .empty_dir = > | dir | try cw .code .print ("mkdir {f }\n " , .{
217217 fmtPath (dir ),
218218 }),
219219
220- .copy_dir = > | copy | try cw .code .print ("copy-dir {} {}\n " , .{
220+ .copy_dir = > | copy | try cw .code .print ("copy-dir {f } {f }\n " , .{
221221 fmtPath (copy .destination ),
222222 cw .fmtLazyPath (copy .source , .directory ),
223223 }),
224224
225- .copy_file = > | copy | try cw .code .print ("copy-file {} {}\n " , .{
225+ .copy_file = > | copy | try cw .code .print ("copy-file {f } {f }\n " , .{
226226 fmtPath (copy .destination ),
227227 cw .fmtLazyPath (copy .source , .file ),
228228 }),
229229
230- .include_script = > | script | try cw .code .print ("!include {}\n " , .{
230+ .include_script = > | script | try cw .code .print ("!include {f }\n " , .{
231231 cw .fmtLazyPath (script , .file ),
232232 }),
233233 }
234234 }
235235 }
236236
237- const PathFormatter = std .fmt .Formatter ( formatPath );
238- const LazyPathFormatter = std .fmt .Formatter ( formatLazyPath );
237+ const PathFormatter = std .fmt .Alt ([] const u8 , formatPath );
238+ const LazyPathFormatter = std .fmt .Alt ( struct { ContentWriter , std . Build . LazyPath , UsageHint }, formatLazyPath );
239239 const UsageHint = enum { file , directory };
240240
241241 fn fmtLazyPath (cw : ContentWriter , path : std.Build.LazyPath , hint : UsageHint ) LazyPathFormatter {
@@ -248,13 +248,9 @@ const ContentWriter = struct {
248248
249249 fn formatLazyPath (
250250 data : struct { ContentWriter , std .Build .LazyPath , UsageHint },
251- comptime fmt : []const u8 ,
252- options : std.fmt.FormatOptions ,
253- writer : anytype ,
254- ) ! void {
251+ writer : * std.Io.Writer ,
252+ ) error {WriteFailed }! void {
255253 const cw , const path , const hint = data ;
256- _ = fmt ;
257- _ = options ;
258254
259255 switch (path ) {
260256 .cwd_relative ,
@@ -267,7 +263,7 @@ const ContentWriter = struct {
267263
268264 std .debug .assert (std .fs .path .isAbsolute (full_path ));
269265
270- try writer .print ("{}" , .{
266+ try writer .print ("{f }" , .{
271267 fmtPath (full_path ),
272268 });
273269 },
@@ -278,7 +274,7 @@ const ContentWriter = struct {
278274 const var_id = cw .vars .count () + 1 ;
279275 const var_name = cw .wfs .step .owner .fmt ("PATH{}" , .{var_id });
280276
281- try cw .vars .put (var_name , .{ path , hint });
277+ cw .vars .put (var_name , .{ path , hint }) catch return error . WriteFailed ;
282278
283279 try writer .print ("${s}" , .{var_name });
284280 },
@@ -287,13 +283,8 @@ const ContentWriter = struct {
287283
288284 fn formatPath (
289285 path : []const u8 ,
290- comptime fmt : []const u8 ,
291- options : std.fmt.FormatOptions ,
292- writer : anytype ,
286+ writer : * std.Io.Writer ,
293287 ) ! void {
294- _ = fmt ;
295- _ = options ;
296-
297288 const is_safe_word = for (path ) | char | {
298289 switch (char ) {
299290 'A' ... 'Z' ,
@@ -318,7 +309,7 @@ const ContentWriter = struct {
318309 if (c == '\\ ' ) {
319310 try writer .writeAll ("/" );
320311 } else {
321- try writer .print ("{}" , .{std .zig .fmtEscapes (&[_ ]u8 {c })});
312+ try writer .print ("{f }" , .{std .zig .fmtString (&[_ ]u8 {c })});
322313 }
323314 }
324315
@@ -419,7 +410,7 @@ pub const FatFs = struct {
419410
420411pub const FileSystemBuilder = struct {
421412 b : * std.Build ,
422- list : std .ArrayListUnmanaged (FileSystem .Item ),
413+ list : std .ArrayList (FileSystem .Item ),
423414
424415 pub fn init (b : * std.Build ) FileSystemBuilder {
425416 return FileSystemBuilder {
0 commit comments