-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig
More file actions
383 lines (336 loc) · 13.2 KB
/
Copy pathbuild.zig
File metadata and controls
383 lines (336 loc) · 13.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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
const std = @import("std");
const build_support = @import("src/build_support.zig");
pub const TidyPattern = build_support.TidyPattern;
pub const TidyAllow = build_support.TidyAllow;
pub const TidyExecutableOptions = build_support.TidyExecutableOptions;
pub const TidyStepOptions = build_support.TidyStepOptions;
/// Add Marionette's tidy executable to a consuming build.
pub fn addTidyExecutable(
b: *std.Build,
options: TidyExecutableOptions,
) *std.Build.Step.Compile {
const marionette = b.dependencyFromBuildZig(@This(), .{});
return build_support.addTidyExecutable(
b,
marionette.path("src/main_tidy.zig"),
options,
);
}
/// Add a tidy run step whose source belongs to the Marionette dependency.
pub fn addTidyStep(
b: *std.Build,
options: TidyStepOptions,
) *std.Build.Step.Run {
const marionette = b.dependencyFromBuildZig(@This(), .{});
return build_support.addTidyStep(
b,
marionette.path("src/main_tidy.zig"),
options,
);
}
fn addValidation(
b: *std.Build,
module: *std.Build.Module,
name: []const u8,
description: []const u8,
) *std.Build.Step.Run {
const run = b.addRunArtifact(b.addTest(.{ .root_module = module }));
b.step(name, description).dependOn(&run.step);
return run;
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("marionette", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
const release_mod = b.addModule("marionette_release", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = .ReleaseFast,
});
// Everything past this point is development-only build graph: tests,
// examples, validation SUTs, tidy, and release checks. A project that
// depends on Marionette needs only the modules above, and returning
// here keeps the lazy validation dependencies from being fetched into
// consumer projects and keeps their build scripts from running there.
if (b.pkg_hash.len != 0) return;
const mod_tests = b.addTest(.{ .root_module = mod });
const run_mod_tests = b.addRunArtifact(mod_tests);
const examples_mod = b.createModule(.{
.root_source_file = b.path("examples/root.zig"),
.target = target,
.optimize = optimize,
});
examples_mod.addImport("marionette", mod);
const example_tests = b.addTest(.{ .root_module = examples_mod });
const run_example_tests = b.addRunArtifact(example_tests);
const run_examples_mod = b.createModule(.{
.root_source_file = b.path("src/main_run.zig"),
.target = target,
.optimize = optimize,
});
run_examples_mod.addImport("marionette", mod);
run_examples_mod.addImport("examples", examples_mod);
const run_examples_exe = b.addExecutable(.{
.name = "marionette-run",
.root_module = run_examples_mod,
});
b.installArtifact(run_examples_exe);
const run_examples_cmd = b.addRunArtifact(run_examples_exe);
if (b.args) |args| run_examples_cmd.addArgs(args);
const run_examples_step = b.step("run-example", "Run a Marionette example by seed");
run_examples_step.dependOn(&run_examples_cmd.step);
const release_probe_mod = b.createModule(.{
.root_source_file = b.path("tests/release_symbol_probe.zig"),
.target = target,
.optimize = .ReleaseFast,
.strip = true,
});
release_probe_mod.addImport("marionette", release_mod);
const release_probe_exe = b.addExecutable(.{
.name = "marionette-release-symbol-probe",
.root_module = release_probe_mod,
});
const check_release_symbols_cmd = b.addSystemCommand(&.{
"sh",
"tests/check_release_symbols.sh",
});
check_release_symbols_cmd.addArtifactArg(release_probe_exe);
const check_release_symbols_step = b.step(
"check-release-symbols",
"Verify production release binary does not contain simulation-only symbols",
);
check_release_symbols_step.dependOn(&check_release_symbols_cmd.step);
if (b.lazyDependency("xitdb", .{
.target = target,
.optimize = optimize,
})) |xitdb_dep| {
const validate_xitdb_mod = b.createModule(.{
.root_source_file = b.path("validation/xitdb_durability.zig"),
.target = target,
.optimize = optimize,
});
validate_xitdb_mod.addImport("marionette", mod);
validate_xitdb_mod.addImport("xitdb", xitdb_dep.module("xitdb"));
_ = addValidation(b, validate_xitdb_mod, "validate-xitdb", "Run xitdb under Marionette");
}
if (b.lazyDependency("mailbox", .{
.target = target,
.optimize = optimize,
})) |mailbox_dep| {
const validate_mailbox_mod = b.createModule(.{
.root_source_file = b.path("validation/mailbox_concurrency.zig"),
.target = target,
.optimize = optimize,
});
validate_mailbox_mod.addImport("marionette", mod);
validate_mailbox_mod.addImport("mailbox", mailbox_dep.module("mailbox"));
_ = addValidation(b, validate_mailbox_mod, "validate-mailbox", "Run Mailbox under Marionette");
}
if (b.lazyDependency("ochi", .{
.target = target,
.optimize = optimize,
})) |ochi_dep| {
const ochi_root_mod = ochi_dep.artifact("Ochi").root_module;
const ochi_store_mod = b.createModule(.{
.root_source_file = ochi_dep.path("src/Store.zig"),
.target = target,
.optimize = optimize,
});
const ochi_imports = [_][]const u8{
"zeit",
"zint",
"metrics",
"logz",
"logging",
"tracy",
"c",
"encoding",
};
for (ochi_imports) |name| {
ochi_store_mod.addImport(name, ochi_root_mod.import_table.get(name).?);
}
const validate_ochi_mod = b.createModule(.{
.root_source_file = b.path("validation/ochi_store.zig"),
.target = target,
.optimize = optimize,
});
validate_ochi_mod.addImport("marionette", mod);
validate_ochi_mod.addImport("ochi_store", ochi_store_mod);
validate_ochi_mod.addImport("ochi_logging", ochi_root_mod.import_table.get("logging").?);
_ = addValidation(
b,
validate_ochi_mod,
"validate-ochi",
"Run Ochi's unmodified storage path under Marionette",
);
}
if (b.lazyDependency("dusty", .{
.target = target,
.optimize = optimize,
.use_tls = false,
})) |dusty_dep| {
const validate_dusty_mod = b.createModule(.{
.root_source_file = b.path("validation/dusty_http.zig"),
.target = target,
.optimize = optimize,
});
validate_dusty_mod.addImport("marionette", mod);
validate_dusty_mod.addImport("dusty", dusty_dep.module("dusty"));
_ = addValidation(
b,
validate_dusty_mod,
"validate-dusty",
"Run the unmodified dusty HTTP client/server under Marionette",
);
}
if (b.lazyDependency("beanstalkz", .{
.target = target,
.optimize = optimize,
})) |beanstalkz_dep| {
const validate_beanstalkz_mod = b.createModule(.{
.root_source_file = b.path("validation/beanstalkz_queue.zig"),
.target = target,
.optimize = optimize,
});
validate_beanstalkz_mod.addImport("marionette", mod);
validate_beanstalkz_mod.addImport("beanstalkz", beanstalkz_dep.module("beanstalkz"));
_ = addValidation(
b,
validate_beanstalkz_mod,
"validate-beanstalkz",
"Run the unmodified beanstalkz queue client under Marionette",
);
}
const validate_bounded_queue_mod = b.createModule(.{
.root_source_file = b.path("validation/bounded_queue_concurrency.zig"),
.target = target,
.optimize = optimize,
});
validate_bounded_queue_mod.addImport("marionette", mod);
const run_validate_bounded_queue = addValidation(
b,
validate_bounded_queue_mod,
"validate-bounded-queue",
"Run the cooperative bounded-queue capability validation",
);
const validate_std_io_net_kv_mod = b.createModule(.{
.root_source_file = b.path("validation/std_io_net_kv.zig"),
.target = target,
.optimize = optimize,
});
validate_std_io_net_kv_mod.addImport("marionette", mod);
validate_std_io_net_kv_mod.addImport("examples", examples_mod);
run_examples_mod.addImport("std_io_net_kv_validation", validate_std_io_net_kv_mod);
const run_validate_std_io_net_kv = addValidation(
b,
validate_std_io_net_kv_mod,
"validate-std-io-net-kv",
"Run the std.Io.net KV capability validation",
);
const validate_kv_compat_mod = b.createModule(.{
.root_source_file = b.path("validation/kv_compat.zig"),
.target = target,
.optimize = optimize,
});
validate_kv_compat_mod.addImport("marionette", mod);
validate_kv_compat_mod.addImport("examples", examples_mod);
const run_validate_kv_compat = addValidation(
b,
validate_kv_compat_mod,
"validate-kv-compat",
"Run the KV compatibility lifecycle (WAL, compaction rename, recovery) under Marionette",
);
const seed_sweep_count = b.option(
usize,
"seed-sweep-count",
"Number of deterministic seeds to run per nightly scenario",
) orelse 1_000;
const seed_sweep_options = b.addOptions();
seed_sweep_options.addOption(usize, "count", seed_sweep_count);
const seed_sweep_mod = b.createModule(.{
.root_source_file = b.path("validation/nightly_seed_sweep.zig"),
.target = target,
.optimize = optimize,
});
seed_sweep_mod.addImport("marionette", mod);
seed_sweep_mod.addImport("examples", examples_mod);
seed_sweep_mod.addOptions("seed_sweep_options", seed_sweep_options);
_ = addValidation(
b,
seed_sweep_mod,
"seed-sweep",
"Run the bounded long-running deterministic seed sweep",
);
const tests_mod = b.createModule(.{
.root_source_file = b.path("tests/root.zig"),
.target = target,
.optimize = optimize,
});
tests_mod.addImport("marionette", mod);
tests_mod.addImport("examples", examples_mod);
const tests = b.addTest(.{ .root_module = tests_mod });
const run_tests = b.addRunArtifact(tests);
const tidy = build_support.addTidyStep(b, b.path("src/main_tidy.zig"), .{
.paths = &.{ "src", "examples", "tests", "validation" },
.target = target,
.optimize = optimize,
});
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_example_tests.step);
test_step.dependOn(&run_tests.step);
test_step.dependOn(&run_validate_bounded_queue.step);
test_step.dependOn(&run_validate_std_io_net_kv.step);
test_step.dependOn(&run_validate_kv_compat.step);
test_step.dependOn(&tidy.step);
const run_tidy_consumer_test = b.addSystemCommand(&.{
b.graph.zig_exe,
"build",
"test",
"--build-file",
b.pathFromRoot("tests/tidy_consumer/build.zig"),
"--cache-dir",
b.pathFromRoot(".zig-cache/tidy-consumer"),
});
test_step.dependOn(&run_tidy_consumer_test.step);
// The fiber overflow diagnostics are POSIX-only and their subprocess
// test must execute the crash binary it builds, so wire it only when
// building natively for a guard-page target.
const guard_page_target = switch (target.result.os.tag) {
.linux, .macos, .freebsd, .netbsd, .openbsd, .dragonfly, .illumos => true,
else => false,
};
if (guard_page_target and target.query.isNative()) {
const overflow_crash_mod = b.createModule(.{
.root_source_file = b.path("tests/fiber_overflow_crash.zig"),
.target = target,
.optimize = optimize,
});
overflow_crash_mod.addImport("marionette", mod);
const overflow_crash_exe = b.addExecutable(.{
.name = "marionette-fiber-overflow-crash",
.root_module = overflow_crash_mod,
});
const overflow_check_mod = b.createModule(.{
.root_source_file = b.path("tests/fiber_overflow_check.zig"),
.target = target,
.optimize = optimize,
});
const overflow_check_exe = b.addExecutable(.{
.name = "marionette-fiber-overflow-check",
.root_module = overflow_check_mod,
});
const run_overflow_check = b.addRunArtifact(overflow_check_exe);
run_overflow_check.addArtifactArg(overflow_crash_exe);
run_overflow_check.addArg("overflow");
test_step.dependOn(&run_overflow_check.step);
const run_non_fiber_check = b.addRunArtifact(overflow_check_exe);
run_non_fiber_check.addArtifactArg(overflow_crash_exe);
run_non_fiber_check.addArg("non-fiber-fault");
test_step.dependOn(&run_non_fiber_check.step);
}
}