From 8f3619d4cfc35a525cf1c7e804d4f78961a07ea6 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sat, 13 Mar 2021 22:10:31 +0100 Subject: build: fix building _without_ the bundled source code --- build.zig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index a1af313..2d6a8dc 100644 --- a/build.zig +++ b/build.zig @@ -12,9 +12,9 @@ fn linkSqlite(b: *std.build.LibExeObjStep) void { } } -pub fn build(b: *std.build.Builder) void { - const target = blk: { - var tmp = b.standardTargetOptions(.{}); +fn getTarget(original_target: std.zig.CrossTarget, bundled: bool) std.zig.CrossTarget { + if (bundled) { + var tmp = original_target; if (tmp.isGnuLibC()) { const min_glibc_version = std.builtin.Version{ @@ -31,15 +31,20 @@ pub fn build(b: *std.build.Builder) void { } } - break :blk tmp; - }; + return tmp; + } - const mode = b.standardReleaseOptions(); + return original_target; +} +pub fn build(b: *std.build.Builder) void { const in_memory = b.option(bool, "in_memory", "Should the tests run with sqlite in memory (default true)") orelse true; const dbfile = b.option([]const u8, "dbfile", "Always use this database file instead of a temporary one"); const use_bundled = b.option(bool, "use_bundled", "Use the bundled sqlite3 source instead of linking the system library (default false)") orelse false; + const target = getTarget(b.standardTargetOptions(.{}), use_bundled); + const mode = b.standardReleaseOptions(); + // Build sqlite from source if asked if (use_bundled) { const lib = b.addStaticLibrary("sqlite", null); -- cgit v1.2.3