@@ -176,8 +176,7 @@ pub fn build(b: *std.Build) !void {
176176
177177 const options = blk : {
178178 const options = b .addOptions ();
179- const out = options .contents .writer ();
180- try out .print (
179+ try options .contents .print (b .allocator ,
181180 \\// module = zine
182181 \\const std = @import("std");
183182 \\pub const tsan = {};
@@ -187,10 +186,10 @@ pub fn build(b: *std.Build) !void {
187186 \\
188187 , .{ tsan , highlight , version .string () });
189188
190- for (scopes ) | l | try out . print (
191- \\.{{.scope = .{s }, .level = .debug}},
192- , std .zig .fmtId (l ));
193- try out . writeAll ( "};" );
189+ for (scopes ) | l | try options . contents . print (b . allocator ,
190+ \\.{{.scope = .{f }, .level = .debug}},
191+ , .{ std .zig .fmtId (l )} );
192+ try options . contents . print ( b . allocator , "}};" , .{} );
194193 break :blk options .createModule ();
195194 };
196195
@@ -242,9 +241,11 @@ pub fn build(b: *std.Build) !void {
242241
243242 const shtml_docgen = b .addExecutable (.{
244243 .name = "shtml_docgen" ,
245- .root_source_file = b .path ("src/docgen.zig" ),
246- .target = target ,
247- .optimize = .Debug ,
244+ .root_module = b .createModule (.{
245+ .root_source_file = b .path ("src/docgen.zig" ),
246+ .target = target ,
247+ .optimize = .Debug ,
248+ }),
248249 });
249250 shtml_docgen .root_module .addImport ("zeit" , zeit );
250251 shtml_docgen .root_module .addImport ("ziggy" , ziggy );
@@ -270,24 +271,34 @@ pub fn build(b: *std.Build) !void {
270271 // setup the Zine standalone executable
271272 const zine_exe = b .addExecutable (.{
272273 .name = "zine" ,
273- .root_source_file = b .path ("src/main.zig" ),
274- .target = target ,
275- .optimize = optimize ,
276- .single_threaded = b .option (
277- bool ,
278- "single-threaded" ,
279- "build Zine in single-threaded mode" ,
280- ) orelse false ,
281-
282- .sanitize_thread = tsan ,
274+ .root_module = b .createModule (.{
275+ .root_source_file = b .path ("src/main.zig" ),
276+ .target = target ,
277+ .optimize = optimize ,
278+ .single_threaded = b .option (
279+ bool ,
280+ "single-threaded" ,
281+ "build Zine in single-threaded mode" ,
282+ ) orelse false ,
283+
284+ .sanitize_thread = tsan ,
285+ }),
283286 });
284287
285- if (target .result .os .tag == .macos ) {
286- const frameworks = b .lazyDependency ("frameworks" , .{}) orelse return ;
287- zine_exe .addIncludePath (frameworks .path ("include" ));
288- zine_exe .addFrameworkPath (frameworks .path ("Frameworks" ));
289- zine_exe .addLibraryPath (frameworks .path ("lib" ));
290- zine_exe .linkFramework ("CoreServices" );
288+ switch (target .result .os .tag ) {
289+ else = > @panic ("target must be added to build.zig" ),
290+ .linux = > {},
291+
292+ .windows = > {
293+ zine_exe .linkSystemLibrary ("ws2_32" );
294+ },
295+ .macos = > {
296+ const frameworks = b .lazyDependency ("frameworks" , .{}) orelse return ;
297+ zine_exe .addIncludePath (frameworks .path ("include" ));
298+ zine_exe .addFrameworkPath (frameworks .path ("Frameworks" ));
299+ zine_exe .addLibraryPath (frameworks .path ("lib" ));
300+ zine_exe .linkFramework ("CoreServices" );
301+ },
291302 }
292303
293304 // zine_exe.root_module.addImport("zine", zine);
@@ -325,9 +336,11 @@ fn setupSnapshotTesting(
325336
326337 const camera = b .addExecutable (.{
327338 .name = "camera" ,
328- .root_source_file = b .path ("build/camera.zig" ),
329- .target = target ,
330- .optimize = .ReleaseFast ,
339+ .root_module = b .createModule (.{
340+ .root_source_file = b .path ("build/camera.zig" ),
341+ .target = target ,
342+ .optimize = .ReleaseFast ,
343+ }),
331344 });
332345
333346 const diff = b .addSystemCommand (&.{
@@ -555,8 +568,7 @@ fn setupReleaseStep(
555568
556569 const options = blk : {
557570 const options = b .addOptions ();
558- const out = options .contents .writer ();
559- out .print (
571+ options .contents .print (b .allocator ,
560572 \\// module = zine
561573 \\const std = @import("std");
562574 \\pub const tsan = false;
@@ -570,9 +582,11 @@ fn setupReleaseStep(
570582
571583 const zine_exe_release = b .addExecutable (.{
572584 .name = "zine" ,
573- .root_source_file = b .path ("src/main.zig" ),
574- .target = target ,
575- .optimize = .ReleaseFast ,
585+ .root_module = b .createModule (.{
586+ .root_source_file = b .path ("src/main.zig" ),
587+ .target = target ,
588+ .optimize = .ReleaseFast ,
589+ }),
576590 });
577591
578592 zine_exe_release .root_module .addImport ("options" , options );
@@ -587,16 +601,23 @@ fn setupReleaseStep(
587601 zine_exe_release .root_module .addImport ("mime" , mime .module ("mime" ));
588602 zine_exe_release .root_module .addImport ("wuffs" , wuffs .module ("wuffs" ));
589603
590- if (target .result .os .tag == .macos ) {
591- if (b .lazyDependency ("frameworks" , .{
592- .target = target ,
593- .optimize = optimize ,
594- })) | frameworks | {
595- zine_exe_release .addIncludePath (frameworks .path ("include" ));
596- zine_exe_release .addFrameworkPath (frameworks .path ("Frameworks" ));
597- zine_exe_release .addLibraryPath (frameworks .path ("lib" ));
598- zine_exe_release .linkFramework ("CoreServices" );
599- }
604+ switch (target .result .os .tag ) {
605+ else = > @panic ("target must be added to build.zig" ),
606+ .linux = > {},
607+ .windows = > {
608+ zine_exe_release .linkSystemLibrary ("ws2_32" );
609+ },
610+ .macos = > {
611+ if (b .lazyDependency ("frameworks" , .{
612+ .target = target ,
613+ .optimize = optimize ,
614+ })) | frameworks | {
615+ zine_exe_release .addIncludePath (frameworks .path ("include" ));
616+ zine_exe_release .addFrameworkPath (frameworks .path ("Frameworks" ));
617+ zine_exe_release .addLibraryPath (frameworks .path ("lib" ));
618+ zine_exe_release .linkFramework ("CoreServices" );
619+ }
620+ },
600621 }
601622
602623 switch (t .os_tag .? ) {
0 commit comments