-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
55 lines (47 loc) · 1.67 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
const std = @import("std");
const fs = std.fs;
const Builder = std.build.Builder;
const sep_str = std.fs.path.sep_str;
const Cpu = std.Target.Cpu;
const Pkg = std.build.Pkg;
const gamekit = @import("./zig-gamekit/build.zig");
const GAMEKIT_PREFIX = "./zig-gamekit/";
const UTIL = std.build.Pkg{
.name = "util",
.path = "./util/util.zig",
};
const CORE = std.build.Pkg{
.name = "core",
.path = "./core/core.zig",
.dependencies = &[_]Pkg{UTIL},
};
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const native = b.addExecutable("hex-chess", "src/main.zig");
native.addPackage(UTIL);
native.addPackage(CORE);
gamekit.addGameKitToArtifact(b, native, target, GAMEKIT_PREFIX);
native.setTarget(target);
native.setBuildMode(mode);
native.install();
b.step("native", "Build native binary").dependOn(&native.step);
// Server
const server = b.addExecutable("hex-chess-server", "server/server.zig");
server.addPackage(CORE);
server.setTarget(target);
server.setBuildMode(mode);
server.install();
b.step("server", "Build server binary").dependOn(&server.step);
const test_server = b.addTest("server/server.zig");
const test_core = b.addTest("core/core.zig");
test_core.addPackage(UTIL);
b.step("run", "Run the native binary").dependOn(&native.run().step);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&test_server.step);
test_step.dependOn(&test_core.step);
const all = b.step("all", "Build all binaries");
all.dependOn(&native.step);
all.dependOn(&server.step);
all.dependOn(test_step);
}