diff options
| -rw-r--r-- | build.zig | 16 |
1 files changed, 8 insertions, 8 deletions
| @@ -40,7 +40,6 @@ fn getTarget(original_target: std.zig.CrossTarget, bundled: bool) std.zig.CrossT | |||
| 40 | 40 | ||
| 41 | const TestTarget = struct { | 41 | const TestTarget = struct { |
| 42 | target: std.zig.CrossTarget = @as(std.zig.CrossTarget, .{}), | 42 | target: std.zig.CrossTarget = @as(std.zig.CrossTarget, .{}), |
| 43 | mode: std.builtin.Mode = .Debug, | ||
| 44 | single_threaded: bool = false, | 43 | single_threaded: bool = false, |
| 45 | bundled: bool, | 44 | bundled: bool, |
| 46 | }; | 45 | }; |
| @@ -183,6 +182,7 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 183 | const use_bundled = b.option(bool, "use_bundled", "Use the bundled sqlite3 source instead of linking the system library (default false)"); | 182 | const use_bundled = b.option(bool, "use_bundled", "Use the bundled sqlite3 source instead of linking the system library (default false)"); |
| 184 | 183 | ||
| 185 | const target = b.standardTargetOptions(.{}); | 184 | const target = b.standardTargetOptions(.{}); |
| 185 | const mode = b.standardReleaseOptions(); | ||
| 186 | 186 | ||
| 187 | // If the target is native we assume the user didn't change it with -Dtarget and run all test targets. | 187 | // If the target is native we assume the user didn't change it with -Dtarget and run all test targets. |
| 188 | // Otherwise we run a single test target. | 188 | // Otherwise we run a single test target. |
| @@ -212,7 +212,7 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 212 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); | 212 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); |
| 213 | lib.linkLibC(); | 213 | lib.linkLibC(); |
| 214 | lib.setTarget(cross_target); | 214 | lib.setTarget(cross_target); |
| 215 | lib.setBuildMode(test_target.mode); | 215 | lib.setBuildMode(mode); |
| 216 | sqlite3 = lib; | 216 | sqlite3 = lib; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| @@ -220,16 +220,16 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 220 | if (bundled) lib.addIncludeDir("c"); | 220 | if (bundled) lib.addIncludeDir("c"); |
| 221 | linkSqlite(lib); | 221 | linkSqlite(lib); |
| 222 | lib.setTarget(cross_target); | 222 | lib.setTarget(cross_target); |
| 223 | lib.setBuildMode(test_target.mode); | 223 | lib.setBuildMode(mode); |
| 224 | 224 | ||
| 225 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; | 225 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; |
| 226 | tests.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{ | 226 | tests.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{ |
| 227 | cross_target.zigTriple(b.allocator), | 227 | cross_target.zigTriple(b.allocator), |
| 228 | @tagName(test_target.mode), | 228 | @tagName(mode), |
| 229 | single_threaded_txt, | 229 | single_threaded_txt, |
| 230 | })); | 230 | })); |
| 231 | tests.single_threaded = test_target.single_threaded; | 231 | tests.single_threaded = test_target.single_threaded; |
| 232 | tests.setBuildMode(test_target.mode); | 232 | tests.setBuildMode(mode); |
| 233 | tests.setTarget(cross_target); | 233 | tests.setTarget(cross_target); |
| 234 | if (bundled) tests.addIncludeDir("c"); | 234 | if (bundled) tests.addIncludeDir("c"); |
| 235 | linkSqlite(tests); | 235 | linkSqlite(tests); |
| @@ -248,13 +248,13 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 248 | const lib = b.addStaticLibrary("sqlite", null); | 248 | const lib = b.addStaticLibrary("sqlite", null); |
| 249 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); | 249 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); |
| 250 | lib.linkLibC(); | 250 | lib.linkLibC(); |
| 251 | lib.setBuildMode(.Debug); | 251 | lib.setBuildMode(mode); |
| 252 | lib.setTarget(getTarget(target, true)); | 252 | lib.setTarget(getTarget(target, true)); |
| 253 | 253 | ||
| 254 | // The library | 254 | // The library |
| 255 | const fuzz_lib = b.addStaticLibrary("fuzz-lib", "fuzz/main.zig"); | 255 | const fuzz_lib = b.addStaticLibrary("fuzz-lib", "fuzz/main.zig"); |
| 256 | fuzz_lib.addIncludeDir("c"); | 256 | fuzz_lib.addIncludeDir("c"); |
| 257 | fuzz_lib.setBuildMode(.Debug); | 257 | fuzz_lib.setBuildMode(mode); |
| 258 | fuzz_lib.setTarget(getTarget(target, true)); | 258 | fuzz_lib.setTarget(getTarget(target, true)); |
| 259 | fuzz_lib.linkLibrary(lib); | 259 | fuzz_lib.linkLibrary(lib); |
| 260 | fuzz_lib.want_lto = true; | 260 | fuzz_lib.want_lto = true; |
| @@ -282,7 +282,7 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 282 | // Compile a companion exe for debugging crashes | 282 | // Compile a companion exe for debugging crashes |
| 283 | const fuzz_debug_exe = b.addExecutable("fuzz-debug", "fuzz/main.zig"); | 283 | const fuzz_debug_exe = b.addExecutable("fuzz-debug", "fuzz/main.zig"); |
| 284 | fuzz_debug_exe.addIncludeDir("c"); | 284 | fuzz_debug_exe.addIncludeDir("c"); |
| 285 | fuzz_debug_exe.setBuildMode(.Debug); | 285 | fuzz_debug_exe.setBuildMode(mode); |
| 286 | fuzz_debug_exe.setTarget(getTarget(target, true)); | 286 | fuzz_debug_exe.setTarget(getTarget(target, true)); |
| 287 | fuzz_debug_exe.linkLibrary(lib); | 287 | fuzz_debug_exe.linkLibrary(lib); |
| 288 | fuzz_debug_exe.addPackagePath("sqlite", "sqlite.zig"); | 288 | fuzz_debug_exe.addPackagePath("sqlite", "sqlite.zig"); |