const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // The public `zbench` module: what dependents @import. const zbench_module = b.addModule("zbench", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }); // The `zbench_build` module: build-time helpers (add_bench_step). // Dependents @import("zbench_build") from their build.zig. _ = b.addModule("zbench_build", .{ .root_source_file = b.path("src/build_helper.zig"), }); // Internal unit tests: `zig build test`. const tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }), }); const run_tests = b.addRunArtifact(tests); const test_step = b.step("test", "Run zbench unit tests"); test_step.dependOn(&run_tests.step); // Convenience: build the bundled example. const example_exe = b.addExecutable(.{ .name = "zbench-example", .root_module = b.createModule(.{ .root_source_file = b.path("examples/bench/main.zig"), .target = target, .optimize = .ReleaseFast, }), }); example_exe.root_module.addImport("zbench", zbench_module); b.installArtifact(example_exe); const run_example = b.addRunArtifact(example_exe); if (b.args) |args| run_example.addArgs(args); const example_step = b.step("example", "Run the bundled example benchmarks"); example_step.dependOn(&run_example.step); }