diff options
Diffstat (limited to '')
| -rw-r--r-- | README.md | 24 |
1 files changed, 19 insertions, 5 deletions
| @@ -136,7 +136,9 @@ If you want to use the system sqlite library, add the following to your `build.z | |||
| 136 | ```zig | 136 | ```zig |
| 137 | exe.linkLibC(); | 137 | exe.linkLibC(); |
| 138 | exe.linkSystemLibrary("sqlite3"); | 138 | exe.linkSystemLibrary("sqlite3"); |
| 139 | exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" }); | 139 | exe.addAnonymousModule("sqlite", .{ |
| 140 | .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" }, | ||
| 141 | }); | ||
| 140 | ``` | 142 | ``` |
| 141 | 143 | ||
| 142 | ## Using the bundled sqlite source code file | 144 | ## Using the bundled sqlite source code file |
| @@ -144,8 +146,18 @@ exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" | |||
| 144 | 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: | 146 | 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: |
| 145 | 147 | ||
| 146 | ```zig | 148 | ```zig |
| 147 | const sqlite = b.addStaticLibrary("sqlite", null); | 149 | const sqlite = b.addStaticLibrary(.{ |
| 148 | sqlite.addCSourceFile("third_party/zig-sqlite/c/sqlite3.c", &[_][]const u8{"-std=c99"}); | 150 | .name = "sqlite", |
| 151 | .target = target, | ||
| 152 | .optimize = optimize, | ||
| 153 | }); | ||
| 154 | sqlite.addCSourceFile(.{ | ||
| 155 | .file = .{ .path = "third_party/zig-sqlite/c/sqlite3.c" }, | ||
| 156 | .flags = &[_][]const u8{ | ||
| 157 | "-std=c99", | ||
| 158 | }, | ||
| 159 | }); | ||
| 160 | sqlite.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); | ||
| 149 | sqlite.linkLibC(); | 161 | sqlite.linkLibC(); |
| 150 | ``` | 162 | ``` |
| 151 | 163 | ||
| @@ -155,8 +167,10 @@ Now it's just a matter of linking your `build.zig` target(s) to this library ins | |||
| 155 | 167 | ||
| 156 | ```zig | 168 | ```zig |
| 157 | exe.linkLibrary(sqlite); | 169 | exe.linkLibrary(sqlite); |
| 158 | exe.addPackagePath("sqlite", "third_party/zig-sqlite/sqlite.zig"); | 170 | exe.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); |
| 159 | exe.addIncludeDir("third_party/zig-sqlite/c"); | 171 | exe.addAnonymousModule("sqlite", .{ |
| 172 | .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" }, | ||
| 173 | }); | ||
| 160 | ``` | 174 | ``` |
| 161 | 175 | ||
| 162 | If you're building with glibc you must make sure that the version used is at least 2.28. | 176 | If you're building with glibc you must make sure that the version used is at least 2.28. |