| ... | @@ -1,10 +1,11 @@ | ... | @@ -1,10 +1,11 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| | 2 | const deps = @import("./deps.zig"); |
| 2 | | 3 | |
| 3 | pub fn build(b: *std.Build) void { | 4 | pub fn build(b: *std.Build) void { |
| 4 | const target = b.standardTargetOptions(.{}); | 5 | const target = b.standardTargetOptions(.{}); |
| 5 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; | 6 | const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; |
| 6 | | 7 | |
| 7 | const mod = b.addModule("tracer", .{ .source_file = .{ .path = "src/mod.zig" } }); | 8 | const mod = b.addModule("tracer", .{ .root_source_file = b.path("src/mod.zig") }); |
| 8 | | 9 | |
| 9 | addTest(b, target, mode, mod, 0); | 10 | addTest(b, target, mode, mod, 0); |
| 10 | addTest(b, target, mode, mod, 1); | 11 | addTest(b, target, mode, mod, 1); |
| ... | @@ -12,22 +13,23 @@ pub fn build(b: *std.Build) void { | ... | @@ -12,22 +13,23 @@ pub fn build(b: *std.Build) void { |
| 12 | addTest(b, target, mode, mod, 3); | 13 | addTest(b, target, mode, mod, 3); |
| 13 | | 14 | |
| 14 | const test_step = b.step("test", "dummy test step to pass CI checks"); | 15 | const test_step = b.step("test", "dummy test step to pass CI checks"); |
| 15 | _ = test_step; | 16 | test_step.dependOn(b.default_step); |
| 16 | } | 17 | } |
| 17 | | 18 | |
| 18 | fn addTest(b: *std.Build, target: std.zig.CrossTarget, mode: std.builtin.Mode, mod: *std.build.Module, comptime backend: u8) void { | 19 | fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mode, mod: *std.Build.Module, comptime backend: u8) void { |
| | 20 | _ = mod; |
| 19 | const options = b.addOptions(); | 21 | const options = b.addOptions(); |
| 20 | options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); | 22 | options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); |
| 21 | options.addOption(u8, "backend", backend); | 23 | options.addOption(u8, "backend", backend); |
| 22 | | 24 | |
| 23 | const exe = b.addExecutable(.{ | 25 | const exe = b.addExecutable(.{ |
| 24 | .name = "test" ++ std.fmt.comptimePrint("{d}", .{backend}), | 26 | .name = "test" ++ std.fmt.comptimePrint("{d}", .{backend}), |
| 25 | .root_source_file = .{ .path = "src/main.zig" }, | 27 | .root_source_file = b.path("src/main.zig"), |
| 26 | .target = target, | 28 | .target = target, |
| 27 | .optimize = mode, | 29 | .optimize = mode, |
| 28 | }); | 30 | }); |
| | 31 | deps.addAllTo(exe); |
| 29 | exe.linkLibC(); | 32 | exe.linkLibC(); |
| 30 | exe.addModule("tracer", mod); | 33 | exe.root_module.addImport("build_options", options.createModule()); |
| 31 | exe.addOptions("build_options", options); | | |
| 32 | b.installArtifact(exe); | 34 | b.installArtifact(exe); |
| 33 | } | 35 | } |