@@ -24,7 +24,7 @@ fn addPackageCSourceFiles(exe: *std.Build.Step.Compile, dep: *std.Build.Dependen
2424fn patchFile (b : * std.Build , tool : * std.Build.Step.Compile , replacements : []const ReplacementPair , filePath : []const u8 , dependency : * std.Build.Step ) * std.Build.Step {
2525 var step = dependency ;
2626
27- for (replacements ) | pair | {
27+ for (replacements ) | pair | {
2828 const cmd = b .addRunArtifact (tool );
2929 cmd .addArgs (&.{pair .find , pair .replace });
3030 cmd .addFileArg (b .path (filePath ));
@@ -111,9 +111,9 @@ pub fn addVulkanApple(b: *std.Build, step: *std.Build.Step, c_lib: *std.Build.St
111111
112112 var allFlags : std .ArrayList ([]const u8 ) = .{};
113113 try allFlags .appendSlice (b .allocator , flags );
114- if (target .result .os .tag == .ios ) {
114+ if (target .result .os .tag == .ios ) {
115115 try allFlags .append (b .allocator , "-DVK_USE_PLATFORM_IOS_MVK" );
116- } else if (target .result .os .tag == .macos ) {
116+ } else if (target .result .os .tag == .macos ) {
117117 try allFlags .append (b .allocator , "-DVK_USE_PLATFORM_MACOS_MVK" );
118118 }
119119 try allFlags .appendSlice (b .allocator , &[_ ][]const u8 {
@@ -137,7 +137,7 @@ pub fn addVulkanApple(b: *std.Build, step: *std.Build.Step, c_lib: *std.Build.St
137137 });
138138
139139 // NOTE(blackedout): Add the MoltenVK binary and JSON manifest file into the cubyz_deps_* directory
140- if (target .result .os .tag == .macos ) {
140+ if (target .result .os .tag == .macos ) {
141141 const moltenVk = b .dependency ("MoltenVK-macos" , .{});
142142 const moltenVkLibPath = moltenVk .path ("MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib" );
143143 const moltenVkJsonPath = moltenVk .path ("MoltenVK/dynamic/dylib/macOS/MoltenVK_icd.json" );
@@ -386,7 +386,7 @@ pub fn makeVulkanLayers(b: *std.Build, parentStep: *std.Build.Step, name: []cons
386386
387387 var allFlags : std .ArrayList ([]const u8 ) = .{};
388388 try allFlags .appendSlice (b .allocator , flags );
389- switch (target .result .os .tag ) {
389+ switch (target .result .os .tag ) {
390390 .windows = > {
391391 try allFlags .append (b .allocator , "-DVK_USE_PLATFORM_WIN32_KHR" );
392392 },
@@ -457,7 +457,7 @@ pub fn addFreetypeAndHarfbuzz(b: *std.Build, c_lib: *std.Build.Step.Compile, tar
457457 c_lib .addIncludePath (freetype .path ("include" ));
458458 c_lib .installHeadersDirectory (freetype .path ("include" ), "" , .{});
459459 addPackageCSourceFiles (c_lib , freetype , & freetypeSources , flags );
460- if (target .result .os .tag == .macos ) c_lib .addCSourceFile (.{
460+ if (target .result .os .tag == .macos ) c_lib .addCSourceFile (.{
461461 .file = freetype .path ("src/base/ftmac.c" ),
462462 .flags = &.{},
463463 });
@@ -474,10 +474,10 @@ pub inline fn addGLFWSources(b: *std.Build, c_lib: *std.Build.Step.Compile, targ
474474 const root = glfw .path ("src" );
475475 const os = target .result .os .tag ;
476476
477- const WinSys = enum {win32 , x11 , cocoa };
477+ const WinSys = enum { win32 , x11 , cocoa };
478478
479479 // TODO: Wayland
480- const ws : WinSys = switch (os ) {
480+ const ws : WinSys = switch (os ) {
481481 .windows = > .win32 ,
482482 .linux = > .x11 ,
483483 .macos = > .cocoa ,
@@ -488,36 +488,36 @@ pub inline fn addGLFWSources(b: *std.Build, c_lib: *std.Build.Step.Compile, targ
488488 break :blk .x11 ;
489489 },
490490 };
491- const wsFlag = switch (ws ) {
491+ const wsFlag = switch (ws ) {
492492 .win32 = > "-D_GLFW_WIN32" ,
493493 .x11 = > "-D_GLFW_X11" ,
494494 .cocoa = > "-D_GLFW_COCOA" ,
495495 };
496496 var allFlags = try std .ArrayList ([]const u8 ).initCapacity (b .allocator , 0 );
497497 try allFlags .appendSlice (b .allocator , flags );
498498 try allFlags .append (b .allocator , wsFlag );
499- if (os == .linux ) {
499+ if (os == .linux ) {
500500 try allFlags .append (b .allocator , "-D_GNU_SOURCE" );
501501 }
502502
503503 c_lib .addIncludePath (glfw .path ("include" ));
504504 c_lib .installHeader (glfw .path ("include/GLFW/glfw3.h" ), "GLFW/glfw3.h" );
505505 const fileses : [3 ][]const []const u8 = .{
506506 &.{"context.c" , "init.c" , "input.c" , "monitor.c" , "platform.c" , "vulkan.c" , "window.c" , "egl_context.c" , "osmesa_context.c" , "null_init.c" , "null_monitor.c" , "null_window.c" , "null_joystick.c" },
507- switch (os ) {
507+ switch (os ) {
508508 .windows = > &.{"win32_module.c" , "win32_time.c" , "win32_thread.c" },
509509 .linux = > &.{"posix_module.c" , "posix_time.c" , "posix_thread.c" , "linux_joystick.c" },
510510 .macos = > &.{"cocoa_time.c" , "posix_module.c" , "posix_thread.c" },
511511 else = > &.{"posix_module.c" , "posix_time.c" , "posix_thread.c" , "linux_joystick.c" },
512512 },
513- switch (ws ) {
513+ switch (ws ) {
514514 .win32 = > &.{"win32_init.c" , "win32_joystick.c" , "win32_monitor.c" , "win32_window.c" , "wgl_context.c" },
515515 .x11 = > &.{"x11_init.c" , "x11_monitor.c" , "x11_window.c" , "xkb_unicode.c" , "glx_context.c" , "posix_poll.c" },
516516 .cocoa = > &.{"cocoa_init.m" , "cocoa_joystick.m" , "cocoa_monitor.m" , "cocoa_window.m" , "nsgl_context.m" },
517517 },
518518 };
519519
520- for (fileses ) | files | {
520+ for (fileses ) | files | {
521521 c_lib .addCSourceFiles (.{
522522 .root = root ,
523523 .files = files ,
@@ -563,7 +563,7 @@ pub inline fn makeCubyzLibs(b: *std.Build, step: *std.Build.Step, name: []const
563563 })});
564564
565565 // NOTE(blackedout): To cross compile on macOS to macOS, the SDK has to be set correctly
566- if (builtin .os .tag == .macos and target .result .os .tag == .macos ) {
566+ if (builtin .os .tag == .macos and target .result .os .tag == .macos ) {
567567 const sdkPathNewline = b .run (&.{"xcrun" , "-sdk" , "macosx" , "--show-sdk-path" });
568568 const sdkPath = sdkPathNewline [0.. (sdkPathNewline .len - 1 )];
569569 c_lib .root_module .addSystemFrameworkPath (.{.cwd_relative = b .fmt ("{s}/System/Library/Frameworks" , .{sdkPath })});
@@ -577,22 +577,22 @@ pub inline fn makeCubyzLibs(b: *std.Build, step: *std.Build.Step, name: []const
577577
578578 // NOTE(blackedout): glad for Vulkan is not needed on macOS since the loader is currently statically linked.
579579 // Whether or not glad can be used like Volk to bind the Vulkan functions directly to the driver, I don't know.
580- if (target .result .os .tag != .macos ) {
580+ if (target .result .os .tag != .macos ) {
581581 c_lib .installHeader (b .path ("include/glad/vulkan.h" ), "glad/vulkan.h" );
582582 c_lib .installHeader (b .path ("include/vk_platform.h" ), "vk_platform.h" );
583583 }
584584
585585 addHeaderOnlyLibs (b , c_lib , flags );
586586 addFreetypeAndHarfbuzz (b , c_lib , target , flags );
587587 addMiniaudioAndStbVorbis (b , c_lib , flags , replace_tool );
588- if (target .result .os .tag == .macos ) {
588+ if (target .result .os .tag == .macos ) {
589589 try addVulkanApple (b , step , c_lib , name , target , flags , replace_tool );
590590 }
591591 try addGLFWSources (b , c_lib , target , flags );
592592 c_lib .addCSourceFile (.{.file = b .path ("lib/gl.c" ), .flags = flags });
593593
594594 // NOTE(blackedout): See the above glad comment
595- if (target .result .os .tag != .macos ) {
595+ if (target .result .os .tag != .macos ) {
596596 c_lib .addCSourceFile (.{.file = b .path ("lib/vulkan.c" ), .flags = flags });
597597 }
598598
@@ -660,7 +660,7 @@ pub fn build(b: *std.Build) !void {
660660 }),
661661 });
662662
663- for (targets ) | target | {
663+ for (targets ) | target | {
664664 const t = b .resolveTargetQuery (target );
665665 const name = t .result .linuxTriple (b .allocator ) catch unreachable ;
666666 const subStep = b .step (name , b .fmt ("Build only {s}" , .{name }));
@@ -670,7 +670,7 @@ pub fn build(b: *std.Build) !void {
670670
671671 subStep .dependOn (& install .step );
672672
673- if (t .result .os .tag == .macos ) {
673+ if (t .result .os .tag == .macos ) {
674674 try makeVulkanLayers (b , subStep , deps , t , .ReleaseSmall , c_flags , replace_tool );
675675 }
676676
@@ -685,7 +685,7 @@ pub fn build(b: *std.Build) !void {
685685
686686 nativeStep .dependOn (& install .step );
687687
688- if (preferredTarget .result .os .tag == .macos ) {
688+ if (preferredTarget .result .os .tag == .macos ) {
689689 try makeVulkanLayers (b , nativeStep , deps , preferredTarget , preferredOptimize , c_flags , replace_tool );
690690 }
691691 }
0 commit comments