diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2026-02-18 16:24:32 -0600 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2026-02-18 16:24:32 -0600 |
| commit | 83889f7f2d72004414f02f88e978b62bed885bfd (patch) | |
| tree | 8b197c61e17e98b26946d97dc2286e042e7e5f8c /build.zig | |
| download | sitter-main.tar.gz | |
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..8a09085 --- /dev/null +++ b/build.zig @@ -0,0 +1,42 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + const lib = b.addLibrary(.{ + .name = "sitter", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/root.zig"), + .target = target, + .optimize = optimize, + }), + }); + + b.installArtifact(lib); + const test_step = b.step("test", "Run unit tests"); + + for ([_][]const u8{ + "src/root.zig", + "src/iterator.zig", + }) |file| + unit_test(b,target,optimize,test_step,file); +} + +fn unit_test( + b: *std.Build, + target: std.Build.ResolvedTarget, + optimize: std.builtin.OptimizeMode, + test_step: *std.Build.Step, + fname: []const u8, +) void { + const unit = b.addTest(.{ + .root_module = b.createModule(.{ + .root_source_file = b.path(fname), + .target = target, + .optimize = optimize, + }), + .test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple }, + }); + const unit_tests = b.addRunArtifact(unit); + test_step.dependOn(&unit_tests.step); +} |
