master
1const std = @import("std");
2
3/// This tests the path where DWARF information is embedded in a COFF binary
4pub fn build(b: *std.Build) void {
5 const host = b.graph.host;
6
7 // https://github.com/ziglang/zig/issues/25471
8 if (host.result.os.tag == .freebsd) return;
9
10 switch (host.result.cpu.arch) {
11 .aarch64,
12 .x86,
13 .x86_64,
14 => {},
15 else => return,
16 }
17
18 const test_step = b.step("test", "Test it");
19 b.default_step = test_step;
20
21 const optimize: std.builtin.OptimizeMode = .Debug;
22 const target = switch (host.result.os.tag) {
23 .windows => host,
24 else => b.resolveTargetQuery(.{ .os_tag = .windows }),
25 };
26
27 const exe = b.addExecutable(.{
28 .name = "main",
29 .root_module = b.createModule(.{
30 .root_source_file = b.path("main.zig"),
31 .optimize = optimize,
32 .target = target,
33 }),
34 });
35
36 const lib = b.addLibrary(.{
37 .linkage = .dynamic,
38 .name = "shared_lib",
39 .root_module = b.createModule(.{
40 .root_source_file = null,
41 .optimize = optimize,
42 .target = target,
43 .link_libc = true,
44 }),
45 });
46 lib.root_module.addCSourceFile(.{ .file = b.path("shared_lib.c"), .flags = &.{"-gdwarf"} });
47 exe.root_module.linkLibrary(lib);
48
49 const run = b.addRunArtifact(exe);
50 run.expectExitCode(0);
51 run.skip_foreign_checks = true;
52
53 test_step.dependOn(&run.step);
54}