-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
50 lines (41 loc) · 2.03 KB
/
Copy pathbuild.zig
File metadata and controls
50 lines (41 loc) · 2.03 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
const std = @import("std");
const deps_mod = @import("build/deps.zig");
const examples_mod = @import("build/examples.zig");
const fuzz_mod = @import("build/fuzz.zig");
const soak_mod = @import("build/soak.zig");
const interop_mod = @import("build/interop.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Shadow simulator build: forwards into the zquic dependency so its
// syscall layer routes through libc and Shadow's LD_PRELOAD shim can
// intercept. See `### Shadow simulator` in the README.
const shadow = b.option(bool, "shadow", "Build for the Shadow simulator (forwards to zquic, links libc on Linux)") orelse false;
const d = deps_mod.createDeps(b, target, optimize, .{ .shadow = shadow });
const test_filter = b.option([]const u8, "test-filter", "Only run tests whose name contains this substring");
const unit_tests = b.addTest(.{
.root_module = d.mod,
.filters = if (test_filter) |f| &.{f} else &.{},
});
const run_unit_tests = b.addRunArtifact(unit_tests);
_ = fuzz_mod.addFuzzStep(b, d.mod);
_ = soak_mod.addSoakStep(b, target, optimize);
const bench_mod = b.createModule(.{
.root_source_file = b.path("bench/bench.zig"),
.target = target,
.optimize = .ReleaseFast,
});
bench_mod.addImport("zig_libp2p", d.mod);
const bench_exe = b.addExecutable(.{
.name = "zig-libp2p-bench",
.root_module = bench_mod,
});
b.installArtifact(bench_exe);
const run_bench = b.addRunArtifact(bench_exe);
const bench_step = b.step("bench", "Run microbenchmarks for hot paths (#19)");
bench_step.dependOn(&run_bench.step);
const test_step = b.step("test", "Run library unit tests, smoke-run most examples, compile TCP status example");
test_step.dependOn(&run_unit_tests.step);
_ = examples_mod.addExamples(b, d, target, optimize, test_step, &run_unit_tests.step);
_ = interop_mod.addInteropSteps(b, d, target, optimize);
}