From 0b580fcbfbd9535d3ebfd5bdeb273071646280ec Mon Sep 17 00:00:00 2001 From: Trevor-Strong <76170333+Trevor-Strong@users.noreply.github.com> Date: Sat, 27 Jan 2024 09:56:26 -0600 Subject: [PATCH 1/5] Add test step and update 'source_file' to 'root_source_file' --- build.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 3033c0a7..4ac17381 100644 --- a/build.zig +++ b/build.zig @@ -1,7 +1,25 @@ const std = @import("std"); pub fn build(b: *std.Build) void { + const optimize = b.standardOptimizeOption(.{}); + const target = b.standardTargetOptions(.{}); + _ = b.addModule("zigwin32", .{ - .source_file = .{ .path = "win32.zig" }, + .root_source_file = .{ .path = "win32.zig" }, + .optimize = optimize, + .target = target, + }); + + const tests = b.addTest(.{ + .root_source_file = .{ .path = "win32.zig" }, + .optimize = optimize, + .target = target, + .link_libc = true, }); + + const run_tests = b.addRunArtifact(tests); + + const test_step = b.step("test", "Run tests"); + + test_step.dependOn(&run_tests.step); } From 759dc6757d48734c141b572657c8026bc73847b7 Mon Sep 17 00:00:00 2001 From: Trevor-Strong <76170333+Trevor-Strong@users.noreply.github.com> Date: Sat, 27 Jan 2024 09:56:42 -0600 Subject: [PATCH 2/5] Add build.zig.zon --- build.zig.zon | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 build.zig.zon diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 00000000..fe53ff6e --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,15 @@ +.{ + .name = "zigwin32", + .version = "0.0.0", + .min_zig_version = "0.11.0", + .dependencies = .{}, + .paths = .{ + "win32", + "win32.zig", + "build.zig", + "build.zig.zon", + "zig.mod", + "LICENSE", + "README.md", + }, +} From d442cc6657c88ca1b0a2f1a1aacb8743071985f1 Mon Sep 17 00:00:00 2001 From: Trevor-Strong <76170333+Trevor-Strong@users.noreply.github.com> Date: Sat, 27 Jan 2024 09:57:36 -0600 Subject: [PATCH 3/5] Restore UNICODE option after ziglang issue 7979 closed --- win32/zig.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/win32/zig.zig b/win32/zig.zig index c9a291bc..15f63362 100644 --- a/win32/zig.zig +++ b/win32/zig.zig @@ -7,8 +7,8 @@ const root = @import("root"); pub const UnicodeMode = enum { ansi, wide, unspecified }; // WORKAROUND: https://github.com/ziglang/zig/issues/7979 // using root.UNICODE causes an erroneous dependency loop, so I'm hardcoding to .wide for now -pub const unicode_mode = UnicodeMode.wide; -//pub const unicode_mode : UnicodeMode = if (@hasDecl(root, "UNICODE")) (if (root.UNICODE) .wide else .ansi) else .unspecified; +// pub const unicode_mode = UnicodeMode.wide; +pub const unicode_mode: UnicodeMode = if (@hasDecl(root, "UNICODE")) (if (root.UNICODE) .wide else .ansi) else .unspecified; pub const L = std.unicode.utf8ToUtf16LeStringLiteral; @@ -50,8 +50,8 @@ pub const Guid = extern union { const big_endian_hex_offsets = [16]u6{ 0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34 }; const little_endian_hex_offsets = [16]u6{ 6, 4, 2, 0, 11, 9, 16, 14, 19, 21, 24, 26, 28, 30, 32, 34 }; const hex_offsets = switch (builtin.target.cpu.arch.endian()) { - .Big => big_endian_hex_offsets, - .Little => little_endian_hex_offsets, + .big => big_endian_hex_offsets, + .little => little_endian_hex_offsets, }; pub fn initString(s: []const u8) Guid { @@ -81,8 +81,8 @@ fn decodeHexByte(hex: [2]u8) u8 { test "Guid" { try testing.expect(std.mem.eql(u8, switch (builtin.target.cpu.arch.endian()) { - .Big => "\x01\x23\x45\x67\x89\xAB\xEF\x10\x32\x54\x76\x98\xba\xdc\xfe\x91", - .Little => "\x67\x45\x23\x01\xAB\x89\x10\xEF\x32\x54\x76\x98\xba\xdc\xfe\x91", + .big => "\x01\x23\x45\x67\x89\xAB\xEF\x10\x32\x54\x76\x98\xba\xdc\xfe\x91", + .little => "\x67\x45\x23\x01\xAB\x89\x10\xEF\x32\x54\x76\x98\xba\xdc\xfe\x91", }, &Guid.initString("01234567-89AB-EF10-3254-7698badcfe91").Bytes)); } From 2a0a59a92bb4bcb0fc9aa8722829ece7314041e3 Mon Sep 17 00:00:00 2001 From: Trevor-Strong <76170333+Trevor-Strong@users.noreply.github.com> Date: Sat, 27 Jan 2024 09:57:36 -0600 Subject: [PATCH 4/5] Restore UNICODE option after ziglang issue 7979 closed --- win32/zig.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/win32/zig.zig b/win32/zig.zig index c9a291bc..15f63362 100644 --- a/win32/zig.zig +++ b/win32/zig.zig @@ -7,8 +7,8 @@ const root = @import("root"); pub const UnicodeMode = enum { ansi, wide, unspecified }; // WORKAROUND: https://github.com/ziglang/zig/issues/7979 // using root.UNICODE causes an erroneous dependency loop, so I'm hardcoding to .wide for now -pub const unicode_mode = UnicodeMode.wide; -//pub const unicode_mode : UnicodeMode = if (@hasDecl(root, "UNICODE")) (if (root.UNICODE) .wide else .ansi) else .unspecified; +// pub const unicode_mode = UnicodeMode.wide; +pub const unicode_mode: UnicodeMode = if (@hasDecl(root, "UNICODE")) (if (root.UNICODE) .wide else .ansi) else .unspecified; pub const L = std.unicode.utf8ToUtf16LeStringLiteral; @@ -50,8 +50,8 @@ pub const Guid = extern union { const big_endian_hex_offsets = [16]u6{ 0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34 }; const little_endian_hex_offsets = [16]u6{ 6, 4, 2, 0, 11, 9, 16, 14, 19, 21, 24, 26, 28, 30, 32, 34 }; const hex_offsets = switch (builtin.target.cpu.arch.endian()) { - .Big => big_endian_hex_offsets, - .Little => little_endian_hex_offsets, + .big => big_endian_hex_offsets, + .little => little_endian_hex_offsets, }; pub fn initString(s: []const u8) Guid { @@ -81,8 +81,8 @@ fn decodeHexByte(hex: [2]u8) u8 { test "Guid" { try testing.expect(std.mem.eql(u8, switch (builtin.target.cpu.arch.endian()) { - .Big => "\x01\x23\x45\x67\x89\xAB\xEF\x10\x32\x54\x76\x98\xba\xdc\xfe\x91", - .Little => "\x67\x45\x23\x01\xAB\x89\x10\xEF\x32\x54\x76\x98\xba\xdc\xfe\x91", + .big => "\x01\x23\x45\x67\x89\xAB\xEF\x10\x32\x54\x76\x98\xba\xdc\xfe\x91", + .little => "\x67\x45\x23\x01\xAB\x89\x10\xEF\x32\x54\x76\x98\xba\xdc\xfe\x91", }, &Guid.initString("01234567-89AB-EF10-3254-7698badcfe91").Bytes)); } From 66e2b2ec0fdf7b44ec59f94054fddbd4f93c72bc Mon Sep 17 00:00:00 2001 From: Trevor-Strong <76170333+Trevor-Strong@users.noreply.github.com> Date: Sat, 27 Jan 2024 10:11:30 -0600 Subject: [PATCH 5/5] Removed comment lines referencing UNICODE option issue --- win32/zig.zig | 3 --- 1 file changed, 3 deletions(-) diff --git a/win32/zig.zig b/win32/zig.zig index 15f63362..e8c489e6 100644 --- a/win32/zig.zig +++ b/win32/zig.zig @@ -5,9 +5,6 @@ const testing = std.testing; const root = @import("root"); pub const UnicodeMode = enum { ansi, wide, unspecified }; -// WORKAROUND: https://github.com/ziglang/zig/issues/7979 -// using root.UNICODE causes an erroneous dependency loop, so I'm hardcoding to .wide for now -// pub const unicode_mode = UnicodeMode.wide; pub const unicode_mode: UnicodeMode = if (@hasDecl(root, "UNICODE")) (if (root.UNICODE) .wide else .ansi) else .unspecified; pub const L = std.unicode.utf8ToUtf16LeStringLiteral;