1
1
const std = @import ("std" );
2
2
3
3
pub fn build (b : * std.build.Builder ) ! void {
4
- const mode = b .standardReleaseOptions ();
5
4
const target = b .standardTargetOptions (.{});
5
+ const optimize = b .standardOptimizeOption (.{});
6
6
7
- const lib = b .addStaticLibrary ("gintro" , "src/lib.zig" );
7
+ const lib = b .addStaticLibrary (.{ . name = "gintro" , . root_source_file = .{ . path = "src/lib.zig" }, . target = target , . optimize = optimize } );
8
8
lib .linkLibC ();
9
9
lib .linkSystemLibrary ("gobject-introspection-1.0" );
10
10
11
- const exe = b .addExecutable ("gintro" , "src/gintro.zig" );
12
- exe .setTarget (target );
11
+ const exe = b .addExecutable (.{
12
+ .name = "gintro" ,
13
+ .root_source_file = .{ .path = "src/gintro.zig" },
14
+ .target = target ,
15
+ .optimize = optimize ,
16
+ });
13
17
exe .linkLibrary (lib );
14
- exe .setBuildMode (mode );
15
- exe .install ();
18
+ b .installArtifact (exe );
16
19
17
- const run_cmd = exe . run ( );
20
+ const run_cmd = b . addRunArtifact ( exe );
18
21
run_cmd .step .dependOn (b .getInstallStep ());
19
22
if (b .args ) | args | {
20
23
run_cmd .addArgs (args );
@@ -23,9 +26,11 @@ pub fn build(b: *std.build.Builder) !void {
23
26
const run_step = b .step ("run" , "Run the app" );
24
27
run_step .dependOn (& run_cmd .step );
25
28
26
- var main_tests = b .addTest ("src/gintro.zig" );
27
- main_tests .setBuildMode (mode );
29
+ var main_tests = b .addTest (.{ .root_source_file = .{ .path = "src/test.zig" }, .optimize = optimize , .target = target });
30
+ main_tests .linkLibrary (lib );
31
+
32
+ const run_test = b .addRunArtifact (main_tests );
28
33
29
34
const test_step = b .step ("test" , "Run library tests" );
30
- test_step .dependOn (& main_tests .step );
35
+ test_step .dependOn (& run_test .step );
31
36
}
0 commit comments