aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-09-18 15:40:10 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-09-18 15:41:19 +0700
commitcfb42e206ff4b9f7dca9d0796b21792629eab902 (patch)
tree0c9550507da7a643da02b5bd3935ebf4508882dd
parentee7009ba1c6284b89f40f2306c0174452bee7a73 (diff)
downloadzeal-cfb42e206ff4b9f7dca9d0796b21792629eab902.tar.gz
Stop installing examples
-rw-r--r--build.zig36
1 files changed, 21 insertions, 15 deletions
diff --git a/build.zig b/build.zig
index 9dd9fa2..11c7deb 100644
--- a/build.zig
+++ b/build.zig
@@ -17,8 +17,25 @@
// along with zeal. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
+const Builder = std.build.Builder;
+const LibExeObjStep = std.build.LibExeObjStep;
+const Mode = std.builtin.Mode;
-pub fn build(b: *std.build.Builder) void {
+fn addExampleStep(comptime name: []const u8, description: []const u8,
+ b: *Builder, lib: *LibExeObjStep, mode: Mode) void {
+ const bin = b.addExecutable(name, "examples/" ++ name ++ ".zig");
+ bin.addPackagePath("zeal", "src/zeal.zig");
+ bin.linkLibrary(lib);
+ bin.setBuildMode(mode);
+
+ const cmd = bin.run();
+ cmd.step.dependOn(b.getInstallStep());
+ if (b.args) |args|
+ cmd.addArgs(args);
+ b.step(name, description).dependOn(&cmd.step);
+}
+
+pub fn build(b: *Builder) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
@@ -33,19 +50,8 @@ pub fn build(b: *std.build.Builder) void {
var main_tests = b.addTest("src/zeal.zig");
main_tests.linkLibrary(lib);
main_tests.setBuildMode(mode);
+ b.step("test", "Run library tests").dependOn(&main_tests.step);
- const test_step = b.step("test", "Run library tests");
- test_step.dependOn(&main_tests.step);
-
- const example_play = b.addExecutable("zeal-play", "examples/play.zig");
- example_play.addPackagePath("zeal", "src/zeal.zig");
- example_play.linkLibrary(lib);
- example_play.setBuildMode(mode);
- example_play.install();
-
- const example_hrtf = b.addExecutable("zeal-hrtf", "examples/hrtf.zig");
- example_hrtf.addPackagePath("zeal", "src/zeal.zig");
- example_hrtf.linkLibrary(lib);
- example_hrtf.setBuildMode(mode);
- example_hrtf.install();
+ addExampleStep("play", "Play audio", b, lib, mode);
+ addExampleStep("hrtf", "Play audio with HRTF", b, lib, mode);
}