-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
87 lines (74 loc) · 2.72 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "podpad",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
linkGraphicsDeps(exe, b);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
}
// This is stolen from DVUI, not sure how much of it is necessary
// https://github.com/david-vanderson/dvui/blob/master/build.zig#L112
fn linkGraphicsDeps(exe: *std.Build.Step.Compile, b: *std.Build) void {
// Link against the FreeType library.
const freetype_dep = b.dependency("freetype", .{
.target = exe.target,
.optimize = exe.optimize,
});
exe.linkLibrary(freetype_dep.artifact("freetype"));
// Link against the C standard library.
exe.linkLibC();
if (exe.target.isWindows()) {
const sdl_dep = b.dependency("sdl", .{
.target = exe.target,
.optimize = exe.optimize,
});
exe.linkLibrary(sdl_dep.artifact("SDL2"));
exe.linkSystemLibrary("setupapi");
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("imm32");
exe.linkSystemLibrary("version");
exe.linkSystemLibrary("oleaut32");
exe.linkSystemLibrary("ole32");
} else {
if (exe.target.isDarwin()) {
exe.linkSystemLibrary("z");
exe.linkSystemLibrary("bz2");
exe.linkSystemLibrary("iconv");
exe.linkFramework("AppKit");
exe.linkFramework("AudioToolbox");
exe.linkFramework("Carbon");
exe.linkFramework("Cocoa");
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreFoundation");
exe.linkFramework("CoreGraphics");
exe.linkFramework("CoreHaptics");
exe.linkFramework("CoreVideo");
exe.linkFramework("ForceFeedback");
exe.linkFramework("GameController");
exe.linkFramework("IOKit");
exe.linkFramework("Metal");
}
exe.linkSystemLibrary("SDL2");
}
}