diff --git a/test/standalone.zig b/test/standalone.zig index 22b9dfba49..87022f8bfc 100644 --- a/test/standalone.zig +++ b/test/standalone.zig @@ -194,6 +194,10 @@ pub const build_cases = [_]BuildCase{ .build_root = "test/standalone/load_dynamic_library", .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 new file mode 100644 index 0000000000..64610cc332 Binary files /dev/null and b/test/standalone/windows_resources/res/zig.ico differ 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"