1const std = @import("std");
2const deps = @import("./deps.zig");
3
4pub fn build(b: *std.Build) void {
5 const target = b.standardTargetOptions(.{});
6 const mode = b.option(std.builtin.OptimizeMode, "mode", "") orelse .Debug;
7 const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false;
8
9 const exe = b.addExecutable(.{
10 .name = "zig-inquirer",
11 .root_module = b.createModule(.{
12 .root_source_file = b.path("src/main.zig"),
13 .target = target,
14 .optimize = mode,
15 }),
16 });
17 deps.addAllTo(exe);
18 exe.root_module.link_libc = true;
19 exe.use_llvm = !disable_llvm;
20 exe.use_lld = !disable_llvm;
21 b.installArtifact(exe);
22
23 const run_cmd = b.addRunArtifact(exe);
24 run_cmd.step.dependOn(b.getInstallStep());
25 if (b.args) |args| {
26 run_cmd.addArgs(args);
27 }
28
29 const run_step = b.step("run", "Run the app");
30 run_step.dependOn(&run_cmd.step);
31
32 const tests = b.addTest(.{
33 .root_module = b.createModule(.{
34 .root_source_file = b.path("test.zig"),
35 .target = target,
36 .optimize = mode,
37 }),
38 });
39 deps.addAllTo(tests);
40 tests.root_module.link_libc = true;
41 tests.use_llvm = !disable_llvm;
42 tests.use_lld = !disable_llvm;
43 b.getInstallStep().dependOn(&tests.step);
44
45 const test_step = b.step("test", "Run all library tests");
46 const tests_run = b.addRunArtifact(tests);
47 tests_run.setCwd(b.path("."));
48 tests_run.has_side_effects = true;
49 test_step.dependOn(&tests_run.step);
50}