build: update to Zig 0.12

This commit is contained in:
Isaac Freund
2024-03-07 16:19:22 +01:00
parent 680cb8ef69
commit 033cad47bf
51 changed files with 285 additions and 271 deletions

View File

@ -109,7 +109,7 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output {
.previous => link.prev.?,
};
}
return @fieldParentPtr(Output, "active_link", link);
return @as(*Output, @fieldParentPtr("active_link", link));
} else if (std.meta.stringToEnum(wlr.OutputLayout.Direction, str)) |direction| { // Spacial direction
var focus_box: wlr.Box = undefined;
server.root.output_layout.getBox(seat.focused_output.?.wlr_output, &focus_box);

View File

@ -15,7 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
const os = std.os;
const posix = std.posix;
const c = @import("../c.zig");
const util = @import("../util.zig");
@ -35,23 +35,26 @@ pub fn spawn(
const child_args = [_:null]?[*:0]const u8{ "/bin/sh", "-c", args[1], null };
const pid = os.fork() catch {
const pid = posix.fork() catch {
out.* = try std.fmt.allocPrint(util.gpa, "fork/execve failed", .{});
return Error.Other;
};
if (pid == 0) {
process.cleanupChild();
const pid2 = os.fork() catch c._exit(1);
if (pid2 == 0) os.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1);
const pid2 = posix.fork() catch c._exit(1);
if (pid2 == 0) {
posix.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1);
}
c._exit(0);
}
// Wait the intermediate child.
const ret = os.waitpid(pid, 0);
if (!os.W.IFEXITED(ret.status) or
(os.W.IFEXITED(ret.status) and os.W.EXITSTATUS(ret.status) != 0))
const ret = posix.waitpid(pid, 0);
if (!posix.W.IFEXITED(ret.status) or
(posix.W.IFEXITED(ret.status) and posix.W.EXITSTATUS(ret.status) != 0))
{
out.* = try std.fmt.allocPrint(util.gpa, "fork/execve failed", .{});
return Error.Other;