From b1d9eb63de7912becc886e96943ef38732d6f35d Mon Sep 17 00:00:00 2001 From: Malcolm Still Date: Sun, 16 Jun 2024 18:18:57 +0100 Subject: Enable features without vendoring --- build.zig | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index ed064a2..55b3950 100644 --- a/build.zig +++ b/build.zig @@ -115,7 +115,23 @@ pub fn build(b: *std.Build) !void { const target = b.resolveTargetQuery(query); const optimize = b.standardOptimizeOption(.{}); - const c_flags = &[_][]const u8{"-std=c99"}; + var flags = std.ArrayList([]const u8).init(b.allocator); + defer flags.deinit(); + try flags.append("-std=c99"); + + inline for (std.meta.fields(EnableOptions)) |field| { + const opt = b.option(bool, field.name, "Enable " ++ field.name) orelse @as(*const bool, @ptrCast(field.default_value.?)).*; + + if (opt) { + var buf: [field.name.len]u8 = undefined; + const name = std.ascii.upperString(&buf, field.name); + const flag = try std.fmt.allocPrint(b.allocator, "-DSQLITE_ENABLE_{s}", .{name}); + + try flags.append(flag); + } + } + + const c_flags = flags.items; const sqlite_lib = b.addStaticLibrary(.{ .name = "sqlite", @@ -317,3 +333,9 @@ pub fn build(b: *std.Build) !void { zigcrypto_compile_run.dependOn(&install_zigcrypto_loadable_ext.step); zigcrypto_compile_run.dependOn(&install_zigcrypto_test.step); } + +// See https://www.sqlite.org/compile.html for flags +const EnableOptions = struct { + // https://www.sqlite.org/fts5.html + fts5: bool = false, +}; -- cgit v1.2.3