-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
51 lines (42 loc) · 1.57 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
50
51
const std = @import("std");
const utils = @import("utils").utils;
pub fn build(b: *std.Build) !void {
const opts = .{
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSafe }),
};
const exe = b.addExecutable(.{
.name = "nix-sigstop",
.root_source_file = b.path("src/main.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
addDependencyImports(b, &exe.root_module, opts);
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
{
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
run_step.dependOn(&run_cmd.step);
}
const test_step = b.step("test", "Run unit tests");
{
const exe_test = b.addTest(.{
.root_source_file = exe.root_module.root_source_file.?,
.target = opts.target,
.optimize = opts.optimize,
});
addDependencyImports(b, &exe_test.root_module, opts);
const run_exe_test = b.addRunArtifact(exe_test);
test_step.dependOn(&run_exe_test.step);
}
_ = utils.addCheckTls(b);
}
fn addDependencyImports(b: *std.Build, module: *std.Build.Module, opts: struct {
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
}) void {
module.addImport("utils", b.dependency("utils", opts).module("utils"));
module.addImport("known-folders", b.dependency("known-folders", opts).module("known-folders"));
}