Skip to content

Commit 9354eee

Browse files
committed
Provide generated zig bindings from the public headers
Relates to #12
1 parent 46fbaf8 commit 9354eee

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

build.zig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,24 @@ pub fn build(b: *std.Build) !void {
287287
const install_test = b.addInstallArtifact(t, .{});
288288
test_step.dependOn(&install_test.step);
289289
}
290+
291+
{ // Generate zig bindings from C headers
292+
const include_all = b.addWriteFile("grpc.h",
293+
\\#include <libpq-fe.h>
294+
\\#include <libpq-events.h>
295+
);
296+
const binding = b.addTranslateC(.{
297+
.root_source_file = try include_all.getDirectory().join(b.allocator, "grpc.h"),
298+
.target = target,
299+
.optimize = optimize,
300+
});
301+
for (config_headers) |header| {
302+
binding.addConfigHeader(header);
303+
}
304+
binding.addIncludePath(upstream.path(libpq_path));
305+
binding.addIncludePath(upstream.path("src/include"));
306+
_ = binding.addModule("libpq");
307+
}
290308
}
291309

292310
const libpq_sources = .{

0 commit comments

Comments
 (0)