forked from zig-gamedev/zig-gamedev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
60 lines (50 loc) · 2.01 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
const std = @import("std");
const demo_name = "audio_experiments_wgpu";
const content_dir = demo_name ++ "_content/";
pub fn build(b: *std.Build, options: anytype) *std.Build.Step.Compile {
const cwd_path = b.pathJoin(&.{ "samples", demo_name });
const src_path = b.pathJoin(&.{ cwd_path, "src" });
const exe = b.addExecutable(.{
.name = demo_name,
.root_source_file = b.path(b.pathJoin(&.{ src_path, demo_name ++ ".zig" })),
.target = options.target,
.optimize = options.optimize,
});
const zglfw = b.dependency("zglfw", .{
.target = options.target,
});
exe.root_module.addImport("zglfw", zglfw.module("root"));
exe.linkLibrary(zglfw.artifact("glfw"));
@import("zgpu").addLibraryPathsTo(exe);
const zgpu = b.dependency("zgpu", .{
.target = options.target,
});
exe.root_module.addImport("zgpu", zgpu.module("root"));
exe.linkLibrary(zgpu.artifact("zdawn"));
const zgui = b.dependency("zgui", .{
.target = options.target,
.backend = .glfw_wgpu,
});
exe.root_module.addImport("zgui", zgui.module("root"));
exe.linkLibrary(zgui.artifact("imgui"));
const zmath = b.dependency("zmath", .{
.target = options.target,
});
exe.root_module.addImport("zmath", zmath.module("root"));
const zaudio = b.dependency("zaudio", .{
.target = options.target,
});
exe.root_module.addImport("zaudio", zaudio.module("root"));
exe.linkLibrary(zaudio.artifact("miniaudio"));
const exe_options = b.addOptions();
exe.root_module.addOptions("build_options", exe_options);
exe_options.addOption([]const u8, "content_dir", content_dir);
const content_path = b.pathJoin(&.{ cwd_path, content_dir });
const install_content_step = b.addInstallDirectory(.{
.source_dir = b.path(content_path),
.install_dir = .{ .custom = "" },
.install_subdir = b.pathJoin(&.{ "bin", content_dir }),
});
exe.step.dependOn(&install_content_step.step);
return exe;
}