From e1192877c32491ffbc1e4a3dc19d6d5b3cc06ba4 Mon Sep 17 00:00:00 2001 From: iddev5 Date: Sat, 30 Apr 2022 12:36:59 +0530 Subject: [PATCH] build: compile examples and applications on demand Without this change, anytime a dependency is modified, all the examples and applications are rebuilt before tring to run any of them. The problem with this approach is that it leads to long compile times which will keep on increasing as more and more examples are added. --- build.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 15774e04..43bc14c2 100644 --- a/build.zig +++ b/build.zig @@ -54,7 +54,7 @@ pub fn build(b: *std.build.Builder) void { example_exe.install(); const example_run_cmd = example_exe.run(); - example_run_cmd.step.dependOn(b.getInstallStep()); + example_run_cmd.step.dependOn(&example_exe.install_step.?.step); const example_run_step = b.step("run-example-" ++ example.name, "Run the example"); example_run_step.dependOn(&example_run_cmd.step); } @@ -74,9 +74,12 @@ pub fn build(b: *std.build.Builder) void { shaderexp_exe.install(); const shaderexp_run_cmd = shaderexp_exe.run(); - shaderexp_run_cmd.step.dependOn(b.getInstallStep()); + shaderexp_run_cmd.step.dependOn(&shaderexp_exe.install_step.?.step); const shaderexp_run_step = b.step("run-shaderexp", "Run shaderexp"); shaderexp_run_step.dependOn(&shaderexp_run_cmd.step); + + const compile_all = b.step("compile-all", "Compile all examples and applications"); + compile_all.dependOn(b.getInstallStep()); } pub const Options = struct {