| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub fn build(b: *std.Build) void { |
| 4 | const test_step = b.step("test", "Test it"); |
| 5 | b.default_step = test_step; |
| 6 | |
| 7 | const optimize: std.builtin.Optimize = .debug; |
| 8 | const target = b.graph.host; |
| 9 | |
| 10 | const obj = b.addObject(.{ |
| 11 | .name = "base64", |
| 12 | .root_module = b.createModule(.{ |
| 13 | .root_source_file = b.path("base64.zig"), |
| 14 | .optimize = optimize, |
| 15 | .target = target, |
| 16 | }), |
| 17 | }); |
| 18 | |
| 19 | const exe = b.addExecutable(.{ |
| 20 | .name = "test", |
| 21 | .root_module = b.createModule(.{ |
| 22 | .root_source_file = null, |
| 23 | .optimize = optimize, |
| 24 | .target = target, |
| 25 | .link_libc = true, |
| 26 | }), |
| 27 | }); |
| 28 | exe.root_module.addCSourceFile(.{ |
| 29 | .file = b.path("test.c"), |
| 30 | .flags = &[_][]const u8{"-std=c99"}, |
| 31 | }); |
| 32 | exe.root_module.addObject(obj); |
| 33 | |
| 34 | b.default_step.dependOn(&exe.step); |
| 35 | |
| 36 | const run_cmd = b.addRunArtifact(exe); |
| 37 | test_step.dependOn(&run_cmd.step); |
| 38 | } |