diff options
| author | 2024-12-08 14:53:57 +0100 | |
|---|---|---|
| committer | 2024-12-08 14:53:57 +0100 | |
| commit | 9e0ffbb77998113af8be58490f312a82ea349644 (patch) | |
| tree | 9c510723c0880dbd032c34dde9f907f15ac419f9 /README.md | |
| parent | Merge pull request #171 from vrischmann/always-use-bundled (diff) | |
| parent | update readme (diff) | |
| download | zig-sqlite-9e0ffbb77998113af8be58490f312a82ea349644.tar.gz zig-sqlite-9e0ffbb77998113af8be58490f312a82ea349644.tar.xz zig-sqlite-9e0ffbb77998113af8be58490f312a82ea349644.zip | |
Merge branch 'improve-readme-fetch'
Diffstat (limited to '')
| -rw-r--r-- | README.md | 22 |
1 files changed, 2 insertions, 20 deletions
| @@ -83,24 +83,10 @@ There are three main ways to include `zig-sqlite` in your project: | |||
| 83 | 83 | ||
| 84 | ## Official package manager | 84 | ## Official package manager |
| 85 | 85 | ||
| 86 | Add this as one of the `.dependencies` inside your `build.zig.zon` file: | 86 | Use the following `zig fetch` command: |
| 87 | ```zig | ||
| 88 | .sqlite = .{ | ||
| 89 | .url = "https://github.com/vrischmann/zig-sqlite/archive/COMMIT.tar.gz", | ||
| 90 | .hash = <hash value>, | ||
| 91 | }, | ||
| 92 | ``` | ||
| 93 | |||
| 94 | This tells zig to fetch zig-sqlite from a tarball provided by GitHub. Make sure to replace the `COMMIT` part with an actual commit SHA in long form, like `219faa2a5cd5a268a865a1100e92805df4b84610`. | ||
| 95 | Every time you want to update zig-sqlite you'll have to update this commit. | ||
| 96 | 87 | ||
| 97 | You'll have to provide the `hash` field too which is actually a litte annoying because the hash is of the _content_, not the _archive_ (see [the Zig 0.11 release notes](https://ziglang.org/download/0.11.0/release-notes.html#Package-Management)). | ||
| 98 | The easiest way to get the hash value is to omit it from the file and run `zig build`, it will report an error like this: | ||
| 99 | ``` | 88 | ``` |
| 100 | Fetch Packages... sqlite... /Users/vincent/dev/perso/projects/zig-sqlite-demo/build.zig.zon:6:11: error: url field is missing corresponding hash field | 89 | zig fetch --save git+https://github.com/vrischmann/zig-sqlite |
| 101 | .url = "https://github.com/vrischmann/zig-sqlite/archive/219faa2a5cd5a268a865a1100e92805df4b84610.tar.gz", | ||
| 102 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 103 | note: expected .hash = "122088f0b73f5adcf07c9af8437c5149ed35c3f16f6393c330a294bdd5f91f069a08", | ||
| 104 | ``` | 90 | ``` |
| 105 | 91 | ||
| 106 | Now in your `build.zig` you can access the module like this: | 92 | Now in your `build.zig` you can access the module like this: |
| @@ -109,11 +95,7 @@ const sqlite = b.dependency("sqlite", .{ | |||
| 109 | .target = target, | 95 | .target = target, |
| 110 | .optimize = optimize, | 96 | .optimize = optimize, |
| 111 | }); | 97 | }); |
| 112 | |||
| 113 | exe.root_module.addImport("sqlite", sqlite.module("sqlite")); | 98 | exe.root_module.addImport("sqlite", sqlite.module("sqlite")); |
| 114 | |||
| 115 | // links the bundled sqlite3, so leave this out if you link the system one | ||
| 116 | exe.linkLibrary(sqlite.artifact("sqlite")); | ||
| 117 | ``` | 99 | ``` |
| 118 | 100 | ||
| 119 | ## zigmod | 101 | ## zigmod |