diff options
| author | 2021-03-13 21:48:46 +0100 | |
|---|---|---|
| committer | 2021-03-13 21:48:46 +0100 | |
| commit | 6a2db025c66a7f4ab0a6c28a554e45157d26694d (patch) | |
| tree | f46d1051191d51e6c0614f5fac238d07daf8015a | |
| parent | add two dockerfiles to build with debian and fedora (diff) | |
| parent | readme: add a note about minimum glibc version (diff) | |
| download | zig-sqlite-6a2db025c66a7f4ab0a6c28a554e45157d26694d.tar.gz zig-sqlite-6a2db025c66a7f4ab0a6c28a554e45157d26694d.tar.xz zig-sqlite-6a2db025c66a7f4ab0a6c28a554e45157d26694d.zip | |
Merge branch 'build-glibc'
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | build.zig | 22 |
2 files changed, 35 insertions, 1 deletions
| @@ -59,6 +59,20 @@ exe.linkLibrary(sqlite); | |||
| 59 | exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" }); | 59 | exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" }); |
| 60 | ``` | 60 | ``` |
| 61 | 61 | ||
| 62 | If you're building with glibc you must make sure that the version used is at least 2.28. | ||
| 63 | |||
| 64 | You can do that in your `build.zig` file: | ||
| 65 | ```zig | ||
| 66 | var target = b.standardTargetOptions(.{}); | ||
| 67 | target.setGnuLibCVersion(2, 28, 0); | ||
| 68 | exe.setTarget(target); | ||
| 69 | ``` | ||
| 70 | |||
| 71 | Or with `-Dtarget`: | ||
| 72 | ``` | ||
| 73 | $ zig build -Dtarget=native-linux-gnu.2.28 | ||
| 74 | ``` | ||
| 75 | |||
| 62 | # Usage | 76 | # Usage |
| 63 | 77 | ||
| 64 | Import `zig-sqlite` like this: | 78 | Import `zig-sqlite` like this: |
| @@ -13,7 +13,27 @@ fn linkSqlite(b: *std.build.LibExeObjStep) void { | |||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | pub fn build(b: *std.build.Builder) void { | 15 | pub 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; |