-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
46 lines (40 loc) · 1.71 KB
/
build.zig
File metadata and controls
46 lines (40 loc) · 1.71 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Library module
const physics_mod = b.addModule("zig-physics", .{
.root_source_file = b.path("src/root.zig"),
});
// Export individual modules
const modules = [_]struct { name: []const u8, path: []const u8 }{
.{ .name = "quantum", .path = "src/quantum/root.zig" },
.{ .name = "gravity", .path = "src/gravity/root.zig" },
.{ .name = "qcd", .path = "src/qcd/root.zig" },
.{ .name = "dark_matter", .path = "src/dark_matter/root.zig" },
.{ .name = "particle_physics", .path = "src/particle_physics/root.zig" },
.{ .name = "plasma", .path = "src/plasma/root.zig" },
.{ .name = "baryogenesis", .path = "src/baryogenesis/root.zig" },
.{ .name = "monopoles", .path = "src/monopoles/root.zig" },
.{ .name = "quantum_gravity", .path = "src/quantum_gravity/root.zig" },
};
inline for (modules) |m| {
if (std.fs.path.join(b.allocator, &.{b.build_root_path.path, m.path})) |full_path| {
defer b.allocator.free(full_path);
if (std.fs.accessAbsolute(full_path, .{})) |_| {
const mod = b.addModule(m.name, .{
.root_source_file = b.path(m.path),
});
} else |_| {}
} else |_| {}
}
// Tests
const tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&b.addRunArtifact(tests).step);
}