summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2024-07-14 22:51:12 +0200
committerGravatar Vincent Rischmann2024-07-14 22:51:13 +0200
commite4afe26b30e03ee5d8b61946893b19c2585745f8 (patch)
tree700371420939b64109761e2920aa0f510f203c69
parentMerge pull request #161 from malcolmstill/master (diff)
downloadzig-sqlite-e4afe26b30e03ee5d8b61946893b19c2585745f8.tar.gz
zig-sqlite-e4afe26b30e03ee5d8b61946893b19c2585745f8.tar.xz
zig-sqlite-e4afe26b30e03ee5d8b61946893b19c2585745f8.zip
update fixme
Fixes #163
Diffstat (limited to '')
-rw-r--r--README.md50
1 files changed, 25 insertions, 25 deletions
diff --git a/README.md b/README.md
index c1b6e04..1f4193f 100644
--- a/README.md
+++ b/README.md
@@ -144,45 +144,45 @@ Then you need to chose if you want to use the system sqlite library or the bundl
144If you want to use the system sqlite library, add the following to your `build.zig` target(s): 144If you want to use the system sqlite library, add the following to your `build.zig` target(s):
145 145
146```zig 146```zig
147const sqlite = b.addModule("sqlite", .{
148 .root_source_file = b.path("third_party/zig-sqlite/sqlite.zig"),
149});
150sqlite.addCSourceFiles(.{
151 .files = &[_][]const u8{
152 "third_party/zig-sqlite/c/workaround.c",
153 },
154 .flags = &[_][]const u8{"-std=c99"},
155});
156sqlite.addIncludePath(b.path("third_party/sqlite/c"));
157
147exe.linkLibC(); 158exe.linkLibC();
148exe.linkSystemLibrary("sqlite3"); 159exe.linkSystemLibrary("sqlite3");
149exe.addAnonymousModule("sqlite", .{ 160exe.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
156If 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: 165If 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
159const sqlite = b.addStaticLibrary(.{ 168const 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});
164sqlite.addCSourceFile(.{ 171sqlite.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});
170sqlite.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); 178sqlite.addIncludePath(b.path("third_party/sqlite/c"));
171sqlite.linkLibC();
172```
173
174If 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
176Now it's just a matter of linking your `build.zig` target(s) to this library instead of the system one: 180exe.linkLibC();
177 181exe.root_module.addImport("sqlite", sqlite);
178```zig
179exe.linkLibrary(sqlite);
180exe.addIncludePath(.{ .path = "third_party/zig-sqlite/c" });
181exe.addAnonymousModule("sqlite", .{
182 .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" },
183});
184``` 182```
185 183
184If 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
186If you're building with glibc you must make sure that the version used is at least 2.28. 186If you're building with glibc you must make sure that the version used is at least 2.28.
187 187
188You can do that in your `build.zig` file: 188You can do that in your `build.zig` file: