Soc Virnyl Estela: 7 build: update to Zig 0.12.0 build: update to Zig 0.13.0 build: cleanup migration to Zig 0.13.0 gitignore: add .zig-cache to ignore options: add strip and llvm options build: update commit hash and sources of zig-spoon fork replace FlagIt with std.process.ArgIteratorPosix 16 files changed, 128 insertions(+), 116 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~leon_plickat/public-inbox/patches/53502/mbox | git am -3Learn more about email & git
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- build.zig | 48 +++++++++++++++++++----------------------------- build.zig.zon | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 build.zig.zon diff --git a/build.zig b/build.zig index 73b6778..ff36053 100644 --- a/build.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const mem = std.mem; -const Scanner = @import("deps/zig-wayland/build.zig").Scanner; +const Scanner = @import("zig-wayland").Scanner; pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); @@ -22,22 +22,11 @@ pub fn build(b: *std.Build) !void { scanner.generate("wl_seat", 8); scanner.generate("wl_output", 4); - const wayland = b.createModule(.{ .source_file = scanner.result }); - const xkbcommon = b.createModule(.{ - .source_file = .{ .path = "deps/zig-xkbcommon/src/xkbcommon.zig" }, - }); - const pixman = b.createModule(.{ - .source_file = .{ .path = "deps/zig-pixman/pixman.zig" }, - }); - const spoon = b.createModule(.{ - .source_file = .{ .path = "deps/zig-spoon/import.zig" }, - }); - const fcft = b.createModule(.{ - .source_file = .{ .path = "deps/zig-fcft/fcft.zig" }, - .dependencies = &.{ - .{ .name = "pixman", .module = pixman }, - }, - }); + const wayland = b.dependency("zig-wayland", .{}).module("wayland"); + const xkbcommon = b.dependency("zig-xkbcommon", .{}).module("xkbcommon"); + const pixman = b.dependency("zig-pixman", .{}).module("pixman"); + const spoon = b.dependency("zig-spoon", .{}).module("spoon"); + const fcft = b.dependency("zig-fcft", .{}).module("fcft"); const wayprompt_cli = b.addExecutable(.{ .name = "wayprompt", @@ -45,19 +34,20 @@ pub fn build(b: *std.Build) !void { .target = target, .optimize = optimize, }); + wayprompt_cli.root_module.addOptions("build_options", options); wayprompt_cli.linkLibC(); - wayprompt_cli.addModule("wayland", wayland); + wayprompt_cli.root_module.addImport("wayland", wayland); wayprompt_cli.linkSystemLibrary("wayland-client"); wayprompt_cli.linkSystemLibrary("wayland-cursor"); scanner.addCSource(wayprompt_cli); - wayprompt_cli.addModule("fcft", fcft); + wayprompt_cli.root_module.addImport("fcft", fcft); wayprompt_cli.linkSystemLibrary("fcft"); - wayprompt_cli.addModule("xkbcommon", xkbcommon); + wayprompt_cli.root_module.addImport("xkbcommon", xkbcommon); wayprompt_cli.linkSystemLibrary("xkbcommon"); - wayprompt_cli.addModule("pixman", pixman); + wayprompt_cli.root_module.addImport("pixman", pixman); wayprompt_cli.linkSystemLibrary("pixman-1"); - wayprompt_cli.addModule("spoon", spoon); - wayprompt_cli.addOptions("build_options", options); + wayprompt_cli.root_module.addImport("spoon", spoon); + wayprompt_cli.root_module.addOptions("build_options", options); wayprompt_cli.pie = pie; b.installArtifact(wayprompt_cli); @@ -68,18 +58,18 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); wayprompt_pinentry.linkLibC(); - wayprompt_pinentry.addModule("wayland", wayland); + wayprompt_pinentry.root_module.addImport("wayland", wayland); wayprompt_pinentry.linkSystemLibrary("wayland-client"); wayprompt_pinentry.linkSystemLibrary("wayland-cursor"); scanner.addCSource(wayprompt_pinentry); - wayprompt_pinentry.addModule("fcft", fcft); + wayprompt_pinentry.root_module.addImport("fcft", fcft); wayprompt_pinentry.linkSystemLibrary("fcft"); - wayprompt_pinentry.addModule("xkbcommon", xkbcommon); + wayprompt_pinentry.root_module.addImport("xkbcommon", xkbcommon); wayprompt_pinentry.linkSystemLibrary("xkbcommon"); - wayprompt_pinentry.addModule("pixman", pixman); + wayprompt_pinentry.root_module.addImport("pixman", pixman); wayprompt_pinentry.linkSystemLibrary("pixman-1"); - wayprompt_pinentry.addModule("spoon", spoon); - wayprompt_pinentry.addOptions("build_options", options); + wayprompt_pinentry.root_module.addImport("spoon", spoon); + wayprompt_pinentry.root_module.addOptions("build_options", options); wayprompt_pinentry.pie = pie; b.installArtifact(wayprompt_pinentry); diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..1d35dc3 --- /dev/null @@ -0,0 +1,27 @@ +.{ + .name = "wayprompt", + .version = "0.2.0", + .paths = .{""}, + .dependencies = .{ + .@"zig-wayland" = .{ + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.1.0.tar.gz", + .hash = "1220b0f8f822c1625af7aae4cb3ab2c4ec1a4c0e99ef32867b2a8d88bb070b3e7f6d", + }, + .@"zig-fcft" = .{ + .url = "https://git.sr.ht/~novakane/zig-fcft/archive/7881eac29bf0d9de4df1fc31df380e8f5f620585.tar.gz", + .hash = "1220cc15677890989c54713a7c9d90b6999ad21bdb78fe411b016335daa6cea9f9dd", + }, + .@"zig-xkbcommon" = .{ + .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.1.0.tar.gz", + .hash = "1220733d45419f34cc6c24a2a1bba4da2eb2f0319a846546ac99eb86b51d7ec7637c", + }, + .@"zig-spoon" = .{ + .url = "https://git.sr.ht/~uncomfy/zig-spoon/archive/0b66d77f5a89c4136daa13b02cebe945feebc668.tar.gz", + .hash = "1220733d45419f34cc6c24a2a1bba4da2eb2f0319a846546ac99eb86b51d7ec7637c", + }, + .@"zig-pixman" = .{ + .url = "https://codeberg.org/ifreund/zig-pixman/archive/v0.1.0.tar.gz", + .hash = "122014eeb4600a059bdcfe1c864862f17e6d5e4237e3bb7d6818f2a5583f6f4eb843", + }, + }, +} -- 2.45.2
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- build.zig | 8 ++++---- build.zig.zon | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build.zig b/build.zig index ff36053..2c34d69 100644 --- a/build.zig @@ -22,7 +22,7 @@ pub fn build(b: *std.Build) !void { scanner.generate("wl_seat", 8); scanner.generate("wl_output", 4); - const wayland = b.dependency("zig-wayland", .{}).module("wayland"); + const wayland = b.createModule(.{ .root_source_file = scanner.result }); const xkbcommon = b.dependency("zig-xkbcommon", .{}).module("xkbcommon"); const pixman = b.dependency("zig-pixman", .{}).module("pixman"); const spoon = b.dependency("zig-spoon", .{}).module("spoon"); @@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void { const wayprompt_cli = b.addExecutable(.{ .name = "wayprompt", - .root_source_file = .{ .path = "src/wayprompt-cli.zig" }, + .root_source_file = b.path("src/wayprompt-cli.zig"), .target = target, .optimize = optimize, }); @@ -53,7 +53,7 @@ pub fn build(b: *std.Build) !void { const wayprompt_pinentry = b.addExecutable(.{ .name = "pinentry-wayprompt", - .root_source_file = .{ .path = "src/wayprompt-pinentry.zig" }, + .root_source_file = b.path("src/wayprompt-pinentry.zig"), .target = target, .optimize = optimize, }); @@ -74,7 +74,7 @@ pub fn build(b: *std.Build) !void { b.installArtifact(wayprompt_pinentry); const tests = b.addTest(.{ - .root_source_file = .{ .path = "src/tests.zig" }, + .root_source_file = b.path("src/tests.zig"), .target = target, .optimize = optimize, }); diff --git a/build.zig.zon b/build.zig.zon index 1d35dc3..74cf32f 100644 --- a/build.zig.zon @@ -3,25 +3,25 @@ .version = "0.2.0", .paths = .{""}, .dependencies = .{ - .@"zig-wayland" = .{ - .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.1.0.tar.gz", - .hash = "1220b0f8f822c1625af7aae4cb3ab2c4ec1a4c0e99ef32867b2a8d88bb070b3e7f6d", + .@"zig-spoon" = .{ + .url = "https://git.sr.ht/~uncomfy/zig-spoon/archive/d029a3339a0363954ca67b17d92a6f574521aebb.tar.gz", + .hash = "122052b78ad23bbe4d5fc4755359a7724a2e36ceed0c67f3cb2194ce0ead510ce22c", }, - .@"zig-fcft" = .{ - .url = "https://git.sr.ht/~novakane/zig-fcft/archive/7881eac29bf0d9de4df1fc31df380e8f5f620585.tar.gz", - .hash = "1220cc15677890989c54713a7c9d90b6999ad21bdb78fe411b016335daa6cea9f9dd", + .@"zig-pixman" = .{ + .url = "https://codeberg.org/ifreund/zig-pixman/archive/v0.2.0.tar.gz", + .hash = "12209db20ce873af176138b76632931def33a10539387cba745db72933c43d274d56", }, - .@"zig-xkbcommon" = .{ - .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.1.0.tar.gz", - .hash = "1220733d45419f34cc6c24a2a1bba4da2eb2f0319a846546ac99eb86b51d7ec7637c", + .@"zig-wayland" = .{ + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.2.0.tar.gz", + .hash = "1220687c8c47a48ba285d26a05600f8700d37fc637e223ced3aa8324f3650bf52242", }, - .@"zig-spoon" = .{ - .url = "https://git.sr.ht/~uncomfy/zig-spoon/archive/0b66d77f5a89c4136daa13b02cebe945feebc668.tar.gz", - .hash = "1220733d45419f34cc6c24a2a1bba4da2eb2f0319a846546ac99eb86b51d7ec7637c", + .@"zig-xkbcommon" = .{ + .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.2.0.tar.gz", + .hash = "1220c90b2228d65fd8427a837d31b0add83e9fade1dcfa539bb56fd06f1f8461605f", }, - .@"zig-pixman" = .{ - .url = "https://codeberg.org/ifreund/zig-pixman/archive/v0.1.0.tar.gz", - .hash = "122014eeb4600a059bdcfe1c864862f17e6d5e4237e3bb7d6818f2a5583f6f4eb843", + .@"zig-fcft" = .{ + .url = "https://git.sr.ht/~novakane/zig-fcft/archive/1.1.0.tar.gz", + .hash = "1220a4029ee3ee70d3175c69878e2b70dccd000c4324bc74ba800d8a143b7250fb38", }, }, } -- 2.45.2
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- src/Config.zig | 10 +++++----- src/Frontend.zig | 4 ++-- src/SecretBuffer.zig | 8 ++++---- src/TTY.zig | 6 +++--- src/Wayland.zig | 28 ++++++++++++++-------------- src/ini.zig | 2 +- src/wayprompt-cli.zig | 19 +++++++++---------- src/wayprompt-pinentry.zig | 21 ++++++++++++--------- 8 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/Config.zig b/src/Config.zig index 05a2602..d854ef3 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -1,7 +1,7 @@ const std = @import("std"); const mem = std.mem; const fs = std.fs; -const os = std.os; +const posix = std.posix; const fmt = std.fmt; const meta = std.meta; const math = std.math; @@ -105,7 +105,7 @@ const WaylandUi = struct { switch (@TypeOf(@field(self, field.name))) { u31, u15 => { @field(self, field.name) = fmt.parseInt(@TypeOf(@field(self, field.name)), value, 10) catch |err| { - log.err("{s}:{}: Invalid positive integer: '{s}', {}", .{ path, line, value, err }); + log.err("{s}:{}: Invalid pposixitive integer: '{s}', {}", .{ path, line, value, err }); return error.BadConfig; }; }, @@ -162,7 +162,7 @@ pub fn reset(self: *Config, alloc: mem.Allocator) void { pub fn parse(self: *Config, alloc: mem.Allocator) !void { const path = try getConfigPath(alloc); defer alloc.free(path); - os.access(path, os.R_OK) catch return; + posix.access(path, posix.R_OK) catch return; const file = try fs.cwd().openFile(path, .{}); defer file.close(); @@ -203,12 +203,12 @@ pub fn parse(self: *Config, alloc: mem.Allocator) !void { } fn getConfigPath(alloc: mem.Allocator) ![]const u8 { - if (os.getenv("XDG_CONFIG_HOME")) |xdg_config_home| { + if (posix.getenv("XDG_CONFIG_HOME")) |xdg_config_home| { return try fs.path.join(alloc, &[_][]const u8{ xdg_config_home, "wayprompt/config.ini", }); - } else if (os.getenv("HOME")) |home| { + } else if (posix.getenv("HOME")) |home| { return try fs.path.join(alloc, &[_][]const u8{ home, ".config/wayprompt/config.ini", diff --git a/src/Frontend.zig b/src/Frontend.zig index a005d06..990e65e 100644 --- a/src/Frontend.zig +++ b/src/Frontend.zig @@ -1,6 +1,6 @@ const std = @import("std"); const mem = std.mem; -const os = std.os; +const posix = std.posix; const log = std.log.scoped(.frontend); const pixman = @import("pixman"); @@ -32,7 +32,7 @@ const Implementation = union(enum) { impl: Implementation = undefined, -pub fn init(self: *Frontend, cfg: *Config) !os.fd_t { +pub fn init(self: *Frontend, cfg: *Config) !posix.fd_t { // First we try to do a Wayland. self.impl = .{ .wayland = .{} }; diff --git a/src/SecretBuffer.zig b/src/SecretBuffer.zig index 13c7e29..d3955f6 100644 --- a/src/SecretBuffer.zig +++ b/src/SecretBuffer.zig @@ -3,7 +3,7 @@ const std = @import("std"); const ascii = std.ascii; const heap = std.heap; const mem = std.mem; -const os = std.os; +const posix = std.posix; const unicode = std.unicode; const Self = @This(); @@ -27,7 +27,7 @@ pub fn init(self: *Self, alloc: mem.Allocator) !void { var attempts: usize = 0; while (attempts < 10) : (attempts += 1) { const res = mlock(self.buffer.ptr, self.buffer.len); - switch (os.errno(res)) { + switch (posix.errno(res)) { .SUCCESS => break, .AGAIN => continue, else => return error.UnexpectedError, @@ -41,8 +41,8 @@ pub fn init(self: *Self, alloc: mem.Allocator) !void { if (builtin.target.os.tag == .linux) { var attempts: usize = 0; while (attempts < 10) : (attempts += 1) { - const res = os.system.madvise(self.buffer.ptr, self.buffer.len, os.MADV.DONTDUMP); - switch (os.errno(res)) { + const res = posix.system.madvise(self.buffer.ptr, self.buffer.len, posix.MADV.DONTDUMP); + switch (posix.errno(res)) { .SUCCESS => break, .AGAIN => continue, else => return error.UnexpectedError, diff --git a/src/TTY.zig b/src/TTY.zig index cb6eb3b..0fcffb9 100644 --- a/src/TTY.zig +++ b/src/TTY.zig @@ -1,6 +1,6 @@ const std = @import("std"); const debug = std.debug; -const os = std.os; +const posix = std.posix; const io = std.io; const math = std.math; const unicode = std.unicode; @@ -42,7 +42,7 @@ term: spoon.Term = undefined, config: *Config = undefined, mode: Frontend.InterfaceMode = .none, -pub fn init(self: *TTY, cfg: *Config) !os.fd_t { +pub fn init(self: *TTY, cfg: *Config) !posix.fd_t { self.config = cfg; // Only try to fall back to TTY mode when a TTY is set. @@ -189,7 +189,7 @@ fn renderContent(self: *TTY, rc: *spoon.Term.RenderContext, str: []const u8, att } fn renderButton(self: *TTY, rc: *spoon.Term.RenderContext, comptime button: []const u8, str: []const u8, line: *usize) !void { - var first = line.*; + const first = line.*; try rc.setAttribute(.{}); try rc.moveCursorTo(line.*, 0); var it = LineIterator.from(str); diff --git a/src/Wayland.zig b/src/Wayland.zig index f8231c4..8471d8c 100644 --- a/src/Wayland.zig +++ b/src/Wayland.zig @@ -1,7 +1,7 @@ const builtin = @import("builtin"); const std = @import("std"); const ascii = std.ascii; -const os = std.os; +const posix = std.posix; const mem = std.mem; const math = std.math; const unicode = std.unicode; @@ -429,16 +429,16 @@ const Seat = struct { fn keyboardListener(_: *wl.Keyboard, event: wl.Keyboard.Event, self: *Seat) void { switch (event) { .keymap => |ev| { - defer os.close(ev.fd); + defer posix.close(ev.fd); if (ev.format != .xkb_v1) { self.w.abort(error.UnsupportedKeyboardLayoutFormat); return; } - const keymap_str = os.mmap(null, ev.size, os.PROT.READ, os.MAP.PRIVATE, ev.fd, 0) catch { + const keymap_str = posix.mmap(null, ev.size, posix.PROT.READ, posix.MAP{ .TYPE = std.os.linux.MAP_TYPE.PRIVATE }, ev.fd, 0) catch { self.w.abort(error.OutOfMemory); return; }; - defer os.munmap(keymap_str); + defer posix.munmap(keymap_str); const keymap = xkb.Keymap.newFromBuffer( self.w.xkb_context.?, keymap_str.ptr, @@ -1255,22 +1255,22 @@ const Buffer = struct { const fd = blk: { if (builtin.target.os.tag == .linux) { - break :blk try os.memfd_createZ("/wayprompt", os.linux.MFD.CLOEXEC); + break :blk try posix.memfd_createZ("/wayprompt", std.os.linux.MFD.CLOEXEC); } @compileError("patches welcome"); }; - defer os.close(fd); - try os.ftruncate(fd, size); + defer posix.close(fd); + try posix.ftruncate(fd, size); - const data = mem.bytesAsSlice(u8, try os.mmap( + const data = mem.bytesAsSlice(u8, try posix.mmap( null, size, - os.PROT.READ | os.PROT.WRITE, - os.MAP.SHARED, + posix.PROT.READ | posix.PROT.WRITE, + posix.MAP{ .TYPE = std.os.linux.MAP_TYPE.SHARED }, fd, 0, )); - errdefer os.munmap(data); + errdefer posix.munmap(data); const shm_pool = try w.shm.?.createPool(fd, size); defer shm_pool.destroy(); @@ -1300,7 +1300,7 @@ const Buffer = struct { fn deinit(self: Buffer) void { if (self.pixman_image) |p| _ = p.unref(); if (self.wl_buffer) |wb| wb.destroy(); - if (self.data) |d| os.munmap(d); + if (self.data) |d| posix.munmap(d); } fn bufferListener(_: *wl.Buffer, event: wl.Buffer.Event, self: *Buffer) void { @@ -1345,12 +1345,12 @@ xkb_context: ?*xkb.Context = undefined, exit_reason: ?anyerror = null, -pub fn init(self: *Wayland, cfg: *Config) !os.fd_t { +pub fn init(self: *Wayland, cfg: *Config) !posix.fd_t { self.config = cfg; const wayland_display = blk: { if (cfg.wayland_display) |wd| break :blk wd; - if (os.getenv("WAYLAND_DISPLAY")) |wd| break :blk wd; + if (posix.getenv("WAYLAND_DISPLAY")) |wd| break :blk wd; return error.NoWaylandDisplay; }; log.debug("trying to connect to '{s}'.", .{wayland_display}); diff --git a/src/ini.zig b/src/ini.zig index 2b2e6b9..8e22d7e 100644 --- a/src/ini.zig +++ b/src/ini.zig @@ -52,7 +52,7 @@ fn IniTok(comptime T: type) type { } // Is this line an assignment? - var eq_pos = blk: { + const eq_pos = blk: { for (buf, 0..) |char, i| { if (char == '=') { if (i == buf.len - 1) return error.InvalidLine; diff --git a/src/wayprompt-cli.zig b/src/wayprompt-cli.zig index 8705528..98c2a04 100644 --- a/src/wayprompt-cli.zig +++ b/src/wayprompt-cli.zig @@ -1,14 +1,13 @@ const std = @import("std"); -const os = std.os; +const posix = std.posix; const mem = std.mem; const heap = std.heap; const debug = std.debug; const io = std.io; const meta = std.meta; -pub const std_options = struct { - pub const logFn = @import("log.zig").log; -}; +pub const logFn = @import("log.zig").log; +pub const std_options = std.Options{ .logFn = logFn }; const logger = std.log.scoped(.wayprompt); @@ -73,9 +72,9 @@ pub fn main() !u8 { } defer if (getpin) secret.deinit(alloc); - var fds: [1]os.pollfd = .{.{ + var fds: [1]posix.pollfd = .{.{ .fd = try frontend.init(&config), - .events = os.POLL.IN, + .events = posix.POLL.IN, .revents = undefined, }}; defer frontend.deinit(); @@ -92,9 +91,9 @@ pub fn main() !u8 { } } - _ = try os.poll(&fds, -1); + _ = try posix.poll(&fds, -1); - if (fds[0].revents & os.POLL.IN != 0) { + if (fds[0].revents & posix.POLL.IN != 0) { const ev = try frontend.handleEvent(); if (ev != .none) { try handleEvent(ev, &ret); @@ -177,7 +176,7 @@ const FlagIt = struct { fn parseCmdFlags() !void { const alloc = arena.allocator(); - var it = FlagIt.new(&os.argv); + var it = FlagIt.new(&std.os.argv); while (it.next()) |flag| { if (mem.eql(u8, flag, "--title")) { try dupeArg(alloc, &it, &config.labels.title, "--title"); @@ -222,7 +221,7 @@ fn parseCmdFlags() !void { \\alternative versions. wayprompt is developed and maintained by \\Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de>. \\ - , .{os.argv[0]}); + , .{std.os.argv[0]}); try out_buffer.flush(); return error.DumpedUsage; } else { diff --git a/src/wayprompt-pinentry.zig b/src/wayprompt-pinentry.zig index 2a8c145..305636e 100644 --- a/src/wayprompt-pinentry.zig +++ b/src/wayprompt-pinentry.zig @@ -2,6 +2,7 @@ const builtin = @import("builtin"); const std = @import("std"); const ascii = std.ascii; const mem = std.mem; +const posix = std.posix; const os = std.os; const io = std.io; const fs = std.fs; @@ -9,8 +10,10 @@ const fmt = std.fmt; const heap = std.heap; const debug = std.debug; -pub const std_options = struct { - pub const logFn = @import("log.zig").log; +const logFn = @import("log.zig").log; + +pub const std_options = std.Options{ + .logFn = logFn, }; const logger = std.log.scoped(.wayprompt); @@ -66,18 +69,18 @@ pub fn main() !u8 { const fds_stdin = 0; const fds_frontend = 1; - var fds: [2]os.pollfd = undefined; + var fds: [2]posix.pollfd = undefined; fds[fds_stdin] = .{ .fd = stdin.handle, - .events = os.POLL.IN, + .events = posix.POLL.IN, .revents = undefined, }; var stdin_closed: bool = false; fds[fds_frontend] = .{ .fd = try frontend.init(&config), - .events = os.POLL.IN, + .events = posix.POLL.IN, .revents = undefined, }; defer frontend.deinit(); @@ -103,10 +106,10 @@ pub fn main() !u8 { } // We don't poll stdin if it has been closed to avoid pointless spinning. - _ = try os.poll(if (stdin_closed) fds[1..2] else &fds, -1); + _ = try posix.poll(if (stdin_closed) fds[1..2] else &fds, -1); if (!stdin_closed) { - if (fds[fds_stdin].revents & os.POLL.IN != 0) { + if (fds[fds_stdin].revents & posix.POLL.IN != 0) { const read = try stdin.read(&in_buffer); if (read == 0) break; @@ -122,14 +125,14 @@ pub fn main() !u8 { } logger.debug("pipe closed.", .{}); - if (fds[fds_stdin].revents & os.POLL.HUP != 0) { + if (fds[fds_stdin].revents & posix.POLL.HUP != 0) { stdin_closed = true; } } if (stdin_closed and mode == .none) break; - if (fds[fds_frontend].revents & os.POLL.IN != 0) { + if (fds[fds_frontend].revents & posix.POLL.IN != 0) { if (frontend.handleEvent()) |ev| { try handleFrontendEvent(out_buffer.writer(), ev); } else |err| { -- 2.45.2
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bf7ffd8..49333f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ zig-out/ zig-cache/ +.zig-cache/ pinentry-wayprompt wayprompt-cli -- 2.45.2
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- build.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.zig b/build.zig index 2c34d69..f994e17 100644 --- a/build.zig @@ -8,7 +8,9 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const options = b.addOptions(); + const strip = b.option(bool, "strip", "Omit debug information") orelse false; const pie = b.option(bool, "pie", "Build with PIE support (by default false)") orelse false; + const llvm = !(b.option(bool, "no-llvm", "(expirimental) Use non-LLVM x86 Zig backend") orelse false); const scanner = Scanner.create(b, .{}); scanner.addCustomProtocol("protocol/wlr-layer-shell-unstable-v1.xml"); @@ -33,6 +35,9 @@ pub fn build(b: *std.Build) !void { .root_source_file = b.path("src/wayprompt-cli.zig"), .target = target, .optimize = optimize, + .strip = strip, + .use_llvm = llvm, + .use_lld = llvm, }); wayprompt_cli.root_module.addOptions("build_options", options); wayprompt_cli.linkLibC(); @@ -56,6 +61,9 @@ pub fn build(b: *std.Build) !void { .root_source_file = b.path("src/wayprompt-pinentry.zig"), .target = target, .optimize = optimize, + .strip = strip, + .use_llvm = llvm, + .use_lld = llvm, }); wayprompt_pinentry.linkLibC(); wayprompt_pinentry.root_module.addImport("wayland", wayland); -- 2.45.2
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 74cf32f..bd2b8d0 100644 --- a/build.zig.zon @@ -4,7 +4,7 @@ .paths = .{""}, .dependencies = .{ .@"zig-spoon" = .{ - .url = "https://git.sr.ht/~uncomfy/zig-spoon/archive/d029a3339a0363954ca67b17d92a6f574521aebb.tar.gz", + .url = "https://git.sr.ht/~uncomfy/zig-spoon/archive/2271c51a101601ff9be9a962d97803ea3c22063f.tar.gz", .hash = "122052b78ad23bbe4d5fc4755359a7724a2e36ceed0c67f3cb2194ce0ead510ce22c", }, .@"zig-pixman" = .{ -- 2.45.2
Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl> --- src/wayprompt-cli.zig | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/wayprompt-cli.zig b/src/wayprompt-cli.zig index 98c2a04..1150827 100644 --- a/src/wayprompt-cli.zig +++ b/src/wayprompt-cli.zig @@ -2,6 +2,7 @@ const std = @import("std"); const posix = std.posix; const mem = std.mem; const heap = std.heap; +const argv = std.process.ArgIteratorPosix; const debug = std.debug; const io = std.io; const meta = std.meta; @@ -156,27 +157,10 @@ fn writeOutput(comptime action: []const u8, pin: ?[]const u8) !void { try out_buffer.flush(); } -const FlagIt = struct { - const Self = @This(); - - argv: *[][*:0]u8, - index: usize = 1, - - pub fn new(argv: *[][*:0]u8) Self { - return Self{ .argv = argv }; - } - - pub fn next(self: *Self) ?[]const u8 { - if (self.index >= self.argv.len) return null; - defer self.index += 1; - return mem.span(self.argv.*[self.index]); - } -}; - fn parseCmdFlags() !void { const alloc = arena.allocator(); - var it = FlagIt.new(&std.os.argv); + var it = argv.init(); while (it.next()) |flag| { if (mem.eql(u8, flag, "--title")) { try dupeArg(alloc, &it, &config.labels.title, "--title"); @@ -231,7 +215,7 @@ fn parseCmdFlags() !void { } } -fn dupeArg(alloc: mem.Allocator, it: *FlagIt, dest: *?[]const u8, comptime flag: []const u8) !void { +fn dupeArg(alloc: mem.Allocator, it: *argv, dest: *?[]const u8, comptime flag: []const u8) !void { if (dest.* != null) { logger.err("redundant '{s}' flag.", .{flag}); return error.RedundantFlag; -- 2.45.2