diff options
| author | 2024-07-14 22:51:12 +0200 | |
|---|---|---|
| committer | 2024-07-14 22:51:13 +0200 | |
| commit | e4afe26b30e03ee5d8b61946893b19c2585745f8 (patch) | |
| tree | 700371420939b64109761e2920aa0f510f203c69 | |
| parent | Merge pull request #161 from malcolmstill/master (diff) | |
| download | zig-sqlite-e4afe26b30e03ee5d8b61946893b19c2585745f8.tar.gz zig-sqlite-e4afe26b30e03ee5d8b61946893b19c2585745f8.tar.xz zig-sqlite-e4afe26b30e03ee5d8b61946893b19c2585745f8.zip | |
update fixme
Fixes #163
| -rw-r--r-- | README.md | 50 |
1 files changed, 25 insertions, 25 deletions
| @@ -144,45 +144,45 @@ Then you need to chose if you want to use the system sqlite library or the bundl | |||
| 144 | If you want to use the system sqlite library, add the following to your `build.zig` target(s): | 144 | If you want to use the system sqlite library, add the following to your `build.zig` target(s): |
| 145 | 145 | ||
| 146 | ```zig | 146 | ```zig |
| 147 | const sqlite = b.addModule("sqlite", .{ | ||
| 148 | .root_source_file = b.path("third_party/zig-sqlite/sqlite.zig"), | ||
| 149 | }); | ||
| 150 | sqlite.addCSourceFiles(.{ | ||
| 151 | .files = &[_][]const u8{ | ||
| 152 | "third_party/zig-sqlite/c/workaround.c", | ||
| 153 | }, | ||
| 154 | .flags = &[_][]const u8{"-std=c99"}, | ||
| 155 | }); | ||
| 156 | sqlite.addIncludePath(b.path("third_party/sqlite/c")); | ||
| 157 | |||
| 147 | exe.linkLibC(); | 158 | exe.linkLibC(); |
| 148 | exe.linkSystemLibrary("sqlite3"); | 159 | exe.linkSystemLibrary("sqlite3"); |
| 149 | exe.addAnonymousModule("sqlite", .{ | 160 | exe.root_module.addImport("sqlite", sqlite); |
| 150 | .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" }, | ||
| 151 | }); | ||
| 152 | ``` | 161 | ``` |
| 153 | 162 | ||
| 154 | ## Using the bundled sqlite source code file | 163 | ## Using the bundled sqlite source code file |
| 155 | 164 | ||
| 156 | If you want to use the bundled sqlite source code file, first you need to add it as a static library in your `build.zig` file: | 165 | If you want to use the bundled sqlite source code file, first you need to add it to the module in your `build.zig` file: |
| 157 | 166 | ||
| 158 | ```zig | 167 | ```zig |
| 159 | const sqlite = b.addStaticLibrary(.{ | 168 | const sqlite = b.addModule("sqlite", .{ |
| 160 | .name = "sqlite", | 169 | .root_source_file = b.path("third_party/zig-sqlite/sqlite.zig"), |
| 161 | .target = target, | ||
| 162 | .optimize = optimize, | ||
| 163 | }); | 170 | }); |
| 164 | sqlite.addCSourceFile(.{ | 171 | sqlite.addCSourceFiles(.{ |
| 165 | .file = .{ .path = "third_party/zig-sqlite/c/sqlite3.c" }, | 172 | .files = &[_][]const u8{ |
| 166 | .flags = &[_][]const u8{ | 173 | "third_party/zig-sqlite/c/sqlite3.c", |
| 167 | "-std=c99", | 174 | "third_party/zig-sqlite/c/workaround.c", |
| 168 | }, | 175 | }, |
| 176 | .flags = &[_][]const u8{"-std=c99"}, | ||
| 169 | }); | 177 | }); |
| 170 | sqlite.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); | 178 | sqlite.addIncludePath(b.path("third_party/sqlite/c")); |
| 171 | sqlite.linkLibC(); | ||
| 172 | ``` | ||
| 173 | |||
| 174 | If you need to define custom [compile-time options](https://www.sqlite.org/compile.html#overview) for sqlite, modify the flags (second argument to `addCSourceFile`). | ||
| 175 | 179 | ||
| 176 | Now it's just a matter of linking your `build.zig` target(s) to this library instead of the system one: | 180 | exe.linkLibC(); |
| 177 | 181 | exe.root_module.addImport("sqlite", sqlite); | |
| 178 | ```zig | ||
| 179 | exe.linkLibrary(sqlite); | ||
| 180 | exe.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); | ||
| 181 | exe.addAnonymousModule("sqlite", .{ | ||
| 182 | .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" }, | ||
| 183 | }); | ||
| 184 | ``` | 182 | ``` |
| 185 | 183 | ||
| 184 | If you need to define custom [compile-time options](https://www.sqlite.org/compile.html#overview) for sqlite, modify the flags (second argument to `addCSourceFiles`). | ||
| 185 | |||
| 186 | If you're building with glibc you must make sure that the version used is at least 2.28. | 186 | If you're building with glibc you must make sure that the version used is at least 2.28. |
| 187 | 187 | ||
| 188 | You can do that in your `build.zig` file: | 188 | You can do that in your `build.zig` file: |