1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const mode = b.option(std.builtin.OptimizeMode, "mode", "") orelse .Debug;
6 const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false;
7
8 const mod = b.addModule("cookies", .{ .root_source_file = b.path("cookies.zig") });
9
10 const tests = b.addTest(.{
11 .root_module = b.createModule(.{
12 .root_source_file = b.path("test.zig"),
13 .target = target,
14 .optimize = mode,
15 }),
16 });
17 tests.root_module.addImport("cookies", mod);
18 tests.root_module.link_libc = true;
19 tests.use_llvm = !disable_llvm;
20 tests.use_lld = !disable_llvm;
21 b.getInstallStep().dependOn(&tests.step);
22
23 const test_step = b.step("test", "Run all library tests");
24 const tests_run = b.addRunArtifact(tests);
25 tests_run.setCwd(b.path("."));
26 tests_run.has_side_effects = true;
27 test_step.dependOn(&tests_run.step);
28}