-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig
More file actions
59 lines (51 loc) · 1.87 KB
/
build.zig
File metadata and controls
59 lines (51 loc) · 1.87 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const maxminddb_module = b.addModule("maxminddb", .{
.root_source_file = b.path("src/maxminddb.zig"),
});
{
const tests = b.addTest(.{
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/maxminddb.zig"),
}),
});
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests.step);
}
const examples = [_]struct {
file: []const u8,
name: []const u8,
}{
.{ .file = "examples/lookup.zig", .name = "example_lookup" },
.{ .file = "examples/within.zig", .name = "example_within" },
.{ .file = "examples/inspect.zig", .name = "example_inspect" },
.{ .file = "benchmarks/lookup.zig", .name = "benchmark_lookup" },
.{ .file = "benchmarks/inspect.zig", .name = "benchmark_inspect" },
};
{
for (examples) |ex| {
const exe = b.addExecutable(.{
.name = ex.name,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path(ex.file),
}),
});
exe.root_module.addImport("maxminddb", maxminddb_module);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(ex.name, ex.file);
run_step.dependOn(&run_cmd.step);
}
}
}