1
1
const std = @import ("std" );
2
2
const builtin = @import ("builtin" );
3
3
4
- // This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
4
+ // This has been tested to work with zig 0.11.0 (67709b6, Aug 4 2023)
5
5
fn add_module (comptime module : []const u8 , b : * std.Build , target : std.zig.CrossTarget , optimize : std.builtin.OptimizeMode ) ! * std.Build.Step {
6
6
if (target .getOsTag () == .emscripten ) {
7
7
@panic ("Emscripten building via Zig unsupported" );
@@ -11,7 +11,7 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossT
11
11
const dir = try std .fs .cwd ().openIterableDir (module , .{});
12
12
var iter = dir .iterate ();
13
13
while (try iter .next ()) | entry | {
14
- if (entry .kind != .File ) continue ;
14
+ if (entry .kind != .file ) continue ;
15
15
const extension_idx = std .mem .lastIndexOf (u8 , entry .name , ".c" ) orelse continue ;
16
16
const name = entry .name [0.. extension_idx ];
17
17
const path = try std .fs .path .join (b .allocator , &.{ module , entry .name });
@@ -24,26 +24,26 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossT
24
24
.target = target ,
25
25
.optimize = optimize ,
26
26
});
27
- exe .addCSourceFile (path , &[ _ ][] const u8 { });
27
+ exe .addCSourceFile (.{ . file = .{ . path = path }, . flags = &.{} });
28
28
exe .linkLibC ();
29
29
exe .addObjectFile (switch (target .getOsTag ()) {
30
- .windows = > "../src/zig-out/lib/raylib.lib" ,
31
- .linux = > "../src/zig-out/lib/libraylib.a" ,
32
- .macos = > "../src/zig-out/lib/libraylib.a" ,
33
- .emscripten = > "../src/zig-out/lib/libraylib.a" ,
30
+ .windows = > .{ . path = "../src/zig-out/lib/raylib.lib" } ,
31
+ .linux = > .{ . path = "../src/zig-out/lib/libraylib.a" } ,
32
+ .macos = > .{ . path = "../src/zig-out/lib/libraylib.a" } ,
33
+ .emscripten = > .{ . path = "../src/zig-out/lib/libraylib.a" } ,
34
34
else = > @panic ("Unsupported OS" ),
35
35
});
36
36
37
- exe .addIncludePath ("../src" );
38
- exe .addIncludePath ("../src/external" );
39
- exe .addIncludePath ("../src/external/glfw/include" );
37
+ exe .addIncludePath (.{ . path = "../src" } );
38
+ exe .addIncludePath (.{ . path = "../src/external" } );
39
+ exe .addIncludePath (.{ . path = "../src/external/glfw/include" } );
40
40
41
41
switch (target .getOsTag ()) {
42
42
.windows = > {
43
43
exe .linkSystemLibrary ("winmm" );
44
44
exe .linkSystemLibrary ("gdi32" );
45
45
exe .linkSystemLibrary ("opengl32" );
46
- exe .addIncludePath ("external/glfw/deps/mingw" );
46
+ exe .addIncludePath (.{ . path = "external/glfw/deps/mingw" } );
47
47
48
48
exe .defineCMacro ("PLATFORM_DESKTOP" , null );
49
49
},
@@ -71,11 +71,15 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossT
71
71
},
72
72
}
73
73
74
- b .installArtifact (exe );
75
- var run = b .addRunArtifact (exe );
76
- run .cwd = module ;
77
- b .step (name , name ).dependOn (& run .step );
78
- all .dependOn (& exe .step );
74
+ const install_cmd = b .addInstallArtifact (exe , .{});
75
+
76
+ const run_cmd = b .addRunArtifact (exe );
77
+ run_cmd .step .dependOn (& install_cmd .step );
78
+
79
+ const run_step = b .step (name , name );
80
+ run_step .dependOn (& run_cmd .step );
81
+
82
+ all .dependOn (& install_cmd .step );
79
83
}
80
84
return all ;
81
85
}
0 commit comments