1const std = @import("std");
  2
  3pub fn build(b: *std.Build) void {
  4    const test_step = b.step("test", "Test it");
  5    b.default_step = test_step;
  6
  7    const target = b.resolveTargetQuery(.{
  8        .cpu_arch = .x86_64,
  9        .os_tag = .windows,
 10        .abi = .gnu,
 11    });
 12
 13    {
 14        const exe = b.addExecutable(.{
 15            .name = "main",
 16            .root_module = b.createModule(.{
 17                .root_source_file = null,
 18                .target = target,
 19                .optimize = .Debug,
 20                .link_libc = true,
 21            }),
 22        });
 23        exe.root_module.addCSourceFile(.{ .file = b.path("main.c") });
 24
 25        _ = exe.getEmittedBin();
 26        test_step.dependOn(&exe.step);
 27    }
 28
 29    {
 30        const exe = b.addExecutable(.{
 31            .name = "wmain",
 32            .root_module = b.createModule(.{
 33                .root_source_file = null,
 34                .target = target,
 35                .optimize = .Debug,
 36                .link_libc = true,
 37            }),
 38        });
 39        exe.mingw_unicode_entry_point = true;
 40        exe.root_module.addCSourceFile(.{ .file = b.path("wmain.c") });
 41
 42        _ = exe.getEmittedBin();
 43        test_step.dependOn(&exe.step);
 44    }
 45
 46    {
 47        const exe = b.addExecutable(.{
 48            .name = "winmain",
 49            .root_module = b.createModule(.{
 50                .root_source_file = null,
 51                .target = target,
 52                .optimize = .Debug,
 53                .link_libc = true,
 54            }),
 55        });
 56        // Note: `exe.subsystem = .windows;` is not necessary
 57        exe.root_module.addCSourceFile(.{ .file = b.path("winmain.c") });
 58
 59        _ = exe.getEmittedBin();
 60        test_step.dependOn(&exe.step);
 61    }
 62
 63    {
 64        const exe = b.addExecutable(.{
 65            .name = "wwinmain",
 66            .root_module = b.createModule(.{
 67                .root_source_file = null,
 68                .target = target,
 69                .optimize = .Debug,
 70                .link_libc = true,
 71            }),
 72        });
 73        exe.mingw_unicode_entry_point = true;
 74        // Note: `exe.subsystem = .windows;` is not necessary
 75        exe.root_module.addCSourceFile(.{ .file = b.path("wwinmain.c") });
 76
 77        _ = exe.getEmittedBin();
 78        test_step.dependOn(&exe.step);
 79    }
 80
 81    {
 82        const exe = b.addExecutable(.{
 83            .name = "zig_main",
 84            .root_module = b.createModule(.{
 85                .root_source_file = b.path("main.zig"),
 86                .target = target,
 87                .optimize = .Debug,
 88            }),
 89        });
 90
 91        _ = exe.getEmittedBin();
 92        test_step.dependOn(&exe.step);
 93    }
 94
 95    {
 96        const exe = b.addExecutable(.{
 97            .name = "zig_main_link_libc",
 98            .root_module = b.createModule(.{
 99                .root_source_file = b.path("main.zig"),
100                .target = target,
101                .optimize = .Debug,
102                .link_libc = true,
103            }),
104        });
105
106        _ = exe.getEmittedBin();
107        test_step.dependOn(&exe.step);
108    }
109
110    {
111        const exe = b.addExecutable(.{
112            .name = "zig_wwinmain",
113            .root_module = b.createModule(.{
114                .root_source_file = b.path("wwinmain.zig"),
115                .target = target,
116                .optimize = .Debug,
117            }),
118        });
119        exe.mingw_unicode_entry_point = true;
120        // Note: `exe.subsystem = .windows;` is not necessary
121
122        _ = exe.getEmittedBin();
123        test_step.dependOn(&exe.step);
124    }
125
126    {
127        const exe = b.addExecutable(.{
128            .name = "zig_wwinmain_link_libc",
129            .root_module = b.createModule(.{
130                .root_source_file = b.path("wwinmain.zig"),
131                .target = target,
132                .optimize = .Debug,
133                .link_libc = true,
134            }),
135        });
136        exe.mingw_unicode_entry_point = true;
137        // Note: `exe.subsystem = .windows;` is not necessary
138
139        _ = exe.getEmittedBin();
140        test_step.dependOn(&exe.step);
141    }
142}