From ed2d27add43ab96584365e7ae40b5bf28ff9e07b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 28 Aug 2025 12:14:16 -0700 Subject: [PATCH] add build.zig and test --- build.zig | 25 +++++++++++++++++++++++++ test.zig | 6 ++++++ 2 files changed, 31 insertions(+) create mode 100644 build.zig create mode 100644 test.zig diff --git a/build.zig b/build.zig new file mode 100644 index 0000000000000000000000000000000000000000..96a7b60258161a9fa241c3fb7ba16a3197589f39 --- /dev/null +++ b/build.zig @@ -0,0 +1,25 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; + const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; + + const mod = b.addModule("cookies", .{ .root_source_file = b.path("cookies.zig") }); + + const tests = b.addTest(.{ + .root_source_file = b.path("test.zig"), + .target = target, + .optimize = mode, + }); + tests.root_module.addImport("cookies", mod); + tests.root_module.link_libc = true; + tests.use_llvm = !disable_llvm; + tests.use_lld = !disable_llvm; + + const test_step = b.step("test", "Run all library tests"); + const tests_run = b.addRunArtifact(tests); + tests_run.setCwd(b.path(".")); + tests_run.has_side_effects = true; + test_step.dependOn(&tests_run.step); +} diff --git a/test.zig b/test.zig new file mode 100644 index 0000000000000000000000000000000000000000..3ba54e86bc78d1706ffb4efddb36d37a55e30d88 --- /dev/null +++ b/test.zig @@ -0,0 +1,6 @@ +const std = @import("std"); +const cookies = @import("cookies"); + +test { + std.testing.refAllDecls(cookies); +} -- 2.54.0