-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
64 lines (53 loc) · 2.06 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
52
53
54
55
56
57
58
59
60
61
62
63
64
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void
{
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const zbench_module = b.dependency("zbench", .{ .target = target, .optimize = optimize }).module("zbench");
const lib = b.addStaticLibrary(
.{
.name = "kiff_math",
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(lib);
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
try setup_benchmark(b, target, optimize, zbench_module);
const test_check = b.addTest(.{
.name = "kiff-engine",
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
});
test_check.root_module.addImport("zbench", zbench_module);
b.installArtifact(test_check);
// These two lines you might want to copy
// (make sure to rename 'exe_check')
const check = b.step("check", "Test Check");
check.dependOn(&test_check.step);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
}
fn setup_benchmark(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, mod: *std.Build.Module ) !void
{
const benchmark = b.addExecutable(.{
.name = "benchmark",
.root_source_file = b.path("src/benchmark.zig"),
.target = target,
.optimize = optimize,
});
benchmark.root_module.addImport("zbench", mod);
b.installArtifact(benchmark);
const run_benchmark = b.addRunArtifact(benchmark);
const benchmark_step = b.step("benchmark", "Run benchmarks");
benchmark_step.dependOn(&run_benchmark.step);
}