-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
47 lines (39 loc) · 1.61 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const std = @import("std");
// Load pgzx build support. The build utilities use pg_config to find all dependencies
// and provide functions go create and test extensions.
const PGBuild = @import("pgzx").Build;
pub fn build(b: *std.Build) void {
// Project meta data
const name = "pg_tigerbeetle";
const version = .{ .major = 0, .minor = 1 };
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Load the pgzx module and initialize the build utilities
const dep_pgzx = b.dependency("pgzx", .{ .target = target, .optimize = optimize });
const pgzx = dep_pgzx.module("pgzx");
var pgbuild = PGBuild.create(b, .{ .target = target, .optimize = optimize });
// Register the dependency with the build system
// and add pgzx as module dependency.
const ext = pgbuild.addInstallExtension(.{
.name = name,
.version = version,
.root_source_file = b.path("src/main.zig"),
.root_dir = ".",
});
ext.lib.addIncludePath(b.path("./lib/"));
ext.lib.addObjectFile(b.path("./lib/libtb_client.a"));
ext.lib.root_module.addImport("pgzx", pgzx);
b.getInstallStep().dependOn(&ext.step);
// Configure pg_regress based testing for the current extension.
const extest = pgbuild.addRegress(.{
.db_user = "postgres",
.db_port = 5432,
.root_dir = ".",
.scripts = &[_][]const u8{
"char_count_test",
},
});
// Make regression tests available to `zig build`
var regress = b.step("pg_regress", "Run regression tests");
regress.dependOn(&extest.step);
}