mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
Add a standalone test for Windows resource file compilation
This commit is contained in:
parent
28f6559947
commit
01fc6a05ef
@ -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"),
|
||||
|
||||
33
test/standalone/windows_resources/build.zig
Normal file
33
test/standalone/windows_resources/build.zig
Normal file
@ -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);
|
||||
}
|
||||
5
test/standalone/windows_resources/main.zig
Normal file
5
test/standalone/windows_resources/main.zig
Normal file
@ -0,0 +1,5 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
||||
}
|
||||
1
test/standalone/windows_resources/res/hello.bin
Normal file
1
test/standalone/windows_resources/res/hello.bin
Normal file
@ -0,0 +1 @@
|
||||
abcdefg
|
||||
1
test/standalone/windows_resources/res/sub/sub.rc
Normal file
1
test/standalone/windows_resources/res/sub/sub.rc
Normal file
@ -0,0 +1 @@
|
||||
2 RCDATA hello.bin
|
||||
BIN
test/standalone/windows_resources/res/zig.ico
Normal file
BIN
test/standalone/windows_resources/res/zig.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 175 KiB |
40
test/standalone/windows_resources/res/zig.rc
Normal file
40
test/standalone/windows_resources/res/zig.rc
Normal file
@ -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"
|
||||
Loading…
x
Reference in New Issue
Block a user