summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2021-03-13 21:48:46 +0100
committerGravatar Vincent Rischmann2021-03-13 21:48:46 +0100
commit6a2db025c66a7f4ab0a6c28a554e45157d26694d (patch)
treef46d1051191d51e6c0614f5fac238d07daf8015a
parentadd two dockerfiles to build with debian and fedora (diff)
parentreadme: add a note about minimum glibc version (diff)
downloadzig-sqlite-6a2db025c66a7f4ab0a6c28a554e45157d26694d.tar.gz
zig-sqlite-6a2db025c66a7f4ab0a6c28a554e45157d26694d.tar.xz
zig-sqlite-6a2db025c66a7f4ab0a6c28a554e45157d26694d.zip
Merge branch 'build-glibc'
-rw-r--r--README.md14
-rw-r--r--build.zig22
2 files changed, 35 insertions, 1 deletions
diff --git a/README.md b/README.md
index 841adfe..aeeff31 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,20 @@ exe.linkLibrary(sqlite);
59exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" }); 59exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" });
60``` 60```
61 61
62If you're building with glibc you must make sure that the version used is at least 2.28.
63
64You can do that in your `build.zig` file:
65```zig
66var target = b.standardTargetOptions(.{});
67target.setGnuLibCVersion(2, 28, 0);
68exe.setTarget(target);
69```
70
71Or with `-Dtarget`:
72```
73$ zig build -Dtarget=native-linux-gnu.2.28
74```
75
62# Usage 76# Usage
63 77
64Import `zig-sqlite` like this: 78Import `zig-sqlite` like this:
diff --git a/build.zig b/build.zig
index 2c958b9..a1af313 100644
--- a/build.zig
+++ b/build.zig
@@ -13,7 +13,27 @@ fn linkSqlite(b: *std.build.LibExeObjStep) void {
13} 13}
14 14
15pub fn build(b: *std.build.Builder) void { 15pub fn build(b: *std.build.Builder) void {
16 const target = b.standardTargetOptions(.{}); 16 const target = blk: {
17 var tmp = b.standardTargetOptions(.{});
18
19 if (tmp.isGnuLibC()) {
20 const min_glibc_version = std.builtin.Version{
21 .major = 2,
22 .minor = 28,
23 .patch = 0,
24 };
25 if (tmp.glibc_version) |ver| {
26 if (ver.order(min_glibc_version) == .lt) {
27 std.debug.panic("sqlite requires glibc version >= 2.28", .{});
28 }
29 } else {
30 tmp.setGnuLibCVersion(2, 28, 0);
31 }
32 }
33
34 break :blk tmp;
35 };
36
17 const mode = b.standardReleaseOptions(); 37 const mode = b.standardReleaseOptions();
18 38
19 const in_memory = b.option(bool, "in_memory", "Should the tests run with sqlite in memory (default true)") orelse true; 39 const in_memory = b.option(bool, "in_memory", "Should the tests run with sqlite in memory (default true)") orelse true;