-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
47 lines (39 loc) · 1.74 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");
const OptimizeMode = std.builtin.OptimizeMode;
const ResolvedTarget = std.Build.ResolvedTarget;
fn add(b: *std.Build, target: ResolvedTarget, optimize: OptimizeMode, step_cmd: []const u8, description: []const u8, exe_name: []const u8, root_source_file: []const u8) *std.Build.Step.Compile {
const exe = b.addExecutable(.{
.name = exe_name,
.root_source_file = b.path(root_source_file),
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(step_cmd, description);
run_step.dependOn(&run_cmd.step);
return exe;
}
fn addTests(b: *std.Build) void {
const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const bannou_exe = add(b, target, optimize, "run", "Run chess engine", "bannou", "src/main.zig");
_ = add(b, target, optimize, "generate-psts", "Generate piece square tables", "generate_psts", "src/generate_psts.zig");
_ = add(b, target, optimize, "generate-zhash", "Generate Zobrist hash tables", "generate_zhash", "src/generate_zhash.zig");
addTests(b);
const bench_cmd = b.addRunArtifact(bannou_exe);
bench_cmd.addArg("bench");
const bench_cmd_step = b.step("bench", "Run chess engine internal benchmark");
bench_cmd_step.dependOn(&bench_cmd.step);
}