Skip to content

Commit 3338e0e

Browse files
committed
update build script
1 parent 75552a4 commit 3338e0e

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

build.zig

+29-31
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,34 @@ pub fn build(b: *std.Build) !void {
2929
test_step.dependOn(&run_fuzz_unit_tests.step);
3030

3131
if (b.option(bool, "fuzz", "Generate an executable for AFL++ (persistent mode) plus extra tooling") orelse false) {
32-
return;
32+
const scripty_fuzz = b.addExecutable(.{
33+
.name = "scriptyfuzz",
34+
.root_source_file = b.path("src/fuzz.zig"),
35+
.target = target,
36+
.optimize = .Debug,
37+
.single_threaded = true,
38+
});
39+
40+
scripty_fuzz.root_module.addImport("scripty", scripty);
41+
b.installArtifact(scripty_fuzz);
42+
43+
const afl_obj = b.addObject(.{
44+
.name = "scriptyfuzz-afl",
45+
.root_source_file = b.path("src/fuzz/afl.zig"),
46+
// .target = b.resolveTargetQuery(.{ .cpu_model = .baseline }),
47+
.target = target,
48+
.optimize = .Debug,
49+
});
50+
51+
afl_obj.root_module.addImport("scripty", scripty);
52+
afl_obj.root_module.stack_check = false; // not linking with compiler-rt
53+
afl_obj.root_module.link_libc = true; // afl runtime depends on libc
54+
// afl_obj.root_module.fuzz = true;
55+
56+
const afl_fuzz = afl.addInstrumentedExe(b, target, optimize, afl_obj);
57+
b.getInstallStep().dependOn(
58+
&b.addInstallBinFile(afl_fuzz, "scriptyfuzz-afl").step,
59+
);
60+
// fuzz.dependOn(&b.addInstallArtifact(afl_fuzz, .{}).step);
3361
}
34-
35-
const scripty_fuzz = b.addExecutable(.{
36-
.name = "scriptyfuzz",
37-
.root_source_file = b.path("src/fuzz.zig"),
38-
.target = target,
39-
.optimize = .Debug,
40-
.single_threaded = true,
41-
});
42-
43-
scripty_fuzz.root_module.addImport("scripty", scripty);
44-
b.installArtifact(scripty_fuzz);
45-
46-
const afl_obj = b.addObject(.{
47-
.name = "scriptyfuzz-afl",
48-
.root_source_file = b.path("src/fuzz/afl.zig"),
49-
// .target = b.resolveTargetQuery(.{ .cpu_model = .baseline }),
50-
.target = target,
51-
.optimize = .Debug,
52-
});
53-
54-
afl_obj.root_module.addImport("scripty", scripty);
55-
afl_obj.root_module.stack_check = false; // not linking with compiler-rt
56-
afl_obj.root_module.link_libc = true; // afl runtime depends on libc
57-
// afl_obj.root_module.fuzz = true;
58-
59-
const afl_fuzz = afl.addInstrumentedExe(b, target, optimize, afl_obj);
60-
b.getInstallStep().dependOn(
61-
&b.addInstallBinFile(afl_fuzz, "scriptyfuzz-afl").step,
62-
);
63-
// fuzz.dependOn(&b.addInstallArtifact(afl_fuzz, .{}).step);
6462
}

0 commit comments

Comments
 (0)