forked from zig-gamedev/zig-gamedev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
47 lines (40 loc) · 1.16 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
const std = @import("std");
pub const Package = struct {
zpool: *std.Build.Module,
pub fn link(pkg: Package, exe: *std.Build.CompileStep) void {
exe.addModule("zpool", pkg.zpool);
}
};
pub fn package(
b: *std.Build,
_: std.zig.CrossTarget,
_: std.builtin.Mode,
_: struct {},
) Package {
const zpool = b.createModule(.{
.source_file = .{ .path = thisDir() ++ "/src/main.zig" },
});
return .{ .zpool = zpool };
}
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const test_step = b.step("test", "Run zpool tests");
test_step.dependOn(runTests(b, optimize, target));
}
pub fn runTests(
b: *std.Build,
optimize: std.builtin.Mode,
target: std.zig.CrossTarget,
) *std.Build.Step {
const tests = b.addTest(.{
.name = "zpool-tests",
.root_source_file = .{ .path = thisDir() ++ "/src/main.zig" },
.target = target,
.optimize = optimize,
});
return &b.addRunArtifact(tests).step;
}
inline fn thisDir() []const u8 {
return comptime std.fs.path.dirname(@src().file) orelse ".";
}