aboutsummaryrefslogtreecommitdiff
path: root/test/standalone/coff_dwarf/build.zig
blob: cd3a53ec8c303d6faa14675703cf57b89e6fcebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const std = @import("std");

/// This tests the path where DWARF information is embedded in a COFF binary
pub fn build(b: *std.Build) void {
    const host = b.graph.host;

    switch (host.result.cpu.arch) {
        .aarch64,
        .x86,
        .x86_64,
        => {},
        else => return,
    }

    const test_step = b.step("test", "Test it");
    b.default_step = test_step;

    const optimize: std.builtin.OptimizeMode = .Debug;
    const target = switch (host.result.os.tag) {
        .windows => host,
        else => b.resolveTargetQuery(.{ .os_tag = .windows }),
    };

    const exe = b.addExecutable(.{
        .name = "main",
        .root_module = b.createModule(.{
            .root_source_file = b.path("main.zig"),
            .optimize = optimize,
            .target = target,
        }),
    });

    const lib = b.addLibrary(.{
        .linkage = .dynamic,
        .name = "shared_lib",
        .root_module = b.createModule(.{
            .root_source_file = null,
            .optimize = optimize,
            .target = target,
            .link_libc = true,
        }),
    });
    lib.root_module.addCSourceFile(.{ .file = b.path("shared_lib.c"), .flags = &.{"-gdwarf"} });
    exe.root_module.linkLibrary(lib);

    const run = b.addRunArtifact(exe);
    run.expectExitCode(0);
    run.skip_foreign_checks = true;

    test_step.dependOn(&run.step);
}