authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-03-23 08:30:09-07:00
committergravatar for ypsvlq@gmail.comElaine Gibson <ypsvlq@gmail.com> 2024-03-27 10:06:06+00:00
logbad9efbcc140ce5e9837ef06652610636593c1d0
tree4b62c7ee0d140903ff5d3689295e79300f8ee464
parent4e428415e575c183050d8108af697ac8aeb9a493

Add standalone test for all possible MinGW exe entry points


6 files changed, 99 insertions(+), 0 deletions(-)

test/standalone.zig+4
......@@ -195,6 +195,10 @@ pub const build_cases = [_]BuildCase{
195195 .build_root = "test/standalone/windows_resources",
196196 .import = @import("standalone/windows_resources/build.zig"),
197197 },
198 .{
199 .build_root = "test/standalone/windows_entry_points",
200 .import = @import("standalone/windows_entry_points/build.zig"),
201 },
198202 .{
199203 .build_root = "test/standalone/windows_spawn",
200204 .import = @import("standalone/windows_spawn/build.zig"),
test/standalone/windows_entry_points/build.zig created+68
......@@ -0,0 +1,68 @@
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 .target = target,
17 .optimize = .Debug,
18 .link_libc = true,
19 });
20 exe.addCSourceFile(.{ .file = .{ .path = "main.c" } });
21
22 _ = exe.getEmittedBin();
23 test_step.dependOn(&exe.step);
24 }
25
26 {
27 const exe = b.addExecutable(.{
28 .name = "wmain",
29 .target = target,
30 .optimize = .Debug,
31 .link_libc = true,
32 });
33 exe.mingw_unicode_entry_point = true;
34 exe.addCSourceFile(.{ .file = .{ .path = "wmain.c" } });
35
36 _ = exe.getEmittedBin();
37 test_step.dependOn(&exe.step);
38 }
39
40 {
41 const exe = b.addExecutable(.{
42 .name = "winmain",
43 .target = target,
44 .optimize = .Debug,
45 .link_libc = true,
46 });
47 // Note: `exe.subsystem = .Windows;` is not necessary
48 exe.addCSourceFile(.{ .file = .{ .path = "winmain.c" } });
49
50 _ = exe.getEmittedBin();
51 test_step.dependOn(&exe.step);
52 }
53
54 {
55 const exe = b.addExecutable(.{
56 .name = "wwinmain",
57 .target = target,
58 .optimize = .Debug,
59 .link_libc = true,
60 });
61 exe.mingw_unicode_entry_point = true;
62 // Note: `exe.subsystem = .Windows;` is not necessary
63 exe.addCSourceFile(.{ .file = .{ .path = "wwinmain.c" } });
64
65 _ = exe.getEmittedBin();
66 test_step.dependOn(&exe.step);
67 }
68}
test/standalone/windows_entry_points/main.c created+6
......@@ -0,0 +1,6 @@
1#include <stdio.h>
2
3int main(int argc, char *argv[ ], char *envp[ ]) {
4 printf("hello from main\n");
5 return 0;
6}
\ No newline at end of file
test/standalone/windows_entry_points/winmain.c created+7
......@@ -0,0 +1,7 @@
1#include <windows.h>
2#include <stdio.h>
3
4int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
5 printf("hello from WinMain\n");
6 return 0;
7}
\ No newline at end of file
test/standalone/windows_entry_points/wmain.c created+7
......@@ -0,0 +1,7 @@
1#include <stdio.h>
2#include <windows.h>
3
4int wmain(int argc, wchar_t *argv[ ], wchar_t *envp[ ]) {
5 printf("hello from wmain\n");
6 return 0;
7}
\ No newline at end of file
test/standalone/windows_entry_points/wwinmain.c created+7
......@@ -0,0 +1,7 @@
1#include <windows.h>
2#include <stdio.h>
3
4int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PWSTR cmdline, int cmdshow) {
5 printf("hello from wWinMain\n");
6 return 0;
7}
\ No newline at end of file