diff options
| author | 2024-06-16 18:18:57 +0100 | |
|---|---|---|
| committer | 2024-06-17 20:11:18 +0100 | |
| commit | b1d9eb63de7912becc886e96943ef38732d6f35d (patch) | |
| tree | 9e2c7029d69dbbc4c1f5a2ce6890a3a9c1874111 /build.zig | |
| parent | update gitignore (diff) | |
| download | zig-sqlite-b1d9eb63de7912becc886e96943ef38732d6f35d.tar.gz zig-sqlite-b1d9eb63de7912becc886e96943ef38732d6f35d.tar.xz zig-sqlite-b1d9eb63de7912becc886e96943ef38732d6f35d.zip | |
Enable features without vendoring
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 24 |
1 files changed, 23 insertions, 1 deletions
| @@ -115,7 +115,23 @@ pub fn build(b: *std.Build) !void { | |||
| 115 | const target = b.resolveTargetQuery(query); | 115 | const target = b.resolveTargetQuery(query); |
| 116 | const optimize = b.standardOptimizeOption(.{}); | 116 | const optimize = b.standardOptimizeOption(.{}); |
| 117 | 117 | ||
| 118 | const c_flags = &[_][]const u8{"-std=c99"}; | 118 | var flags = std.ArrayList([]const u8).init(b.allocator); |
| 119 | defer flags.deinit(); | ||
| 120 | try flags.append("-std=c99"); | ||
| 121 | |||
| 122 | inline for (std.meta.fields(EnableOptions)) |field| { | ||
| 123 | const opt = b.option(bool, field.name, "Enable " ++ field.name) orelse @as(*const bool, @ptrCast(field.default_value.?)).*; | ||
| 124 | |||
| 125 | if (opt) { | ||
| 126 | var buf: [field.name.len]u8 = undefined; | ||
| 127 | const name = std.ascii.upperString(&buf, field.name); | ||
| 128 | const flag = try std.fmt.allocPrint(b.allocator, "-DSQLITE_ENABLE_{s}", .{name}); | ||
| 129 | |||
| 130 | try flags.append(flag); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | const c_flags = flags.items; | ||
| 119 | 135 | ||
| 120 | const sqlite_lib = b.addStaticLibrary(.{ | 136 | const sqlite_lib = b.addStaticLibrary(.{ |
| 121 | .name = "sqlite", | 137 | .name = "sqlite", |
| @@ -317,3 +333,9 @@ pub fn build(b: *std.Build) !void { | |||
| 317 | zigcrypto_compile_run.dependOn(&install_zigcrypto_loadable_ext.step); | 333 | zigcrypto_compile_run.dependOn(&install_zigcrypto_loadable_ext.step); |
| 318 | zigcrypto_compile_run.dependOn(&install_zigcrypto_test.step); | 334 | zigcrypto_compile_run.dependOn(&install_zigcrypto_test.step); |
| 319 | } | 335 | } |
| 336 | |||
| 337 | // See https://www.sqlite.org/compile.html for flags | ||
| 338 | const EnableOptions = struct { | ||
| 339 | // https://www.sqlite.org/fts5.html | ||
| 340 | fts5: bool = false, | ||
| 341 | }; | ||