| ... | ... | @@ -6,32 +6,40 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | 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 | 9 | |
| 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); |
| 10 | const exe_names: []const []const u8 = &.{ "test", "test-dync" }; |
| 11 | const lib_names: []const []const u8 = &.{ "mathtest", "mathtest-dync" }; |
| 12 | const lib_link_libc: []const bool = &.{ false, true }; |
| 34 | 13 | |
| 35 | | const run_cmd = b.addRunArtifact(exe); |
| 36 | | test_step.dependOn(&run_cmd.step); |
| 14 | for (exe_names, lib_names, lib_link_libc) |exe_name, lib_name, dyn_libc| { |
| 15 | const lib = b.addLibrary(.{ |
| 16 | .linkage = .dynamic, |
| 17 | .name = lib_name, |
| 18 | .version = .{ .major = 1, .minor = 0, .patch = 0 }, |
| 19 | .root_module = b.createModule(.{ |
| 20 | .root_source_file = b.path("mathtest.zig"), |
| 21 | .target = target, |
| 22 | .optimize = optimize, |
| 23 | .link_libc = dyn_libc, |
| 24 | }), |
| 25 | }); |
| 26 | |
| 27 | const exe = b.addExecutable(.{ |
| 28 | .name = exe_name, |
| 29 | .root_module = b.createModule(.{ |
| 30 | .root_source_file = null, |
| 31 | .target = target, |
| 32 | .optimize = optimize, |
| 33 | .link_libc = true, |
| 34 | }), |
| 35 | }); |
| 36 | exe.root_module.addCSourceFile(.{ |
| 37 | .file = b.path("test.c"), |
| 38 | .flags = &[_][]const u8{"-std=c99"}, |
| 39 | }); |
| 40 | exe.root_module.linkLibrary(lib); |
| 41 | |
| 42 | const run_cmd = b.addRunArtifact(exe); |
| 43 | test_step.dependOn(&run_cmd.step); |
| 44 | } |
| 37 | 45 | } |