summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2021-01-26 00:32:42 +0100
committerGravatar Vincent Rischmann2021-01-26 00:32:42 +0100
commite819a2c4663a6cef9b1400e69ad14438328b524b (patch)
treec3937f21659f30b476a3834322aaaa2db5416482 /README.md
parentci: stop building with the bundled sqlite on aarch64 (diff)
downloadzig-sqlite-e819a2c4663a6cef9b1400e69ad14438328b524b.tar.gz
zig-sqlite-e819a2c4663a6cef9b1400e69ad14438328b524b.tar.xz
zig-sqlite-e819a2c4663a6cef9b1400e69ad14438328b524b.zip
update readme
Add more information about building with the system sqlite library or the bundled sqlite source file.
Diffstat (limited to '')
-rw-r--r--README.md34
1 files changed, 27 insertions, 7 deletions
diff --git a/README.md b/README.md
index 96dfcde..ddeaf89 100644
--- a/README.md
+++ b/README.md
@@ -13,10 +13,10 @@ If you use this library, expect to have to make changes when you update the code
13[Zig master](https://ziglang.org/download/) is the only required dependency. 13[Zig master](https://ziglang.org/download/) is the only required dependency.
14 14
15For sqlite, you have options depending on your target: 15For sqlite, you have options depending on your target:
16* On Windows the only supported way at the moment to build `zig-sqlite` is with the embedded sqlite source code file. 16* On Windows the only supported way at the moment to build `zig-sqlite` is with the bundled sqlite source code file.
17* On Linux we have to options: 17* On Linux we have to options:
18 * use the system and development package for sqlite (`libsqlite3-dev` for Debian and derivatives, `sqlite3-devel` for Fedora) 18 * use the system and development package for sqlite (`libsqlite3-dev` for Debian and derivatives, `sqlite3-devel` for Fedora)
19 * use the embedded sqlite source code file. 19 * use the bundled sqlite source code file.
20 20
21# Features 21# Features
22 22
@@ -28,25 +28,45 @@ For sqlite, you have options depending on your target:
28Since there's no package manager for Zig yet, the recommended way is to use a git submodule: 28Since there's no package manager for Zig yet, the recommended way is to use a git submodule:
29 29
30```bash 30```bash
31$ git submodule add https://github.com/vrischmann/zig-sqlite.git src/sqlite 31$ git submodule add https://github.com/vrischmann/zig-sqlite.git third_party/zig-sqlite
32``` 32```
33 33
34Then add the following to your `build.zig` target(s): 34## Using the system sqlite library
35
36If you want to use the system sqlite library, add the following to your `build.zig` target(s):
35 37
36```zig 38```zig
37exe.linkLibC(); 39exe.linkLibC();
38exe.linkSystemLibrary("sqlite3"); 40exe.linkSystemLibrary("sqlite3");
39exe.addPackage(.{ .name = "sqlite", .path = "src/sqlite/sqlite.zig" }); 41exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" });
40``` 42```
41 43
42Now you should be able to import sqlite like this: 44## Using the bundled sqlite source code file
45
46If 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:
43 47
44```zig 48```zig
45const sqlite = @import("sqlite"); 49const sqlite = b.addStaticLibrary("sqlite", null);
50sqlite.addCSourceFile("third_party/zig-sqlite/sqlite3.c", &[_][]const u8{"-std=c99"});
51sqlite.linkLibC();
52```
53
54Now it's just a matter of linking your `build.zig` target(s) to this library instead of the system one:
55
56```zig
57exe.linkLibC();
58exe.linkLibrary(sqlite);
59exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" });
46``` 60```
47 61
48# Usage 62# Usage
49 63
64Import `zig-sqlite` like this:
65
66```zig
67const sqlite = @import("sqlite");
68```
69
50## Initialization 70## Initialization
51 71
52You must create and initialize an instance of `sqlite.Db`: 72You must create and initialize an instance of `sqlite.Db`: