| 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); |
| 3 | |
| 4 | pub fn build(b: *std.Build) void { |
| 5 | const test_step = b.step("test", "Test it"); |
| 6 | b.default_step = test_step; |
| 7 | |
| 8 | const optimize: std.builtin.Optimize = .debug; |
| 9 | const target = b.graph.host; |
| 10 | |
| 11 | const exe = b.addExecutable(.{ |
| 12 | .name = "main", |
| 13 | .root_module = b.createModule(.{ |
| 14 | .root_source_file = b.path("main.zig"), |
| 15 | .optimize = optimize, |
| 16 | .target = target, |
| 17 | }), |
| 18 | }); |
| 19 | |
| 20 | const c_sources = [_][]const u8{ |
| 21 | "test.c", |
| 22 | }; |
| 23 | exe.root_module.addCSourceFiles(.{ .files = &c_sources }); |
| 24 | exe.root_module.link_libc = true; |
| 25 | |
| 26 | const run_cmd = b.addRunArtifact(exe); |
| 27 | run_cmd.expectExitCode(0); |
| 28 | run_cmd.skip_foreign_checks = true; |
| 29 | test_step.dependOn(&run_cmd.step); |
| 30 | } |