chore: project scaffold and build wiring

Initial Zig 0.16 build script wiring the public `zbench` module, the
`zbench_build` helper module for downstream `build.zig` files, an
internal `test` step, and an `example` step that compiles and runs the
bundled benchmark suite.
This commit is contained in:
2026-05-21 08:12:45 +03:00
commit be72707042
3 changed files with 63 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.zig-cache/
zig-out/

48
build.zig Normal file
View File

@@ -0,0 +1,48 @@
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);
}

13
build.zig.zon Normal file
View File

@@ -0,0 +1,13 @@
.{
.name = .zbench,
.version = "0.1.0",
.fingerprint = 0xbb819b3c1603b711,
.minimum_zig_version = "0.16.0",
.paths = .{
"build.zig",
"build.zig.zon",
"src",
"examples",
},
.dependencies = .{},
}