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.Optimize = .debug;
9 const target = b.graph.host;
10
11 if (builtin.os.tag == .wasi) return;
12 if (builtin.os.tag == .windows) return;
13
14 // ld and lld do not agree on the format of the .hash section
15 // Tracked by https://codeberg.org/ziglang/zig/issues/35746
16 if (builtin.cpu.arch == .s390x and builtin.os.tag == .linux) return;
17
18 const lib = b.addLibrary(.{
19 .linkage = .dynamic,
20 .name = "lib",
21 .version = .{ .major = 1, .minor = 0, .patch = 0 },
22 .root_module = b.createModule(.{
23 .root_source_file = b.path("lib.zig"),
24 .optimize = optimize,
25 .target = target,
26 }),
27 });
28
29 const main = b.addExecutable(.{
30 .name = "main",
31 .root_module = b.createModule(.{
32 .root_source_file = b.path("main.zig"),
33 .optimize = optimize,
34 .target = target,
35 }),
36 });
37
38 const run = b.addRunArtifact(main);
39 run.addArtifactArg(lib);
40 run.skip_foreign_checks = true;
41 run.expectExitCode(0);
42
43 test_step.dependOn(&run.step);
44}