From aab3c0181c2f727c72d342ab0d69f161992a6d9b Mon Sep 17 00:00:00 2001 From: Loris Cro Date: Fri, 26 Jul 2024 14:52:55 +0200 Subject: [PATCH] make fuzzing deps lazy --- build.zig | 17 ++++++++++------- build.zig.zon | 5 +++-- src/cli.zig | 26 +++++++++++++++++++------- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/build.zig b/build.zig index ccf841d..8771c43 100644 --- a/build.zig +++ b/build.zig @@ -31,11 +31,18 @@ pub fn build(b: *std.Build) !void { setupTestStep(b, target, superhtml); setupCliTool(b, target, optimize, options, superhtml, folders, lsp); setupWasmStep(b, optimize, options, superhtml, lsp); - setupFuzzStep(b, target, superhtml); setupCheckStep(b, target, optimize, options, superhtml, folders, lsp); if (version == .tag) { setupReleaseStep(b, options, superhtml, folders, lsp); } + + if (b.option( + bool, + "fuzz", + "Generate an executable for AFL++ (persistent mode) plus extra tooling", + ) orelse false) { + setupFuzzStep(b, target, superhtml); + } } fn setupCheckStep( @@ -103,10 +110,6 @@ fn setupFuzzStep( target: std.Build.ResolvedTarget, superhtml: *std.Build.Module, ) void { - const fuzz = b.step( - "fuzz", - "Generate an executable for AFL++ (persistent mode) plus extra tooling", - ); const afl_obj = b.addObject(.{ .name = "superfuzz-afl", .root_source_file = b.path("src/fuzz/afl.zig"), @@ -134,7 +137,7 @@ fn setupFuzzStep( }); super_fuzz.root_module.addImport("superhtml", superhtml); - fuzz.dependOn(&b.addInstallArtifact(super_fuzz, .{}).step); + b.installArtifact(super_fuzz); const supergen = b.addExecutable(.{ .name = "supergen", @@ -144,7 +147,7 @@ fn setupFuzzStep( }); supergen.root_module.addImport("superhtml", superhtml); - fuzz.dependOn(&b.addInstallArtifact(supergen, .{}).step); + b.installArtifact(supergen); } fn setupCliTool( diff --git a/build.zig.zon b/build.zig.zon index f4c0b0d..e212fc0 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -11,12 +11,13 @@ .hash = "12209cde192558f8b3dc098ac2330fc2a14fdd211c5433afd33085af75caa9183147", }, .scripty = .{ - .url = "git+https://github.com/kristoff-it/scripty#141af2a88ed45a8e0fa5762ae7acddb8e747d8c9", - .hash = "12209226037051a39081e33137927031e378d76420088fd57cf0eab0fa98474456b4", + .url = "git+https://github.com/kristoff-it/scripty#3338e0ed9e1ffd869acadca9673c87894b3ba38c", + .hash = "1220a064034f7b797618a1fc5c2f3596b5dbfe4f309afd0798cfc77bbea6bb5eb672", }, .@"zig-afl-kit" = .{ .url = "git+https://github.com/kristoff-it/zig-afl-kit#f003bfe714f2964c90939fdc940d5993190a66ec", .hash = "1220f2d8402bb7bbc4786b9c0aad73910929ea209cbd3b063842371d68abfed33c1e", + .lazy = true, }, }, .paths = .{ diff --git a/src/cli.zig b/src/cli.zig index 1a528c3..678410b 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -51,7 +51,15 @@ pub fn panic( std.process.exit(1); } -pub const Command = enum { fmt, lsp, help, version }; +pub const Command = enum { + check, + interface, + i, // alias for interface + fmt, + lsp, + help, + version, +}; pub fn main() !void { var gpa_impl: std.heap.GeneralPurposeAllocator(.{}) = .{}; @@ -72,10 +80,13 @@ pub fn main() !void { if (cmd == .lsp) lsp_mode = true; _ = switch (cmd) { + // .check => check_exe.run(gpa, args[2..]), + // .interface, .i => interface_exe.run(gpa, args[2..]), .fmt => fmt_exe.run(gpa, args[2..]), .lsp => lsp_exe.run(gpa, args[2..]), .help => fatalHelp(), .version => printVersion(), + else => fatalHelp(), } catch |err| fatal("unexpected error: {s}\n", .{@errorName(err)}); } @@ -95,14 +106,15 @@ fn printVersion() noreturn { fn fatalHelp() noreturn { fatal( - \\Usage: super COMMAND [OPTIONS] + \\Usage: superhtml COMMAND [OPTIONS] \\ \\Commands: - // \\ check Check HTML documents for syntax errors - \\ fmt Format HTML documents - \\ lsp Start the Super LSP - \\ help Show this menu and exit - \\ version Print Super's version and exit + \\ check Check documents for syntax errors + \\ interface, i Print a SuperHTML template's interface + \\ fmt Format documents + \\ lsp Start the Super LSP + \\ help Show this menu and exit + \\ version Print Super's version and exit \\ \\General Options: \\ --help, -h Print command specific usage