From 6f59071043981d555ba4af2141f5fe0eec96cf45 Mon Sep 17 00:00:00 2001 From: Matheus Catarino Date: Sun, 25 Aug 2024 16:58:11 -0300 Subject: [PATCH] updated to zig v0.13.0/v0.14.0-dev --- .github/workflows/build.yml | 6 ++--- .gitignore | 3 +-- README.md | 2 +- build.zig | 53 ++++++++++++++++++++----------------- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8d70eb..17f3ee1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,8 @@ jobs: target: [x86_64, x86, aarch64] runs-on: ${{ matrix.runs-on }} steps: - - uses: actions/checkout@v3 - - uses: goto-bus-stop/setup-zig@v2 - with: - version: 0.11.0 + - uses: actions/checkout@v4 + - uses: mlugg/setup-zig@v1 - uses: baptiste0928/cargo-install@v2 with: crate: xwin diff --git a/.gitignore b/.gitignore index c97b60b..15c3249 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,7 @@ Cargo.lock *.pdb # Zig build -zig-cache/ -zig-out/ +*zig-*/ # Xwin Unpack .xwin/ diff --git a/README.md b/README.md index bee04c7..99b5a6f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This experiment is for testing purposes only. Possibly to make it easier to buil ## Requirements - [xwin](https://github.com/Jake-Shadle/xwin) -- [zig 0.11 or higher](https://ziglang.org/download) +- [zig 0.13.x or higher](https://ziglang.org/download) ## Testing diff --git a/build.zig b/build.zig index d2f1a8b..40c6cd8 100644 --- a/build.zig +++ b/build.zig @@ -36,12 +36,15 @@ fn buildExe(b: *std.Build, info: BuildInfo) void { // zig w/ msvc no has libcxx support // https://github.com/ziglang/zig/issues/5312 .cpp => { - exe.addCSourceFile(.{ .file = .{ .path = info.filepath }, .flags = &.{ - "-Wall", - "-Wextra", - } }); + exe.addCSourceFile(.{ + .file = b.path(info.filepath), + .flags = &.{ + "-Wall", + "-Wextra", + }, + }); exe.want_lto = false; - if (exe.target.getAbi() == .msvc) { + if (exe.rootModuleTarget().abi == .msvc) { xWin(b, exe); exe.linkLibC(); } else { @@ -49,16 +52,19 @@ fn buildExe(b: *std.Build, info: BuildInfo) void { } }, .c => { - exe.addCSourceFile(.{ .file = .{ .path = info.filepath }, .flags = &.{ - "-Wall", - "-Wextra", - } }); - if (exe.target.getAbi() == .msvc) { + exe.addCSourceFile(.{ + .file = b.path(info.filepath), + .flags = &.{ + "-Wall", + "-Wextra", + }, + }); + if (exe.rootModuleTarget().abi == .msvc) { xWin(b, exe); } exe.linkLibC(); }, - .zig => exe.root_src = .{ .path = info.filepath }, + .zig => exe.root_module.root_source_file = b.path(info.filepath), } b.installArtifact(exe); @@ -81,7 +87,7 @@ const BuildInfo = struct { cpp, zig, }, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, fn filename(self: BuildInfo) []const u8 { @@ -90,8 +96,7 @@ const BuildInfo = struct { } }; fn xWin(b: *std.Build, exe: *std.Build.Step.Compile) void { - const target = (std.zig.system.NativeTargetInfo.detect(exe.target) catch unreachable).target; - const arch: []const u8 = switch (target.cpu.arch) { + const arch: []const u8 = switch (exe.rootModuleTarget().cpu.arch) { .x86_64 => "x64", .x86 => "x86", .arm, .armeb => "arm", @@ -99,16 +104,16 @@ fn xWin(b: *std.Build, exe: *std.Build.Step.Compile) void { else => @panic("Unsupported Architecture"), }; - exe.setLibCFile(.{ .path = sdkPath("/libc.txt") }); - exe.addSystemIncludePath(.{ .path = sdkPath("/.xwin/crt/include") }); - exe.addSystemIncludePath(.{ .path = sdkPath("/.xwin/sdk/include") }); - exe.addSystemIncludePath(.{ .path = sdkPath("/.xwin/sdk/include/10.0.22000/cppwinrt") }); - exe.addSystemIncludePath(.{ .path = sdkPath("/.xwin/sdk/include/10.0.22000/ucrt") }); - exe.addSystemIncludePath(.{ .path = sdkPath("/.xwin/sdk/include/10.0.22000/um") }); - exe.addSystemIncludePath(.{ .path = sdkPath("/.xwin/sdk/include/10.0.22000/shared") }); - exe.addLibraryPath(.{ .path = b.fmt(sdkPath("/.xwin/crt/lib/{s}"), .{arch}) }); - exe.addLibraryPath(.{ .path = b.fmt(sdkPath("/.xwin/sdk/lib/ucrt/{s}"), .{arch}) }); - exe.addLibraryPath(.{ .path = b.fmt(sdkPath("/.xwin/sdk/lib/um/{s}"), .{arch}) }); + exe.setLibCFile(.{ .cwd_relative = sdkPath("/libc.txt") }); + exe.addSystemIncludePath(.{ .cwd_relative = sdkPath("/.xwin/crt/include") }); + exe.addSystemIncludePath(.{ .cwd_relative = sdkPath("/.xwin/sdk/include") }); + exe.addSystemIncludePath(.{ .cwd_relative = sdkPath("/.xwin/sdk/include/10.0.26100/cppwinrt") }); + exe.addSystemIncludePath(.{ .cwd_relative = sdkPath("/.xwin/sdk/include/10.0.26100/ucrt") }); + exe.addSystemIncludePath(.{ .cwd_relative = sdkPath("/.xwin/sdk/include/10.0.26100/um") }); + exe.addSystemIncludePath(.{ .cwd_relative = sdkPath("/.xwin/sdk/include/10.0.26100/shared") }); + exe.addLibraryPath(.{ .cwd_relative = b.fmt(sdkPath("/.xwin/crt/lib/{s}"), .{arch}) }); + exe.addLibraryPath(.{ .cwd_relative = b.fmt(sdkPath("/.xwin/sdk/lib/ucrt/{s}"), .{arch}) }); + exe.addLibraryPath(.{ .cwd_relative = b.fmt(sdkPath("/.xwin/sdk/lib/um/{s}"), .{arch}) }); } fn sdkPath(comptime suffix: []const u8) []const u8 { if (suffix[0] != '/') @compileError("relToPath requires an absolute path!");