-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
88 lines (69 loc) · 2.9 KB
/
Copy pathbuild.zig
File metadata and controls
88 lines (69 loc) · 2.9 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const std = @import("std");
const zon = @import("build.zig.zon");
pub const version = std.SemanticVersion.parse(zon.version) catch @panic("Invalid version in build.zig.zon");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const utils_mod = b.createModule(.{
.root_source_file = b.path("src/utils/mod.zig"),
.target = target,
.optimize = optimize,
});
const cli_mod = b.createModule(.{
.root_source_file = b.path("src/cli/mod.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "utils", .module = utils_mod },
},
});
const modules_mod = b.createModule(.{
.root_source_file = b.path("src/modules/mod.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "utils", .module = utils_mod },
},
});
const zon_mod = b.createModule(.{
.root_source_file = b.path("build.zig.zon"),
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable(.{
.name = "systema",
.version = version,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "cli", .module = cli_mod },
.{ .name = "modules", .module = modules_mod },
.{ .name = "utils", .module = utils_mod },
.{ .name = "zon", .module = zon_mod },
},
}),
});
if (target.result.os.tag == .linux) {
exe.root_module.link_libc = true;
}
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const test_step = b.step("test", "Run tests");
const zig_exe = b.graph.zig_exe;
const test_utils = b.addSystemCommand(&.{ zig_exe, "test", "-Mroot=src/utils/mod.zig" });
test_step.dependOn(&test_utils.step);
const test_cli = b.addSystemCommand(&.{ zig_exe, "test", "--dep", "utils", "-Mroot=src/cli/mod.zig", "-Mutils=src/utils/mod.zig" });
test_step.dependOn(&test_cli.step);
const test_modules = b.addSystemCommand(&.{ zig_exe, "test", "--dep", "utils", "-Mroot=src/modules/mod.zig", "-Mutils=src/utils/mod.zig", "-lc" });
test_step.dependOn(&test_modules.step);
const test_main = b.addSystemCommand(&.{ zig_exe, "test", "--dep", "cli", "--dep", "modules", "--dep", "utils", "--dep", "zon", "-Mroot=src/main.zig", "-Mcli=src/cli/mod.zig", "-Mmodules=src/modules/mod.zig", "-Mutils=src/utils/mod.zig", "-Mzon=build.zig.zon", "-lc" });
test_step.dependOn(&test_main.step);
}