| ... | @@ -4,19 +4,20 @@ const deps = @import("./deps.zig"); | ... | @@ -4,19 +4,20 @@ const deps = @import("./deps.zig"); |
| 4 | pub fn build(b: *std.Build) void { | 4 | pub fn build(b: *std.Build) void { |
| 5 | const target = b.standardTargetOptions(.{}); | 5 | const target = b.standardTargetOptions(.{}); |
| 6 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; | 6 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; |
| | 7 | const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; |
| 7 | | 8 | |
| 8 | const mod = b.addModule("tracer", .{ .root_source_file = b.path("src/mod.zig") }); | 9 | const mod = b.addModule("tracer", .{ .root_source_file = b.path("src/mod.zig") }); |
| 9 | | 10 | |
| 10 | addTest(b, target, mode, mod, 0); | 11 | addTest(b, target, mode, disable_llvm, mod, 0); |
| 11 | addTest(b, target, mode, mod, 1); | 12 | addTest(b, target, mode, disable_llvm, mod, 1); |
| 12 | addTest(b, target, mode, mod, 2); | 13 | addTest(b, target, mode, disable_llvm, mod, 2); |
| 13 | addTest(b, target, mode, mod, 3); | 14 | addTest(b, target, mode, disable_llvm, mod, 3); |
| 14 | | 15 | |
| 15 | const test_step = b.step("test", "dummy test step to pass CI checks"); | 16 | const test_step = b.step("test", "dummy test step to pass CI checks"); |
| 16 | test_step.dependOn(b.default_step); | 17 | test_step.dependOn(b.default_step); |
| 17 | } | 18 | } |
| 18 | | 19 | |
| 19 | fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mode, mod: *std.Build.Module, comptime backend: u8) void { | 20 | fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mode, disable_llvm: bool, mod: *std.Build.Module, comptime backend: u8) void { |
| 20 | _ = mod; | 21 | _ = mod; |
| 21 | const options = b.addOptions(); | 22 | const options = b.addOptions(); |
| 22 | options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); | 23 | options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); |
| ... | @@ -31,5 +32,7 @@ fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mo | ... | @@ -31,5 +32,7 @@ fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mo |
| 31 | deps.addAllTo(exe); | 32 | deps.addAllTo(exe); |
| 32 | exe.linkLibC(); | 33 | exe.linkLibC(); |
| 33 | exe.root_module.addImport("build_options", options.createModule()); | 34 | exe.root_module.addImport("build_options", options.createModule()); |
| | 35 | exe.use_llvm = !disable_llvm; |
| | 36 | exe.use_lld = !disable_llvm; |
| 34 | b.installArtifact(exe); | 37 | b.installArtifact(exe); |
| 35 | } | 38 | } |