This repository was archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
67 lines (60 loc) · 2.2 KB
/
build.zig
File metadata and controls
67 lines (60 loc) · 2.2 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
56
57
58
59
60
61
62
63
64
65
66
67
/// this build.zig shows how to link libgeos with an exe and with your unit tests.
const std = @import("std");
const libgeos = @import("src/libgeos.zig");
const Example = struct {
cmd: []const u8,
src: []const u8,
descr: []const u8,
};
const examples = [_]Example{
Example{
.cmd = "run-ex1",
.src = "src/examples/ex1.zig",
.descr = "Ex 1: Reads two WKT representations and calculates the intersection, prints it out, and cleans up."
},
Example{
.cmd = "run-ex1-ts",
.src = "src/examples/ex1_threadsafe.zig",
.descr = "Ex 1 (threadsafe): Same but using re-entrant api.",
},
Example{
.cmd = "run-ex2",
.src = "src/examples/ex2.zig",
.descr = "Ex 2: Reads one geometry and does a high-performance prepared geometry operations to place random points inside it."
},
Example{
.cmd = "run-ex3",
.src = "src/examples/ex3.zig",
.descr = "Ex 3: Build a spatial index and search it for a nearest pair.",
},
};
pub fn build(b: *std.build.Builder) !void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
// the C api depends on the core C++ lib, so build and link both of them.
const core_lib = try libgeos.createCore(b, target, mode);
const capi_lib = try libgeos.createCAPI(b, target, mode);
// setup unit tests step
const tests = b.addTest("src/tests.zig");
core_lib.link(tests, .{});
capi_lib.link(tests, .{ .import_name = "geos" });
const test_step = b.step("test", "Run tests");
test_step.dependOn(&tests.step);
// add all examples
for (examples) |ex| {
const exe = b.addExecutable(ex.cmd, ex.src);
exe.addPackagePath("default_handlers", "src/shim/default_handlers.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
core_lib.link(exe, .{});
capi_lib.link(exe, .{ .import_name = "geos" });
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(ex.cmd, ex.descr);
run_step.dependOn(&run_cmd.step);
}
}