diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2023-09-05 23:33:38 -0700 |
|---|---|---|
| committer | Ryan Liptak <squeek502@hotmail.com> | 2023-09-17 03:09:45 -0700 |
| commit | 01fc6a05ef4b4de3d351ebbc64f35eef7f3afa7a (patch) | |
| tree | bf48afc68d45939d62f1b9dfe96689450ecfe045 | |
| parent | 28f6559947b7acd2ef3c983c90e1215a0d75ae15 (diff) | |
| download | zig-01fc6a05ef4b4de3d351ebbc64f35eef7f3afa7a.tar.gz zig-01fc6a05ef4b4de3d351ebbc64f35eef7f3afa7a.zip | |
Add a standalone test for Windows resource file compilation
| -rw-r--r-- | test/standalone.zig | 4 | ||||
| -rw-r--r-- | test/standalone/windows_resources/build.zig | 33 | ||||
| -rw-r--r-- | test/standalone/windows_resources/main.zig | 5 | ||||
| -rw-r--r-- | test/standalone/windows_resources/res/hello.bin | 1 | ||||
| -rw-r--r-- | test/standalone/windows_resources/res/sub/sub.rc | 1 | ||||
| -rw-r--r-- | test/standalone/windows_resources/res/zig.ico | bin | 0 -> 179271 bytes | |||
| -rw-r--r-- | test/standalone/windows_resources/res/zig.rc | 40 |
7 files changed, 84 insertions, 0 deletions
diff --git a/test/standalone.zig b/test/standalone.zig index 22b9dfba49..87022f8bfc 100644 --- a/test/standalone.zig +++ b/test/standalone.zig @@ -195,6 +195,10 @@ pub const build_cases = [_]BuildCase{ .import = @import("standalone/load_dynamic_library/build.zig"), }, .{ + .build_root = "test/standalone/windows_resources", + .import = @import("standalone/windows_resources/build.zig"), + }, + .{ .build_root = "test/standalone/windows_spawn", .import = @import("standalone/windows_spawn/build.zig"), }, diff --git a/test/standalone/windows_resources/build.zig b/test/standalone/windows_resources/build.zig new file mode 100644 index 0000000000..4c2854ffc9 --- /dev/null +++ b/test/standalone/windows_resources/build.zig @@ -0,0 +1,33 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const test_step = b.step("test", "Test it"); + b.default_step = test_step; + + const native_target: std.zig.CrossTarget = .{}; + const cross_target = .{ + .cpu_arch = .x86_64, + .os_tag = .windows, + .abi = .gnu, + }; + + add(b, native_target, test_step); + add(b, cross_target, test_step); +} + +fn add(b: *std.Build, target: std.zig.CrossTarget, test_step: *std.Build.Step) void { + const exe = b.addExecutable(.{ + .name = "zig_resource_test", + .root_source_file = .{ .path = "main.zig" }, + .target = target, + .optimize = .Debug, + }); + exe.addWin32ResourceFile(.{ + .file = .{ .path = "res/zig.rc" }, + .flags = &.{"/c65001"}, // UTF-8 code page + }); + + _ = exe.getEmittedBin(); + + test_step.dependOn(&exe.step); +} diff --git a/test/standalone/windows_resources/main.zig b/test/standalone/windows_resources/main.zig new file mode 100644 index 0000000000..f92e18124b --- /dev/null +++ b/test/standalone/windows_resources/main.zig @@ -0,0 +1,5 @@ +const std = @import("std"); + +pub fn main() !void { + std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); +} diff --git a/test/standalone/windows_resources/res/hello.bin b/test/standalone/windows_resources/res/hello.bin new file mode 100644 index 0000000000..dda6eb4b7b --- /dev/null +++ b/test/standalone/windows_resources/res/hello.bin @@ -0,0 +1 @@ +abcdefg
\ No newline at end of file diff --git a/test/standalone/windows_resources/res/sub/sub.rc b/test/standalone/windows_resources/res/sub/sub.rc new file mode 100644 index 0000000000..b15ce30604 --- /dev/null +++ b/test/standalone/windows_resources/res/sub/sub.rc @@ -0,0 +1 @@ +2 RCDATA hello.bin diff --git a/test/standalone/windows_resources/res/zig.ico b/test/standalone/windows_resources/res/zig.ico Binary files differnew file mode 100644 index 0000000000..64610cc332 --- /dev/null +++ b/test/standalone/windows_resources/res/zig.ico diff --git a/test/standalone/windows_resources/res/zig.rc b/test/standalone/windows_resources/res/zig.rc new file mode 100644 index 0000000000..88503a0f6a --- /dev/null +++ b/test/standalone/windows_resources/res/zig.rc @@ -0,0 +1,40 @@ +#define ICO_ID 1 + +// Nothing from windows.h is used in this .rc file, +// but it's common to include it within a .rc file +// so this makes sure that it can be found on +// all platforms. +#include "windows.h" + +ICO_ID ICON "zig.ico" + +1 VERSIONINFO + FILEVERSION 1L,0,0,2 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x1L + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "Zig" + VALUE "FileDescription", "My cool zig program" + VALUE "FileVersion", "1.0.0.1" + VALUE "InternalName", "zig-ico.exe" + VALUE "LegalCopyright", "(c) no one" + VALUE "OriginalFilename", "zig-ico.exe" + VALUE "ProductName", "Zig but with an icon" + VALUE "ProductVersion", "1.0.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#include "sub/sub.rc" |
