build_c.zig (795B) - Raw
1 const std = @import("std"); 2 3 pub fn build(b: *std.Build) void { 4 const lib = b.addLibrary(.{ 5 .linkage = .dynamic, 6 .name = "mathtest", 7 .root_module = b.createModule(.{ 8 .root_source_file = b.path("mathtest.zig"), 9 }), 10 .version = .{ .major = 1, .minor = 0, .patch = 0 }, 11 }); 12 const exe = b.addExecutable(.{ 13 .name = "test", 14 .root_module = b.createModule(.{ 15 .link_libc = true, 16 }), 17 }); 18 exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} }); 19 exe.root_module.linkLibrary(lib); 20 21 b.default_step.dependOn(&exe.step); 22 23 const run_cmd = exe.run(); 24 25 const test_step = b.step("test", "Test the program"); 26 test_step.dependOn(&run_cmd.step); 27 } 28 29 // syntax