Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
59 lines (49 loc) · 1.75 KB
/
Copy pathbuild.zig
File metadata and controls
59 lines (49 loc) · 1.75 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 mod = b.addModule("csio", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
const mod_tests = b.addTest(.{
.root_module = mod,
});
const run_mod_tests = b.addRunArtifact(mod_tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
const fuzz = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuzz.zig"),
.target = target,
.optimize = optimize,
}),
// Required for running fuzz tests
// https://github.com/ziglang/zig/issues/23423
.use_llvm = true,
});
const run_fuzz = b.addRunArtifact(fuzz);
const fuzz_step = b.step("fuzz", "run fuzz tests");
fuzz_step.dependOn(&run_fuzz.step);
const Example = enum {
direct_io,
tcp,
};
const example_option = b.option(Example, "example", "Example to run, default is direct_io") orelse Example.direct_io;
const example_step = b.step("example", "Run example");
const example = b.addExecutable(.{
.name = b.fmt("{s}_example", .{@tagName(example_option)}),
.root_module = b.createModule(.{
.root_source_file = b.path(
b.fmt("examples/{s}.zig", .{@tagName(example_option)}),
),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "csio", .module = mod },
},
}),
});
const example_run = b.addRunArtifact(example);
example_step.dependOn(&example_run.step);
}