summary refs log tree commit diff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig25
1 files changed, 13 insertions, 12 deletions
diff --git a/build.zig b/build.zig
index 11b8baf..46a93d2 100644
--- a/build.zig
+++ b/build.zig
@@ -22,11 +22,16 @@ const Builder = std.build.Builder;
 
 const data = InstallDirectoryOptions{
     .source_dir = "data",
-    .install_dir = .{ .Custom = "share" }, // break in future Zig
+    .install_dir = .{ .custom = "share" },
     .install_subdir = "blackshades",
 };
 
 pub fn build(b: *Builder) void {
+    b.installDirectory(data);
+    const options = b.addOptions();
+    const data_dir = b.getInstallPath(data.install_dir, data.install_subdir);
+    options.addOption([]const u8, "data_dir", data_dir);
+
     const exe = b.addExecutable("blackshades", "src/main.zig");
     exe.addIncludeDir("src");
 
@@ -48,13 +53,12 @@ pub fn build(b: *Builder) void {
 
     exe.addCSourceFile("lib/lodepng/lodepng.c", &.{ "-ansi", "-pedantic" });
     exe.addIncludeDir("lib/lodepng");
-    exe.addPackage(.{ .name = "gfz", .path = "lib/gfz/src/gfz.zig" });
-    exe.linkSystemLibrary("glfw");
-    exe.addPackage(.{ .name = "ini", .path = "lib/ini/src/ini.zig" });
-    exe.addPackage(.{ .name = "loca", .path = "lib/loca/src/main.zig" });
-    exe.addPackage(.{ .name = "zeal", .path = "lib/zeal/src/zeal.zig" });
-    exe.linkSystemLibrary("openal");
-    exe.linkSystemLibrary("sndfile");
+    exe.addPackagePath("gfz", "lib/gfz/src/gfz.zig");
+    @import("lib/gfz/build.zig").link(exe);
+    exe.addPackagePath("ini", "lib/ini/src/ini.zig");
+    exe.addPackagePath("loca", "lib/loca/src/main.zig");
+    exe.addPackagePath("zeal", "lib/zeal/src/zeal.zig");
+    @import("lib/zeal/build.zig").link(exe);
 
     exe.linkSystemLibrary("GL");
     exe.linkSystemLibrary("GLU");
@@ -69,10 +73,7 @@ pub fn build(b: *Builder) void {
     // Standard release options allow the person running `zig build` to select
     // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
     exe.setBuildMode(b.standardReleaseOptions());
-
-    const data_dir = b.getInstallPath(data.install_dir, data.install_subdir);
-    exe.addBuildOption([]const u8, "data_dir", data_dir);
-    b.installDirectory(data);
+    exe.addOptions("build_options", options);
     exe.install();
 
     const run_cmd = exe.run();