From 889eaabd82419be40dcb5de057f1f4fc20f78d3a Mon Sep 17 00:00:00 2001 From: Mathew Gordon Date: Tue, 18 Jun 2024 02:35:55 -0600 Subject: [PATCH] Update to Zig 0.13 --- .github/workflows/push.yaml | 2 +- zig/build.zig | 14 ++++---------- zig/build.zig.zon | 4 ++-- zig/lib/appimage.zig | 7 +++---- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 5823ea9..2ea0ec7 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -12,7 +12,7 @@ jobs: - uses: actions/setup-go@v4 - uses: goto-bus-stop/setup-zig@v2 with: - version: 0.12.0 + version: 0.13.0 - name: Install deps run: | diff --git a/zig/build.zig b/zig/build.zig index 36e4034..ff5257b 100644 --- a/zig/build.zig +++ b/zig/build.zig @@ -15,16 +15,10 @@ pub const LinkOptions = struct { use_libdeflate: bool = true, }; -pub inline fn thisDir() []const u8 { - return comptime std.fs.path.dirname(@src().file) orelse unreachable; -} - // Although this function looks imperative, note that its job is to // declaratively construct a build graph that will be executed by an external // runner. pub fn build(b: *std.Build) void { - const prefix = thisDir(); - // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options @@ -49,15 +43,15 @@ pub fn build(b: *std.Build) void { .name = "aisap", // In this case the main source file is merely a path, however, in more // complicated build scripts, this could be a generated file. - .root_source_file = .{ .path = prefix ++ "/lib/c_api.zig" }, + .root_source_file = b.path("lib/c_api.zig"), .target = target, .optimize = optimize, }); - lib.addIncludePath(.{ .path = prefix ++ "/../include" }); + lib.addIncludePath(b.path("../include")); const known_folders_module = b.addModule("known-folders", .{ - .root_source_file = .{ .path = "known-folders/known-folders.zig" }, + .root_source_file = b.path("known-folders/known-folders.zig"), }); const squashfuse_dep = b.dependency("squashfuse", .{ @@ -110,7 +104,7 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. This only builds the test executable // but does not run it. const main_tests = b.addTest(.{ - .root_source_file = .{ .path = "lib.zig" }, + .root_source_file = b.path("lib.zig"), .target = target, .optimize = optimize, }); diff --git a/zig/build.zig.zon b/zig/build.zig.zon index cbc65d0..bfd06cd 100644 --- a/zig/build.zig.zon +++ b/zig/build.zig.zon @@ -5,11 +5,11 @@ .dependencies = .{ .squashfuse = .{ .url = "https://github.com/mgord9518/squashfuse-zig/archive/refs/tags/continuous.tar.gz", - .hash = "1220558ae6e303460037e63523a874f06c434f109897c75d0f5a3512ffe44fffaa23", + .hash = "12209f047e1b7dcaaa3335cb2ae4167b1062f308c409d8be24ce99edd17e1a0fc7d1", }, .fuse = .{ .url = "https://github.com/mgord9518/libfuse-zig/archive/refs/tags/continuous.tar.gz", - .hash = "1220c5f5640bdf55d07c1cd67986a39df1c41fff641f58e975a7cf6a470ae5b2461b", + .hash = "12205592f7dc4b4c7256abd657a50bd9784459a0e9b8bfe8b0d1bbcc153a6d0f650a", }, }, } diff --git a/zig/lib/appimage.zig b/zig/lib/appimage.zig index 31c1836..afa1b16 100644 --- a/zig/lib/appimage.zig +++ b/zig/lib/appimage.zig @@ -7,7 +7,6 @@ const span = std.mem.span; const expect = std.testing.expect; const os = std.os; const posix = std.posix; -const ChildProcess = std.ChildProcess; const Md5 = std.crypto.hash.Md5; @@ -1161,7 +1160,7 @@ pub const AppImage = struct { ); defer ai.allocator.free(offset_string); - var proc = ChildProcess.init(&[_][]const u8{ + var proc = std.process.Child.init(&[_][]const u8{ "squashfuse", offset_string, ai.path, @@ -1221,7 +1220,7 @@ pub const AppImage = struct { pub fn unmount(ai: *AppImage) !void { if (ai.mount_dir) |mount_dir| { - var umount = ChildProcess.init(&[_][]const u8{ + var umount = std.process.Child.init(&[_][]const u8{ "fusermount", "-u", mount_dir, @@ -1388,7 +1387,7 @@ pub fn bwrap(allocator: std.mem.Allocator, args: []const []const u8) !void { const stdout = std.io.getStdOut(); const stderr = std.io.getStdErr(); - var child = ChildProcess.init(args, allocator); + var child = std.process.Child.init(args, allocator); child.stdout = stdout; child.stderr = stderr; _ = try child.spawnAndWait();