1const std = @import("std");
 2const builtin = @import("builtin");
 3
 4pub fn build(b: *std.Build) void {
 5    const test_step = b.step("test", "Test it");
 6    b.default_step = test_step;
 7
 8    const optimize: std.builtin.OptimizeMode = .Debug;
 9    const target = b.graph.host;
10
11    if (builtin.os.tag == .wasi) return;
12
13    const lib = b.addLibrary(.{
14        .linkage = .dynamic,
15        .name = "add",
16        .version = .{ .major = 1, .minor = 0, .patch = 0 },
17        .root_module = b.createModule(.{
18            .root_source_file = b.path("add.zig"),
19            .optimize = optimize,
20            .target = target,
21        }),
22    });
23
24    const main = b.addExecutable(.{
25        .name = "main",
26        .root_module = b.createModule(.{
27            .root_source_file = b.path("main.zig"),
28            .optimize = optimize,
29            .target = target,
30        }),
31    });
32
33    const run = b.addRunArtifact(main);
34    run.addArtifactArg(lib);
35    run.skip_foreign_checks = true;
36    run.expectExitCode(0);
37
38    test_step.dependOn(&run.step);
39}