-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
49 lines (38 loc) · 1.69 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("zig-template", "src/main.zig");
const install = b.addInstallArtifact(exe);
{ // >>> EXE - BUILD ONLY >>>
exe.setTarget(target);
exe.setBuildMode(mode);
const install_step = b.getInstallStep();
install_step.dependOn(&install.step);
} // <<< EXE - BUILD ONLY <<<
{ // >>> EXE - BUILD AND RUN >>>
const run_cmd = exe.run();
run_cmd.step.dependOn(&install.step);
// Forward CLI arguments passed after "--".
if (b.args) |args| run_cmd.addArgs(args);
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
} // <<< EXE - BUILD AND RUN <<<
const test_exe = b.addTestExe("test", "src/main.zig");
const install_test = b.addInstallArtifact(test_exe);
{ // >>> TEST - BUILD ONLY >>>
test_exe.setTarget(target);
test_exe.setBuildMode(mode);
const install_test_step = b.step("build-test", "Build unit tests");
install_test_step.dependOn(&install_test.step);
} // <<< TEST - BUILD ONLY <<<
{ // >>> TEST - BUILD AND RUN >>>
const run_test_cmd = test_exe.run();
run_test_cmd.step.dependOn(&install_test.step);
// Test executables need the zig command/path as the first argument.
// Not passing it here because it's done implicitely.
// run_test_cmd.addArg("zig");
const run_test_step = b.step("test", "Run unit tests");
run_test_step.dependOn(&run_test_cmd.step);
} // <<< TEST - BUILD AND RUN <<<
}