build.zig (1042B)
1 const std = @import("std"); 2 3 pub fn build(b: *std.Build) void { 4 const target = b.standardTargetOptions(.{}); 5 const optimize = b.standardOptimizeOption(.{}); 6 7 const exe = b.addExecutable(.{ 8 .name = "zbt", 9 .root_source_file = .{ .path = "src/main.zig" }, 10 .target = target, 11 .optimize = optimize, 12 }); 13 14 b.installArtifact(exe); 15 const run_cmd = b.addRunArtifact(exe); 16 run_cmd.step.dependOn(b.getInstallStep()); 17 18 if (b.args) |args| { 19 run_cmd.addArgs(args); 20 } 21 22 const run_step = b.step("run", "Run the app"); 23 run_step.dependOn(&run_cmd.step); 24 25 const unit_tests = b.addTest(.{ 26 .root_source_file = .{ .path = "src/main.zig" }, 27 .target = target, 28 .optimize = optimize, 29 }); 30 b.installArtifact(unit_tests); // Useful if you want to debug the test binary with lldb or something 31 32 const run_unit_tests = b.addRunArtifact(unit_tests); 33 const test_step = b.step("test", "Run unit tests"); 34 test_step.dependOn(&run_unit_tests.step); 35 }