-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
104 lines (80 loc) · 3.16 KB
/
Copy pathbuild.zig
File metadata and controls
104 lines (80 loc) · 3.16 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Create the library module
const fawna_mod = b.createModule(.{
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
});
// Export the module so dependents can use it
b.modules.put("fawna", fawna_mod) catch @panic("OOM");
// Build the library
const lib = b.addLibrary(.{
.linkage = .static,
.name = "fawna",
.root_module = fawna_mod,
});
b.installArtifact(lib);
// Library tests
const lib_unit_tests = b.addTest(.{
.root_module = fawna_mod,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
// Examples
const examples_step = b.step("examples", "Build and run all examples");
inline for ([_][]const u8{ "basic_tsm", "query_parsing", "series_and_tags", "query_executor" }) |example_name| {
const example_mod = b.createModule(.{
.root_source_file = b.path("examples/" ++ example_name ++ ".zig"),
.target = target,
.optimize = optimize,
});
example_mod.addImport("fawna", fawna_mod);
const example_exe = b.addExecutable(.{
.name = example_name,
.root_module = example_mod,
});
b.installArtifact(example_exe);
const example_run = b.addRunArtifact(example_exe);
const example_step = b.step("example-" ++ example_name, "Run " ++ example_name ++ " example");
example_step.dependOn(&example_run.step);
examples_step.dependOn(&example_run.step);
}
// Benchmarks
const benchmark_optimize: std.builtin.OptimizeMode = .ReleaseFast;
const codspeed = b.dependency("codspeed", .{
.target = target,
.optimize = benchmark_optimize,
});
const billions_mod = b.createModule(.{
.root_source_file = b.path("billions.zig"),
.target = target,
.optimize = benchmark_optimize,
});
billions_mod.addImport("codspeed", codspeed.module("codspeed"));
const billions_exe = b.addExecutable(.{
.name = "billions",
.root_module = billions_mod,
});
b.installArtifact(billions_exe);
const billions_run_step = b.step("billions", "Run the billions benchmark");
const billions_run_cmd = b.addRunArtifact(billions_exe);
billions_run_step.dependOn(&billions_run_cmd.step);
const millions_mod = b.createModule(.{
.root_source_file = b.path("millions.zig"),
.target = target,
.optimize = benchmark_optimize,
});
millions_mod.addImport("codspeed", codspeed.module("codspeed"));
const millions_exe = b.addExecutable(.{
.name = "millions",
.root_module = millions_mod,
});
b.installArtifact(millions_exe);
const millions_run_step = b.step("millions", "Run the millions benchmark");
const millions_run_cmd = b.addRunArtifact(millions_exe);
millions_run_step.dependOn(&millions_run_cmd.step);
}