From d2ec7d68becdb48408c6e2a9e8b2d2b379cf6219 Mon Sep 17 00:00:00 2001 From: cozis Date: Sat, 23 May 2026 17:28:28 +0200 Subject: [PATCH] build: Add "zig build examples" command to build all examples --- build.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 6ac3422..538156e 100644 --- a/build.zig +++ b/build.zig @@ -10,6 +10,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + const examples_step = b.step("examples", "Build all examples"); + const exe = b.addExecutable(.{ .name = "example", .root_module = b.createModule(.{ @@ -19,7 +21,8 @@ pub fn build(b: *std.Build) void { }), }); exe.root_module.addImport("zigmulator", zigmulator); - b.installArtifact(exe); + const install_exe = b.addInstallArtifact(exe, .{}); + examples_step.dependOn(&install_exe.step); const run_cmd = b.addRunArtifact(exe); if (b.args) |args| { @@ -28,4 +31,16 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "Run the example"); run_step.dependOn(&run_cmd.step); + + const open_file_exe = b.addExecutable(.{ + .name = "open_file", + .root_module = b.createModule(.{ + .root_source_file = b.path("examples/open_file.zig"), + .target = target, + .optimize = optimize, + }), + }); + open_file_exe.root_module.addImport("zigmulator", zigmulator); + const install_open_file_exe = b.addInstallArtifact(open_file_exe, .{}); + examples_step.dependOn(&install_open_file_exe.step); }