diff options
| -rw-r--r-- | README.md | 64 |
1 files changed, 0 insertions, 64 deletions
| @@ -119,70 +119,6 @@ deps.addAllTo(exe); | |||
| 119 | 119 | ||
| 120 | This is the easiest way to add `zig-sqlite` because it uses the bundled source code, avoiding all sorts of linking problems. | 120 | This is the easiest way to add `zig-sqlite` because it uses the bundled source code, avoiding all sorts of linking problems. |
| 121 | 121 | ||
| 122 | ## Git submodule | ||
| 123 | |||
| 124 | If you don't want to use a package manager you can simply add this repository as a git submodule. | ||
| 125 | |||
| 126 | Then you need to chose if you want to use the system sqlite library or the bundled source code. | ||
| 127 | |||
| 128 | ## Using the system sqlite library | ||
| 129 | |||
| 130 | If you want to use the system sqlite library, add the following to your `build.zig` target(s): | ||
| 131 | |||
| 132 | ```zig | ||
| 133 | const sqlite = b.addModule("sqlite", .{ | ||
| 134 | .root_source_file = b.path("third_party/zig-sqlite/sqlite.zig"), | ||
| 135 | }); | ||
| 136 | sqlite.addCSourceFiles(.{ | ||
| 137 | .files = &[_][]const u8{ | ||
| 138 | "third_party/zig-sqlite/c/workaround.c", | ||
| 139 | }, | ||
| 140 | .flags = &[_][]const u8{"-std=c99"}, | ||
| 141 | }); | ||
| 142 | sqlite.addIncludePath(b.path("third_party/sqlite/c")); | ||
| 143 | |||
| 144 | exe.linkLibC(); | ||
| 145 | exe.linkSystemLibrary("sqlite3"); | ||
| 146 | exe.root_module.addImport("sqlite", sqlite); | ||
| 147 | ``` | ||
| 148 | |||
| 149 | ## Using the bundled sqlite source code file | ||
| 150 | |||
| 151 | 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: | ||
| 152 | |||
| 153 | ```zig | ||
| 154 | const sqlite = b.addModule("sqlite", .{ | ||
| 155 | .root_source_file = b.path("third_party/zig-sqlite/sqlite.zig"), | ||
| 156 | }); | ||
| 157 | sqlite.addCSourceFiles(.{ | ||
| 158 | .files = &[_][]const u8{ | ||
| 159 | "third_party/zig-sqlite/c/sqlite3.c", | ||
| 160 | "third_party/zig-sqlite/c/workaround.c", | ||
| 161 | }, | ||
| 162 | .flags = &[_][]const u8{"-std=c99"}, | ||
| 163 | }); | ||
| 164 | sqlite.addIncludePath(b.path("third_party/sqlite/c")); | ||
| 165 | |||
| 166 | exe.linkLibC(); | ||
| 167 | exe.root_module.addImport("sqlite", sqlite); | ||
| 168 | ``` | ||
| 169 | |||
| 170 | 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`). | ||
| 171 | |||
| 172 | If you're building with glibc you must make sure that the version used is at least 2.28. | ||
| 173 | |||
| 174 | You can do that in your `build.zig` file: | ||
| 175 | ```zig | ||
| 176 | var target = b.standardTargetOptions(.{}); | ||
| 177 | target.setGnuLibCVersion(2, 28, 0); | ||
| 178 | exe.setTarget(target); | ||
| 179 | ``` | ||
| 180 | |||
| 181 | Or with `-Dtarget`: | ||
| 182 | ``` | ||
| 183 | $ zig build -Dtarget=native-linux-gnu.2.28 | ||
| 184 | ``` | ||
| 185 | |||
| 186 | # Usage | 122 | # Usage |
| 187 | 123 | ||
| 188 | ## Demo | 124 | ## Demo |