Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
55 lines (55 loc) · 2.9 KB
/
Copy pathbuild.zig
File metadata and controls
55 lines (55 loc) · 2.9 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("jevlin", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize });
const tests = b.addTest(.{ .root_module = module });
const run = b.addRunArtifact(tests);
const test_step = b.step("test", "Run offline contract and fault tests");
test_step.dependOn(&run.step);
const fuzz_target = b.option(enum { all, parser, encoder }, "fuzz-target", "Select a standalone fuzz oracle") orelse .all;
const fuzz_tests = b.addTest(.{
.filters = switch (fuzz_target) {
.all => &.{},
.parser => &.{"fuzz parser and typed decoder"},
.encoder => &.{"fuzz request encoder"},
},
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuzz.zig"),
.target = target,
.optimize = optimize,
// Zig 0.16.0's fuzz runner uses the wrong error-return trace type.
// Disable only return tracing; safety checks and fuzz instrumentation stay on.
.error_tracing = b.option(bool, "fuzz-error-tracing", "Enable error-return traces in the standalone fuzz target") orelse false,
}),
// The default x86 backend produced an empty PC table with -ffuzz on 0.16.0.
.use_llvm = true,
});
b.step("fuzz", "Run bounded parser/encoder mutation campaigns without sockets").dependOn(&b.addRunArtifact(fuzz_tests).step);
const example = b.addExecutable(.{ .name = "jevlin-triage", .root_module = b.createModule(.{
.root_source_file = b.path("examples/triage.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "jevlin", .module = module }},
}) });
b.installArtifact(example);
const live = b.addRunArtifact(example);
live.has_side_effects = true;
b.step("live", "Run one billable API call using TYPESAFE_API_KEY").dependOn(&live.step);
const fmt = b.addFmt(.{ .paths = &.{ "src", "examples", "build.zig" }, .check = true });
const check = b.step("check", "Check formatting, tests, and example compilation");
check.dependOn(&fmt.step);
check.dependOn(test_step);
check.dependOn(&example.step);
const examples = b.step("examples", "Run offline public API examples and compatibility contract");
for ([_][]const u8{ "structured", "errors_and_buffers", "parallel", "api_contract" }) |name| {
const offline = b.addExecutable(.{ .name = name, .root_module = b.createModule(.{
.root_source_file = b.path(b.fmt("examples/{s}.zig", .{name})),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "jevlin", .module = module }},
}) });
examples.dependOn(&b.addRunArtifact(offline).step);
}
check.dependOn(examples);
}