| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub fn build(b: *std.Build) void { |
| 4 | const target = b.standardTargetOptions(.{}); |
| 5 | const mode = b.option(std.builtin.OptimizeMode, "mode", "") orelse .Debug; |
| 6 | const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; |
| 7 | |
| 8 | const mod = b.addModule("extras", .{ |
| 9 | .root_source_file = b.path("src/lib.zig"), |
| 10 | }); |
| 11 | |
| 12 | const tests = b.addTest(.{ |
| 13 | .root_module = b.createModule(.{ |
| 14 | .root_source_file = b.path("src/lib.zig"), |
| 15 | .target = target, |
| 16 | .optimize = mode, |
| 17 | }), |
| 18 | }); |
| 19 | tests.root_module.addImport("extras", mod); |
| 20 | tests.use_llvm = !disable_llvm; |
| 21 | tests.use_lld = !disable_llvm; |
| 22 | b.getInstallStep().dependOn(&tests.step); |
| 23 | |
| 24 | const test_step = b.step("test", "Run all library tests"); |
| 25 | const tests_run = b.addRunArtifact(tests); |
| 26 | tests_run.setCwd(b.path(".")); |
| 27 | tests_run.has_side_effects = true; |
| 28 | test_step.dependOn(&tests_run.step); |
| 29 | } |