master
1const std = @import("std");
2
3pub 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.OptimizeMode = .Debug;
8 const target = b.graph.host;
9 const lib = b.addLibrary(.{
10 .linkage = .dynamic,
11 .name = "mathtest",
12 .version = .{ .major = 1, .minor = 0, .patch = 0 },
13 .root_module = b.createModule(.{
14 .root_source_file = b.path("mathtest.zig"),
15 .target = target,
16 .optimize = optimize,
17 }),
18 });
19
20 const exe = b.addExecutable(.{
21 .name = "test",
22 .root_module = b.createModule(.{
23 .root_source_file = null,
24 .target = target,
25 .optimize = optimize,
26 .link_libc = true,
27 }),
28 });
29 exe.root_module.addCSourceFile(.{
30 .file = b.path("test.c"),
31 .flags = &[_][]const u8{"-std=c99"},
32 });
33 exe.root_module.linkLibrary(lib);
34
35 const run_cmd = b.addRunArtifact(exe);
36 test_step.dependOn(&run_cmd.step);
37}