Add a standalone test for Windows resource file compilation

This commit is contained in:
Ryan Liptak
2023-09-05 23:33:38 -07:00
parent 28f6559947
commit 01fc6a05ef
7 changed files with 84 additions and 0 deletions
+4
View File
@@ -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"),
@@ -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);
}
@@ -0,0 +1,5 @@
const std = @import("std");
pub fn main() !void {
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
}
@@ -0,0 +1 @@
abcdefg
@@ -0,0 +1 @@
2 RCDATA hello.bin
Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

@@ -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"