Skip to content

Commit 58347f9

Browse files
committed
Update readme to show usage of new bindings module
1 parent 9354eee commit 58347f9

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ Provides a package to be used by the zig package manager for C programs.
77
| Architecture \ OS | Linux | MacOS |
88
|:------------------|:-----------|-------|
99
| x86_64 |||
10-
| arm 64 | (untested) | |
10+
| arm 64 | (untested) |* |
1111

12-
| Refname | PostgreSQL version | Zig `0.15.x` | Zig `0.14.x` | Zig `0.13.x` |
13-
|------------|--------------------|--------------|--------------|--------------|
14-
| `5.16.4+4` | `REL_16_4` ||||
15-
| `5.16.4+3` | `REL_16_4` ||||
16-
| `5.16.4+2` | `REL_16_4` ||||
12+
| Refname | PostgreSQL version | Zig `0.16.x` | Zig `0.15.x` | Zig `0.14.x` | Zig `0.13.x` |
13+
|------------|--------------------|--------------|--------------|--------------|--------------|
14+
| `5.16.4+5` | `REL_16_4` |||||
15+
| `5.16.4+4` | `REL_16_4` |* ||||
16+
| `5.16.4+4` | `REL_16_4` |* ||||
17+
| `5.16.4+3` | `REL_16_4` |||||
18+
| `5.16.4+2` | `REL_16_4` |||||
19+
20+
*: Will not work with OpenSSL
1721

1822
## Use
1923

@@ -25,10 +29,12 @@ zig fetch --save git+https://github.com/allyourcodebase/libpq#master
2529
Then, in your `build.zig`:
2630
```zig
2731
const postgres = b.dependency("libpq", { .target = target, .optimize = optimize });
28-
const libpq = postgres.artifact("pq");
2932
30-
// wherever needed:
31-
exe.linkLibrary(libpq);
33+
// to use from Zig (since 5.16.4+5):
34+
mod.addImport("libpq", postgres.module("libpq"));
35+
36+
// to use from C:
37+
exe.linkLibrary(postgres.artifact("pq"));
3238
```
3339

3440
## Options

build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ pub fn build(b: *std.Build) !void {
303303
}
304304
binding.addIncludePath(upstream.path(libpq_path));
305305
binding.addIncludePath(upstream.path("src/include"));
306-
_ = binding.addModule("libpq");
306+
const bindmod = binding.addModule("libpq");
307+
bindmod.linkLibrary(lib);
307308
}
308309
}
309310

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
.hash = "N-V-__8AAKeztweKsqUQCZESI7M-Rw2v-1IU1bTHR5SS-px6",
1010
},
1111
.openssl = .{
12-
.url = "git+https://github.com/allyourcodebase/openssl?ref=main#cad7ccba47e42fa608ca655ec14ae33202df86e1",
13-
.hash = "openssl-3.3.2-TC9C3Wa3ZACgB1hZbrLOQCK9XccIBaW_F3imFfIeYP06",
12+
.url = "git+https://github.com/allyourcodebase/openssl?ref=main#7d4b2590b3b05fbc0e5cc20e2704a968e63503b1",
13+
.hash = "openssl-3.3.2-TC9C3Vy3ZABkts70T3a6QfLYghNUy0tI42ksiW7jRmvd",
1414
.lazy = true,
1515
},
1616
.libressl = .{

0 commit comments

Comments
 (0)