-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.zig
186 lines (163 loc) · 8.25 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Run
// -----------------------------------------------
{
const exe = b.addExecutable(.{
.name = "zippondb",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
exe.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
exe.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
exe.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
exe.root_module.addImport("error", b.createModule(.{ .root_source_file = b.path("lib/errors.zig") }));
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
// Test
// -----------------------------------------------
{
const tests1 = b.addTest(.{
.root_source_file = b.path("src/dataStructure/UUIDFileIndex.zig"),
.target = target,
.optimize = optimize,
.name = "CLI tokenizer",
.test_runner = b.path("src/test_runner.zig"),
});
tests1.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
const run_tests1 = b.addRunArtifact(tests1);
const tests2 = b.addTest(.{
.root_source_file = b.path("src/cli/tokenizer.zig"),
.target = target,
.optimize = optimize,
.name = "CLI tokenizer",
.test_runner = b.path("src/test_runner.zig"),
});
const run_tests2 = b.addRunArtifact(tests2);
const tests3 = b.addTest(.{
.root_source_file = b.path("src/ziql/tokenizer.zig"),
.target = target,
.optimize = optimize,
.name = "ZiQL tokenizer",
.test_runner = b.path("src/test_runner.zig"),
});
const run_tests3 = b.addRunArtifact(tests3);
const tests4 = b.addTest(.{
.root_source_file = b.path("src/schema/tokenizer.zig"),
.target = target,
.optimize = optimize,
.name = "Schema tokenizer",
.test_runner = b.path("src/test_runner.zig"),
});
tests4.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
tests4.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
const run_tests4 = b.addRunArtifact(tests4);
const tests5 = b.addTest(.{
.root_source_file = b.path("src/test.zig"),
.target = target,
.optimize = optimize,
.name = "ZiQL parser",
.test_runner = b.path("src/test_runner.zig"),
});
tests5.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
tests5.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
tests5.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
tests5.root_module.addImport("error", b.createModule(.{ .root_source_file = b.path("lib/errors.zig") }));
const run_tests5 = b.addRunArtifact(tests5);
const tests6 = b.addTest(.{
.root_source_file = b.path("src/dataStructure/filter.zig"),
.target = target,
.optimize = optimize,
.name = "Filter tree",
.test_runner = b.path("src/test_runner.zig"),
});
tests6.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
tests6.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
tests6.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
tests6.root_module.addImport("error", b.createModule(.{ .root_source_file = b.path("lib/errors.zig") }));
const run_tests6 = b.addRunArtifact(tests6);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests1.step);
test_step.dependOn(&run_tests2.step);
test_step.dependOn(&run_tests3.step);
test_step.dependOn(&run_tests4.step);
test_step.dependOn(&run_tests5.step);
test_step.dependOn(&run_tests6.step);
}
// Test zid
// -----------------------------------------------
{
const tests1 = b.addTest(.{
.root_source_file = b.path("lib/zid.zig"),
.target = target,
.optimize = optimize,
.name = "File parsing",
.test_runner = b.path("src/test_runner.zig"),
});
const run_tests1 = b.addRunArtifact(tests1);
const test_step = b.step("benchmark-parsing", "Run the benchmark of ZipponData (Single thread).");
test_step.dependOn(&run_tests1.step);
}
// Benchmark
// -----------------------------------------------
{
const benchmark = b.addExecutable(.{
.name = "benchmark",
.root_source_file = b.path("src/benchmark.zig"),
.target = target,
.optimize = optimize,
});
benchmark.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
benchmark.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config_benchmark.zig") }));
benchmark.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
benchmark.root_module.addImport("error", b.createModule(.{ .root_source_file = b.path("lib/errors.zig") }));
b.installArtifact(benchmark);
const run_benchmark = b.addRunArtifact(benchmark);
run_benchmark.step.dependOn(b.getInstallStep());
const benchmark_step = b.step("benchmark", "Run benchmarks");
benchmark_step.dependOn(&run_benchmark.step);
}
// Release
// -----------------------------------------------
{
const release_step = b.step("release", "Create release binaries for multiple platforms");
const targets = [_]std.Build.ResolvedTarget{
b.resolveTargetQuery(.{ .os_tag = .windows, .cpu_arch = .x86_64 }),
//b.resolveTargetQuery(.{ .os_tag = .windows, .cpu_arch = .arm }),
b.resolveTargetQuery(.{ .os_tag = .macos, .cpu_arch = .x86_64 }),
b.resolveTargetQuery(.{ .os_tag = .macos, .cpu_arch = .aarch64 }),
b.resolveTargetQuery(.{ .os_tag = .linux, .cpu_arch = .x86_64 }),
b.resolveTargetQuery(.{ .os_tag = .linux, .cpu_arch = .aarch64 }),
//b.resolveTargetQuery(.{ .os_tag = .linux, .cpu_arch = .arm }),
b.resolveTargetQuery(.{ .os_tag = .linux, .cpu_arch = .riscv64 }),
};
for (targets) |tar| {
const exe_name = b.fmt("zippondb-{s}-{s}", .{
@tagName(tar.query.cpu_arch.?),
@tagName(tar.query.os_tag.?),
});
const exe = b.addExecutable(.{
.name = exe_name,
.root_source_file = b.path("src/main.zig"),
.target = tar,
.optimize = optimize,
});
// Add the same imports as your main executable
exe.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
exe.root_module.addImport("config", b.createModule(.{ .root_source_file = b.path("lib/config.zig") }));
exe.root_module.addImport("ZipponData", b.createModule(.{ .root_source_file = b.path("lib/zid.zig") }));
exe.root_module.addImport("error", b.createModule(.{ .root_source_file = b.path("lib/errors.zig") }));
const install_exe = b.addInstallArtifact(exe, .{
.dest_dir = .{ .override = .{ .custom = "release" } },
});
release_step.dependOn(&install_exe.step);
}
}
}