-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
55 lines (47 loc) · 1.85 KB
/
build.zig
File metadata and controls
55 lines (47 loc) · 1.85 KB
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
48
49
50
51
52
53
54
55
const std = @import("std");
pub fn build(b: *std.Build) !void {
// Define the common build options
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const psql_dep = b.addModule("psql", .{
.root_source_file = b.path("psql.zig"),
});
psql_dep.addIncludePath(b.path("pq/include/"));
// Add the directory for the library files.
psql_dep.addLibraryPath(b.path("pq/lib/"));
// Create a static library target for the package.
// This will compile your psql.zig into a static library.
const lib = b.addStaticLibrary(.{
.name = "psql",
.root_source_file = b.path("psql.zig"),
.target = target,
.optimize = optimize,
});
// Link the PostgreSQL C libraries.
// Add the directory for header files.
lib.addIncludePath(b.path("pq/include/"));
// Add the directory for the library files.
lib.addLibraryPath(b.path("pq/lib/"));
// Link the PostgreSQL library.
lib.linkSystemLibrary("pq");
b.installArtifact(lib);
// Optionally add tests. Here we build and link a test executable.
var main_test = b.addTest(. {
.root_source_file = b.path("psql-tests.zig"),
.target = target,
.optimize = optimize,
});
// Link the static library we created so that tests use the package.
main_test.linkLibrary(lib);
main_test.addIncludePath(b.path("pq/include/"));
// Add the directory for the library files.
main_test.addLibraryPath(b.path("pq/lib/"));
// Link the PostgreSQL library.
main_test.linkSystemLibrary("pq");
const run_test = b.addRunArtifact(main_test);
//Testing the module
const test_step = b.step("test", "Run PSQL tests");
test_step.dependOn(&run_test.step);
// By default, build the static library.
b.default_step.dependOn(&lib.step);
}