Skip to content

Commit d73340d

Browse files
committed
Switched to zig build
1 parent 2a562eb commit d73340d

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ jobs:
1616
cd pgvector
1717
make
1818
sudo make install
19-
- run: zig run example.zig -I/usr/include/postgresql -lc -lpq
19+
- run: zig build
20+
- run: zig-out/bin/example

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/example
2-
*.o
1+
/.zig-cache
2+
/zig-out

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ To get started with development:
7575
git clone https://github.com/pgvector/pgvector-zig.git
7676
cd pgvector-zig
7777
createdb pgvector_zig_test
78-
zig run example.zig -lc -lpq
78+
zig build
79+
zig-out/bin/example
7980
```
8081

8182
Specify the path to libpq if needed:
8283

8384
```sh
84-
zig run example.zig -I/opt/homebrew/opt/libpq/include -L/opt/homebrew/opt/libpq/lib -lc -lpq
85+
zig build --search-prefix /opt/homebrew/opt/libpq
8586
```

build.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const exe = b.addExecutable(.{
5+
.name = "example",
6+
.root_source_file = b.path("example.zig"),
7+
.target = b.graph.host,
8+
});
9+
10+
exe.linkSystemLibrary("pq");
11+
exe.linkLibC();
12+
13+
b.installArtifact(exe);
14+
}

0 commit comments

Comments
 (0)