| ... | @@ -5,26 +5,75 @@ pub fn build(b: *std.Build) void { | ... | @@ -5,26 +5,75 @@ pub fn build(b: *std.Build) void { |
| 5 | b.default_step = test_step; | 5 | b.default_step = test_step; |
| 6 | | 6 | |
| 7 | const optimize: std.builtin.OptimizeMode = .Debug; | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| | 8 | const target = b.standardTargetOptions(.{}); |
| 8 | | 9 | |
| 9 | const foo = b.addLibrary(.{ | 10 | const exe_names: []const []const u8 = &.{ |
| 10 | .linkage = .static, | 11 | "test", |
| 11 | .name = "foo", | 12 | "test-dync", |
| 12 | .root_module = b.createModule(.{ | 13 | "test-no-llvm", |
| 13 | .root_source_file = null, | 14 | "test-no-llvm-dync", |
| 14 | .optimize = optimize, | 15 | "test-exe-no-llvm", |
| 15 | .target = b.graph.host, | 16 | "test-dync-exe-no-llvm", |
| 16 | }), | 17 | "test-no-llvm-exe-no-llvm", |
| 17 | }); | 18 | "test-no-llvm-dync-exe-no-llvm", |
| 18 | foo.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} }); | 19 | }; |
| 19 | foo.root_module.addIncludePath(b.path(".")); | 20 | const lib_names: []const []const u8 = &.{ |
| | 21 | "foo", |
| | 22 | "foo-dync", |
| | 23 | "foo-no-llvm", |
| | 24 | "foo-no-llvm-dync", |
| | 25 | "foo-exe-no-llvm", |
| | 26 | "foo-dync-exe-no-llvm", |
| | 27 | "foo-no-llvm-exe-no-llvm", |
| | 28 | "foo-no-llvm-dync-exe-no-llvm", |
| | 29 | }; |
| | 30 | const lib_link_libc: []const bool = &.{ false, true, false, true, false, true, false, true }; |
| | 31 | const lib_use_llvm: []const bool = &.{ true, true, false, false, true, true, false, false }; |
| | 32 | const exe_use_llvm: []const bool = &.{ true, true, true, true, false, false, false, false }; |
| 20 | | 33 | |
| 21 | const test_exe = b.addTest(.{ .root_module = b.createModule(.{ | 34 | for ( |
| 22 | .root_source_file = b.path("foo.zig"), | 35 | exe_names, |
| 23 | .target = b.graph.host, | 36 | lib_names, |
| 24 | .optimize = optimize, | 37 | lib_link_libc, |
| 25 | }) }); | 38 | lib_use_llvm, |
| 26 | test_exe.root_module.linkLibrary(foo); | 39 | exe_use_llvm, |
| 27 | test_exe.root_module.addIncludePath(b.path(".")); | 40 | ) |exe_name, lib_name, dyn_libc, lib_llvm, exe_llvm| { |
| | 41 | const use_llvm = lib_llvm or exe_llvm; |
| | 42 | if (!use_llvm and target.result.os.tag == .macos) continue; // TODO |
| | 43 | if (!use_llvm and target.result.os.tag == .freebsd) continue; // TODO |
| | 44 | if (!use_llvm and target.result.os.tag == .netbsd) continue; // TODO |
| | 45 | if (!use_llvm and target.result.os.tag == .openbsd) continue; // TODO |
| | 46 | if (!use_llvm and target.result.cpu.arch == .loongarch64) continue; // TODO |
| | 47 | if (!use_llvm and target.result.cpu.arch == .powerpc64le) continue; // TODO |
| | 48 | if (!use_llvm and target.result.cpu.arch == .s390x) continue; // TODO |
| 28 | | 49 | |
| 29 | test_step.dependOn(&b.addRunArtifact(test_exe).step); | 50 | const foo = b.addLibrary(.{ |
| | 51 | .linkage = .static, |
| | 52 | .name = lib_name, |
| | 53 | .root_module = b.createModule(.{ |
| | 54 | .root_source_file = null, |
| | 55 | .optimize = optimize, |
| | 56 | .target = target, |
| | 57 | .link_libc = dyn_libc, |
| | 58 | }), |
| | 59 | .use_llvm = lib_llvm, |
| | 60 | }); |
| | 61 | foo.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} }); |
| | 62 | foo.root_module.addIncludePath(b.path(".")); |
| | 63 | |
| | 64 | const test_exe = b.addTest(.{ |
| | 65 | .name = exe_name, |
| | 66 | .root_module = b.createModule(.{ |
| | 67 | .root_source_file = b.path("foo.zig"), |
| | 68 | .target = target, |
| | 69 | .optimize = optimize, |
| | 70 | .link_libc = dyn_libc, |
| | 71 | }), |
| | 72 | .use_llvm = exe_llvm, |
| | 73 | }); |
| | 74 | test_exe.root_module.linkLibrary(foo); |
| | 75 | test_exe.root_module.addIncludePath(b.path(".")); |
| | 76 | |
| | 77 | test_step.dependOn(&b.addRunArtifact(test_exe).step); |
| | 78 | } |
| 30 | } | 79 | } |