From 76752e1c33d9a275594afb0ba3b5d13c445573b1 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Fri, 21 Jun 2024 18:43:42 +0200 Subject: [PATCH] port all Zig code to Zig 0.13.0 --- .config/fish/conf.d/50-alecor.fish | 1 - .gitignore | 4 + lib/common-zig/.gitignore | 1 - lib/common-zig/build.zig | 2 +- mzte-nv/.gitignore | 5 - mzte-nv/build.zig | 4 +- mzte-nv/build.zig.zon | 4 +- plugins/mzte-mpv/.gitignore | 1 - plugins/mzte-mpv/build.zig | 2 +- plugins/mzte-mpv/src/modules/SBSkip.zig | 2 +- scripts/alecor/.gitignore | 1 - scripts/alecor/build.zig | 27 --- scripts/alecor/build.zig.zon | 8 - scripts/alecor/src/cache.zig | 60 ------ scripts/alecor/src/correct.zig | 224 --------------------- scripts/alecor/src/main.zig | 73 ------- scripts/alecor/src/util.zig | 100 --------- scripts/hyprtool/.gitignore | 1 - scripts/hyprtool/build.zig | 2 +- scripts/mzteinit/.gitignore | 3 - scripts/mzteinit/build.zig | 6 +- scripts/mzteinit/build.zig.zon | 4 +- scripts/mzteinit/src/command.zig | 2 +- scripts/mzteinit/src/env.zig | 2 +- scripts/mzteinit/src/main.zig | 4 +- scripts/mzteriver/.gitignore | 2 - scripts/mzteriver/build.zig | 7 +- scripts/mzteriver/build.zig.zon | 4 +- scripts/openbrowser/.gitignore | 5 - scripts/openbrowser/build.zig | 4 +- scripts/openbrowser/src/main.zig | 2 +- scripts/playvid/.gitignore | 3 - scripts/playvid/build.zig | 2 +- scripts/prompt/.gitignore | 4 - scripts/prompt/build.zig | 2 +- scripts/prompt/build.zig.zon | 8 +- scripts/randomwallpaper/.gitignore | 2 - scripts/randomwallpaper/build.zig | 2 +- scripts/sysupdate.rkt | 1 - scripts/vinput/.gitignore | 5 - scripts/vinput/build.zig | 7 +- scripts/vinput/build.zig.zon | 4 +- scripts/vinput/src/ClipboardConnection.zig | 2 +- scripts/vinput/src/main.zig | 2 +- scripts/withjava/.gitignore | 1 - scripts/withjava/build.zig | 2 +- scripts/withjava/src/main.zig | 2 +- scripts/wlbg/.gitignore | 1 - scripts/wlbg/build.zig | 7 +- scripts/wlbg/build.zig.zon | 4 +- setup/commands/install-scripts.rkt | 1 - 51 files changed, 56 insertions(+), 573 deletions(-) delete mode 100644 .config/fish/conf.d/50-alecor.fish delete mode 100644 lib/common-zig/.gitignore delete mode 100644 mzte-nv/.gitignore delete mode 100644 plugins/mzte-mpv/.gitignore delete mode 100644 scripts/alecor/.gitignore delete mode 100644 scripts/alecor/build.zig delete mode 100644 scripts/alecor/build.zig.zon delete mode 100644 scripts/alecor/src/cache.zig delete mode 100644 scripts/alecor/src/correct.zig delete mode 100644 scripts/alecor/src/main.zig delete mode 100644 scripts/alecor/src/util.zig delete mode 100644 scripts/hyprtool/.gitignore delete mode 100644 scripts/mzteinit/.gitignore delete mode 100644 scripts/mzteriver/.gitignore delete mode 100644 scripts/openbrowser/.gitignore delete mode 100644 scripts/playvid/.gitignore delete mode 100644 scripts/prompt/.gitignore delete mode 100644 scripts/randomwallpaper/.gitignore delete mode 100644 scripts/vinput/.gitignore delete mode 100644 scripts/withjava/.gitignore delete mode 100644 scripts/wlbg/.gitignore diff --git a/.config/fish/conf.d/50-alecor.fish b/.config/fish/conf.d/50-alecor.fish deleted file mode 100644 index 5399027..0000000 --- a/.config/fish/conf.d/50-alecor.fish +++ /dev/null @@ -1 +0,0 @@ -alecor printfish | source diff --git a/.gitignore b/.gitignore index 5c7c97a..5aa41a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ # confgen output cgout + +# Zig build outputs +**/zig-out +**/.zig-cache diff --git a/lib/common-zig/.gitignore b/lib/common-zig/.gitignore deleted file mode 100644 index fe95f8d..0000000 --- a/lib/common-zig/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zig-* diff --git a/lib/common-zig/build.zig b/lib/common-zig/build.zig index a293559..18b27b5 100644 --- a/lib/common-zig/build.zig +++ b/lib/common-zig/build.zig @@ -4,7 +4,7 @@ pub const confgen_json_opt = std.json.ParseOptions{ .ignore_unknown_fields = tru pub fn build(b: *std.Build) void { _ = b.addModule("common", .{ - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), }); } diff --git a/mzte-nv/.gitignore b/mzte-nv/.gitignore deleted file mode 100644 index 1ae1b10..0000000 --- a/mzte-nv/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -zig-cache/ -zig-out/ -deps.zig -gyro.lock -.gyro diff --git a/mzte-nv/build.zig b/mzte-nv/build.zig index c035a63..049cc9f 100644 --- a/mzte-nv/build.zig +++ b/mzte-nv/build.zig @@ -12,7 +12,7 @@ pub fn build(b: *std.Build) !void { const lib = b.addSharedLibrary(.{ .name = "mzte-nv", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = mode, }); @@ -55,7 +55,7 @@ pub fn build(b: *std.Build) !void { // this is the install step for the lua config compiler binary const compiler = b.addExecutable(.{ .name = "mzte-nv-compile", - .root_source_file = .{ .path = "src/compiler.zig" }, + .root_source_file = b.path("src/compiler.zig"), .target = target, .optimize = mode, }); diff --git a/mzte-nv/build.zig.zon b/mzte-nv/build.zig.zon index 10fcfd9..d5465ce 100644 --- a/mzte-nv/build.zig.zon +++ b/mzte-nv/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../lib/common-zig" }, .znvim = .{ - .url = "git+https://git.mzte.de/LordMZTE/znvim.git#8e52c461dc071e6b88c8e77e49aa2805f225e7da", - .hash = "122029929d792aa32a71c0b98bb67d344d971d269d6fea5b8f8693e29f0f45924951", + .url = "git+https://git.mzte.de/LordMZTE/znvim.git#593576ab90fe7745acef03b88849aa904c399731", + .hash = "122036fae770b609b5eca343a07dd735522f90c93f9ae1a5f89bc24480f5906cd777", }, }, .paths = .{""}, diff --git a/plugins/mzte-mpv/.gitignore b/plugins/mzte-mpv/.gitignore deleted file mode 100644 index fe95f8d..0000000 --- a/plugins/mzte-mpv/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zig-* diff --git a/plugins/mzte-mpv/build.zig b/plugins/mzte-mpv/build.zig index 37d7270..d2bd02f 100644 --- a/plugins/mzte-mpv/build.zig +++ b/plugins/mzte-mpv/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void { const lib = b.addSharedLibrary(.{ .name = "mzte-mpv", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .link_libc = true, .target = target, .optimize = optimize, diff --git a/plugins/mzte-mpv/src/modules/SBSkip.zig b/plugins/mzte-mpv/src/modules/SBSkip.zig index cea5664..7ae81e8 100644 --- a/plugins/mzte-mpv/src/modules/SBSkip.zig +++ b/plugins/mzte-mpv/src/modules/SBSkip.zig @@ -12,7 +12,7 @@ skipped_chapters: ChapterSet, const SBSkip = @This(); -const blacklist = std.ComptimeStringMap(void, .{ +const blacklist = std.StaticStringMap(void).initComptime(.{ .{ "Endcards/Credits", {} }, .{ "Interaction Reminder", {} }, .{ "Intermission/Intro Animation", {} }, diff --git a/scripts/alecor/.gitignore b/scripts/alecor/.gitignore deleted file mode 100644 index fe95f8d..0000000 --- a/scripts/alecor/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zig-* diff --git a/scripts/alecor/build.zig b/scripts/alecor/build.zig deleted file mode 100644 index aea075b..0000000 --- a/scripts/alecor/build.zig +++ /dev/null @@ -1,27 +0,0 @@ -const std = @import("std"); - -pub fn build(b: *std.Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - - const exe = b.addExecutable(.{ - .name = "alecor", - .root_source_file = .{ .path = "src/main.zig" }, - .target = target, - .optimize = optimize, - }); - - exe.root_module.addImport("common", b.dependency("common", .{}).module("common")); - - b.installArtifact(exe); - - const run_cmd = b.addRunArtifact(exe); - run_cmd.step.dependOn(b.getInstallStep()); - - if (b.args) |args| { - run_cmd.addArgs(args); - } - - const run_step = b.step("run", "Run the app"); - run_step.dependOn(&run_cmd.step); -} diff --git a/scripts/alecor/build.zig.zon b/scripts/alecor/build.zig.zon deleted file mode 100644 index dfc4394..0000000 --- a/scripts/alecor/build.zig.zon +++ /dev/null @@ -1,8 +0,0 @@ -.{ - .name = "alecor", - .version = "0.0.0", - .paths = .{""}, - .dependencies = .{ - .common = .{ .path = "../../lib/common-zig" }, - }, -} diff --git a/scripts/alecor/src/cache.zig b/scripts/alecor/src/cache.zig deleted file mode 100644 index 97d1865..0000000 --- a/scripts/alecor/src/cache.zig +++ /dev/null @@ -1,60 +0,0 @@ -const std = @import("std"); - -pub fn commandsCachePath(alloc: std.mem.Allocator) ![]const u8 { - return try std.fs.path.join(alloc, &.{ - std.posix.getenv("HOME") orelse return error.HomeNotSet, - ".cache", - "alecor", - "commands", - }); -} - -pub fn generate(alloc: std.mem.Allocator) !void { - const cache_path = try commandsCachePath(alloc); - defer alloc.free(cache_path); - - if (std.fs.path.dirname(cache_path)) |cache_dir| { - try std.fs.cwd().makePath(cache_dir); - } - - var cache_file = try std.fs.cwd().createFile(cache_path, .{}); - defer cache_file.close(); - - const pipefds = try std.posix.pipe(); - defer std.posix.close(pipefds[0]); - - var stdout_buf_reader = std.io.bufferedReader((std.fs.File{ .handle = pipefds[0] }).reader()); - - // ChildProcess being useless again... - const pid = try std.posix.fork(); - if (pid == 0) { - errdefer std.posix.exit(1); - try std.posix.dup2(pipefds[1], 1); - std.posix.close(pipefds[0]); - std.posix.close(pipefds[1]); - return std.posix.execvpeZ( - "fish", - &[_:null]?[*:0]const u8{ "fish", "-c", "complete -C ''" }, - @ptrCast(std.os.environ.ptr), - ); - } - - std.posix.close(pipefds[1]); - - var cmd_buf: [1024]u8 = undefined; - var fbs = std.io.fixedBufferStream(&cmd_buf); - while (true) { - fbs.reset(); - stdout_buf_reader.reader().streamUntilDelimiter(fbs.writer(), '\n', null) catch |e| switch (e) { - error.EndOfStream => break, - else => return e, - }; - - // FBS will have \tgarbage here - var spliter = std.mem.tokenize(u8, fbs.getWritten(), "\t"); - try cache_file.writeAll(spliter.next() orelse continue); - try cache_file.writer().writeByte('\n'); - } - - _ = std.posix.waitpid(pid, 0); -} diff --git a/scripts/alecor/src/correct.zig b/scripts/alecor/src/correct.zig deleted file mode 100644 index a607bc8..0000000 --- a/scripts/alecor/src/correct.zig +++ /dev/null @@ -1,224 +0,0 @@ -const std = @import("std"); - -const util = @import("util.zig"); - -/// Commands which are prioritized for correction -const priority_commands = [_][]const u8{ - "git", -}; - -/// Commands which wrap another -const wrapper_commands = std.ComptimeStringMap(void, .{ - .{ "doas", {} }, - .{ "sudo", {} }, - .{ "rbg", {} }, - .{ "rbgd", {} }, - .{ "pkexec", {} }, -}); - -fn populateArgMap(map: *ArgMap) !void { - try map.put(&.{"git"}, .{ .subcommand = &.{ "push", "pull", "reset", "checkout" } }); - try map.put(&.{ "git", "checkout" }, .file_or_directory); -} - -const ArgRequirement = union(enum) { - subcommand: []const []const u8, - file, - directory, - file_or_directory, -}; - -const ArgMap = std.HashMap( - []const []const u8, - ArgRequirement, - struct { - pub fn hash(self: @This(), v: []const []const u8) u64 { - _ = self; - var hasher = std.hash.Wyhash.init(0); - hasher.update(std.mem.asBytes(&v.len)); - for (v) |s| { - hasher.update(std.mem.asBytes(&v.len)); - hasher.update(s); - } - - return hasher.final(); - } - - pub fn eql(self: @This(), a: []const []const u8, b: []const []const u8) bool { - _ = self; - if (a.len != b.len) - return false; - - for (a, b) |va, vb| - if (!std.mem.eql(u8, va, vb)) - return false; - - return true; - } - }, - std.hash_map.default_max_load_percentage, -); - -pub fn correctCommand( - arena: *std.heap.ArenaAllocator, - /// Command to correct in-place - cmd: [][]const u8, - /// Set of all valid commands - commands: *std.StringHashMap(void), -) !void { - const alloc = arena.child_allocator; - - var subslice = cmd; - - // skip wrapper commands - while (subslice.len > 0 and wrapper_commands.has(subslice[0])) - subslice = subslice[1..]; - - // empty command - if (subslice.len == 0) - return; - - if (!commands.contains(subslice[0])) { - // correct command - var best: ?struct { []const u8, usize } = null; - - // do priority commands first and sub 1 from distance - for (priority_commands) |possible_cmd| { - const dist = try util.dist(alloc, subslice[0], possible_cmd) -| 1; // prioritize by subtracting 1 - if (best == null or best.?.@"1" > dist) - best = .{ possible_cmd, dist }; - } - - if (best != null and best.?.@"1" != 0) { - var iter = commands.keyIterator(); - while (iter.next()) |possible_cmd| { - const dist = try util.dist(alloc, subslice[0], possible_cmd.*); - if (best == null or best.?.@"1" > dist) - best = .{ possible_cmd.*, dist }; - } - } - - if (best) |b| { - if (!std.mem.eql(u8, subslice[0], b.@"0")) { - std.log.info("[C] {s} => {s}", .{ subslice[0], b.@"0" }); - subslice[0] = b.@"0"; - } - } - } - - if (subslice.len < 2) - return; - - var arg_map = ArgMap.init(alloc); - defer arg_map.deinit(); - try populateArgMap(&arg_map); - - // correct args. loop as long as corrections are made - while (true) { - var req: ?ArgRequirement = null; - - var cmd_slice_end = subslice.len - 1; - - while (cmd_slice_end >= 1) : (cmd_slice_end -= 1) { - if (arg_map.get(subslice[0..cmd_slice_end])) |r| { - req = r; - cmd_slice_end -= 1; - break; - } - } - - // If the argument contains a slash, assume it's a path. - if (req == null and std.mem.containsAtLeast(u8, subslice[cmd_slice_end + 1], 1, "/")) - req = .file_or_directory; - - if (req) |r| { - var new_arg = subslice[cmd_slice_end + 1]; - try correctArgForReq(arena, r, &new_arg); - if (!std.mem.eql(u8, subslice[cmd_slice_end + 1], new_arg)) { - std.log.info("[A] {s} => {s}", .{ subslice[cmd_slice_end + 1], new_arg }); - subslice[cmd_slice_end + 1] = new_arg; - } else break; - } else break; - } -} - -fn correctArgForReq(arena: *std.heap.ArenaAllocator, req: ArgRequirement, arg: *[]const u8) !void { - const alloc = arena.child_allocator; - switch (req) { - .subcommand => |subcmds| { - var best: ?struct { []const u8, usize } = null; - for (subcmds) |possible_cmd| { - const dist = try util.dist(alloc, arg.*, possible_cmd); - if (best == null or best.?.@"1" > dist) - best = .{ possible_cmd, dist }; - } - - if (best) |b| - arg.* = b.@"0"; - }, - .file, .directory, .file_or_directory => { - if (arg.len == 0) - return; - - var path_spliter = std.mem.tokenize(u8, arg.*, "/"); - var path_splits = std.ArrayList([]const u8).init(alloc); - defer path_splits.deinit(); - - // path is absolute - if (arg.*[0] == '/') - try path_splits.append("/"); - - while (path_spliter.next()) |split| { - if (std.mem.eql(u8, split, "~")) { - try path_splits.append(std.posix.getenv("HOME") orelse return error.HomeNotSet); - } else { - try path_splits.append(split); - } - } - - for (path_splits.items, 0..) |*split, cur_idx| { - const dirs = path_splits.items[0..cur_idx]; - const dir_subpath = try std.fs.path.join(arena.allocator(), if (dirs.len == 0) &.{"."} else dirs); - - var iterable_dir = try std.fs.cwd().openDir(dir_subpath, .{ .iterate = true }); - defer iterable_dir.close(); - - // if the given file already exists, there's no point in iterating the dir - if (iterable_dir.statFile(split.*)) |_| continue else |e| switch (e) { - error.FileNotFound => {}, - else => return e, - } - - var best: ?struct { []const u8, usize } = null; - - var dir_iter = iterable_dir.iterate(); - - var best_buf: [1024]u8 = undefined; - - while (try dir_iter.next()) |entry| { - switch (req) { - .file => if (entry.kind == .directory) continue, - .directory => if (entry.kind != .directory and - entry.kind != .sym_link) continue, - else => {}, - } - - const dist = try util.dist(alloc, split.*, entry.name); - if (best == null or best.?.@"1" > dist) { - if (entry.name.len > best_buf.len) - return error.OutOfMemory; - const buf_slice = best_buf[0..entry.name.len]; - @memcpy(buf_slice, entry.name); - best = .{ buf_slice, dist }; - } - } - - if (best) |b| { - split.* = try arena.allocator().dupe(u8, b.@"0"); - } else break; - } - - arg.* = try std.fs.path.join(arena.allocator(), path_splits.items); - }, - } -} diff --git a/scripts/alecor/src/main.zig b/scripts/alecor/src/main.zig deleted file mode 100644 index cd614d1..0000000 --- a/scripts/alecor/src/main.zig +++ /dev/null @@ -1,73 +0,0 @@ -const std = @import("std"); - -const cache = @import("cache.zig"); -const util = @import("util.zig"); - -pub const std_options = std.Options{ - .log_level = .debug, - .logFn = @import("common").logFn, -}; - -pub fn main() !void { - if (std.os.argv.len < 2) - return error.NotEnoughArguments; - - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - defer _ = gpa.deinit(); - const alloc = gpa.allocator(); - - const subcmd = std.mem.span(std.os.argv[1]); - - if (std.mem.eql(u8, subcmd, "doalec")) { - if (std.os.argv.len < 3) - return error.NotEnoughArguments; - - var args = std.ArrayList([]const u8).init(alloc); - defer args.deinit(); - - var spliter = std.mem.tokenize(u8, std.mem.span(std.os.argv[2]), "\n"); - while (spliter.next()) |arg| - try args.append(arg); - - // open and map cache - const cache_path = try cache.commandsCachePath(alloc); - defer alloc.free(cache_path); - - var cache_file = try std.fs.cwd().openFile(cache_path, .{}); - defer cache_file.close(); - - const cache_content = try std.posix.mmap( - null, - (try cache_file.stat()).size, - std.posix.PROT.READ, - .{ .TYPE = .PRIVATE }, - cache_file.handle, - 0, - ); - defer std.posix.munmap(cache_content); - - var command_set = std.StringHashMap(void).init(alloc); - defer command_set.deinit(); - - var cache_tok = std.mem.tokenize(u8, cache_content, "\n"); - while (cache_tok.next()) |tok| - if (tok.len != 0) - try command_set.put(tok, {}); - - var arena = std.heap.ArenaAllocator.init(alloc); - defer arena.deinit(); - - try @import("correct.zig").correctCommand(&arena, args.items, &command_set); - try std.io.getStdOut().writer().print("{}\n", .{util.fmtCommand(args.items)}); - } else if (std.mem.eql(u8, subcmd, "printfish")) { - try std.io.getStdOut().writer().print( - \\function alec --description 'ALEC' - \\ commandline (builtin history search -n 1) - \\ commandline ({s} doalec (commandline -o | string split0)) - \\end - \\ - , .{std.os.argv[0]}); - } else if (std.mem.eql(u8, subcmd, "mkcache")) { - try cache.generate(alloc); - } else return error.UnknownCommand; -} diff --git a/scripts/alecor/src/util.zig b/scripts/alecor/src/util.zig deleted file mode 100644 index d11fc50..0000000 --- a/scripts/alecor/src/util.zig +++ /dev/null @@ -1,100 +0,0 @@ -const std = @import("std"); - -/// A 2-dimensional heap-allocated matrix. -pub fn Matrix2D(comptime T: type) type { - return struct { - data: []T, - width: usize, - - const Self = @This(); - - pub inline fn init(alloc: std.mem.Allocator, height: usize, width: usize) !Self { - return .{ .data = try alloc.alloc(T, height * width), .width = width }; - } - - pub inline fn deinit(self: Self, alloc: std.mem.Allocator) void { - alloc.free(self.data); - } - - pub inline fn el(self: *Self, row: usize, col: usize) *T { - return &self.data[row * self.width + col]; - } - }; -} - -/// Calculates the Damerau-Levenshtein distance between 2 strings -pub fn dist(alloc: std.mem.Allocator, a: []const u8, b: []const u8) !usize { - var d = try Matrix2D(usize).init(alloc, a.len + 1, b.len + 1); - defer d.deinit(alloc); - - @memset(d.data, 0); - - var i: usize = 0; - var j: usize = 0; - - while (i <= a.len) : (i += 1) { - d.el(i, 0).* = i; - } - - while (j <= b.len) : (j += 1) { - d.el(0, j).* = j; - } - - i = 1; - while (i <= a.len) : (i += 1) { - j = 1; - while (j <= b.len) : (j += 1) { - const cost = @intFromBool(a[i - 1] != b[j - 1]); - d.el(i, j).* = @min( - d.el(i - 1, j).* + 1, // deletion - @min( - d.el(i, j - 1).* + 1, // insertion - d.el(i - 1, j - 1).* + cost, // substitution - ), - ); - - // transposition - if (i > 1 and j > 1 and a[i - 1] == b[j - 2] and a[i - 2] == b[j - 1]) - d.el(i, j).* = @min(d.el(i, j).*, d.el(i - 2, j - 2).* + cost); - } - } - - return d.el(a.len, b.len).*; -} - -fn formatCommand( - cmd: []const []const u8, - comptime fmt: []const u8, - options: std.fmt.FormatOptions, - writer: anytype, -) !void { - _ = options; - _ = fmt; - - var first = true; - for (cmd) |arg| { - defer first = false; - var needs_quote = false; - for (arg) |ch| { - if (!std.ascii.isPrint(ch) or ch == '\'' or ch == ' ' or ch == '*' or ch == '$') { - needs_quote = true; - break; - } - } - - if (!first) - try writer.writeByte(' '); - - if (needs_quote) { - try writer.writeByte('"'); - try writer.print("{}", .{std.fmt.fmtSliceEscapeUpper(arg)}); - try writer.writeByte('"'); - } else { - try writer.writeAll(arg); - } - } -} - -pub fn fmtCommand(cmd: []const []const u8) std.fmt.Formatter(formatCommand) { - return .{ .data = cmd }; -} diff --git a/scripts/hyprtool/.gitignore b/scripts/hyprtool/.gitignore deleted file mode 100644 index fe95f8d..0000000 --- a/scripts/hyprtool/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zig-* diff --git a/scripts/hyprtool/build.zig b/scripts/hyprtool/build.zig index a519295..6094c34 100644 --- a/scripts/hyprtool/build.zig +++ b/scripts/hyprtool/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "hyprtool", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); diff --git a/scripts/mzteinit/.gitignore b/scripts/mzteinit/.gitignore deleted file mode 100644 index 5da67ec..0000000 --- a/scripts/mzteinit/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -zig-cache/ -zig-out/ -flake.lock diff --git a/scripts/mzteinit/build.zig b/scripts/mzteinit/build.zig index 70f4928..1695a40 100644 --- a/scripts/mzteinit/build.zig +++ b/scripts/mzteinit/build.zig @@ -10,14 +10,14 @@ pub fn build(b: *std.Build) !void { const exe = b.addExecutable(.{ .name = "mzteinit", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); const mzteinitctl = b.addExecutable(.{ .name = "mzteinitctl", - .root_source_file = .{ .path = "src/mzteinitctl.zig" }, + .root_source_file = b.path("src/mzteinitctl.zig"), .target = target, .optimize = optimize, }); @@ -28,7 +28,7 @@ pub fn build(b: *std.Build) !void { } const cg_opt = try common.confgenGet(struct { - gtk_theme: []u8, // TODO: this being non-const is a workaround for an std bug + gtk_theme: []const u8, }, b.allocator); const opts = b.addOptions(); diff --git a/scripts/mzteinit/build.zig.zon b/scripts/mzteinit/build.zig.zon index 895941a..2ed96f4 100644 --- a/scripts/mzteinit/build.zig.zon +++ b/scripts/mzteinit/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .ansi_term = .{ - .url = "git+https://github.com/LordMZTE/ansi-term.git#73c03175068679685535111dbea72cade075719e", - .hash = "1220ea86ace34b38e49c1d737c5f857d88346af10695a992b38e10cb0a73b6a19ef7", + .url = "git+https://github.com/LordMZTE/ansi-term.git#86a00a97e5d72d21c8632006c73483c4187b6d98", + .hash = "12200719196e0abd325efa248fb03882c8fa2c7130e3ae1d57dbff72afc846b28495", }, }, .paths = .{""}, diff --git a/scripts/mzteinit/src/command.zig b/scripts/mzteinit/src/command.zig index d6f2a5c..ef0923e 100644 --- a/scripts/mzteinit/src/command.zig +++ b/scripts/mzteinit/src/command.zig @@ -29,7 +29,7 @@ pub const Command = struct { if (self.exit) exit.* = .immediate; log.info("run cmd: {s}", .{self.command}); - var child = std.ChildProcess.init(self.command, alloc); + var child = std.process.Child.init(self.command, alloc); { env.mtx.lock(); defer env.mtx.unlock(); diff --git a/scripts/mzteinit/src/env.zig b/scripts/mzteinit/src/env.zig index 6bf9628..7a3e1cf 100644 --- a/scripts/mzteinit/src/env.zig +++ b/scripts/mzteinit/src/env.zig @@ -227,7 +227,7 @@ pub fn populateSysdaemonEnvironment(env: *const std.process.EnvMap) !void { log.debug("sysdaemon env cmd: {}", .{util.fmtCommand(argv.items)}); - var child = std.ChildProcess.init(argv.items, env.hash_map.allocator); + var child = std.process.Child.init(argv.items, env.hash_map.allocator); const term = try child.spawnAndWait(); if (!std.meta.eql(term, .{ .Exited = 0 })) { diff --git a/scripts/mzteinit/src/main.zig b/scripts/mzteinit/src/main.zig index 62a8cb6..5012641 100644 --- a/scripts/mzteinit/src/main.zig +++ b/scripts/mzteinit/src/main.zig @@ -80,7 +80,7 @@ fn tryMain() !void { if (env_map.data.get("MZTEINIT")) |_| { try stdout.writer().writeAll("mzteinit running already, starting shell\n"); try stdout.flush(); - var child = std.ChildProcess.init(launch_cmd orelse &.{"nu"}, alloc); + var child = std.process.Child.init(launch_cmd orelse &.{"nu"}, alloc); _ = try child.spawnAndWait(); return; } else { @@ -121,7 +121,7 @@ fn tryMain() !void { if (launch_cmd) |cmd| { try msg("using launch command", .{}); - var child = std.ChildProcess.init(cmd, alloc); + var child = std.process.Child.init(cmd, alloc); { env_map.mtx.lock(); defer env_map.mtx.unlock(); diff --git a/scripts/mzteriver/.gitignore b/scripts/mzteriver/.gitignore deleted file mode 100644 index e73c965..0000000 --- a/scripts/mzteriver/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -zig-cache/ -zig-out/ diff --git a/scripts/mzteriver/build.zig b/scripts/mzteriver/build.zig index 3a647b9..df093b5 100644 --- a/scripts/mzteriver/build.zig +++ b/scripts/mzteriver/build.zig @@ -43,14 +43,17 @@ pub fn build(b: *std.Build) !void { const exe = b.addExecutable(.{ .name = "mzteriver", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, + .link_libc = true, }); + scanner.addCSource(exe); + exe.root_module.addImport("common", b.dependency("common", .{}).module("common")); exe.root_module.addImport("opts", opts.createModule()); - exe.root_module.addImport("wayland", scanner.mod); + exe.root_module.addImport("wayland", b.createModule(.{ .root_source_file = scanner.result })); scanner.addCustomProtocol("river-control-unstable-v1.xml"); diff --git a/scripts/mzteriver/build.zig.zon b/scripts/mzteriver/build.zig.zon index 1819da8..69c320e 100644 --- a/scripts/mzteriver/build.zig.zon +++ b/scripts/mzteriver/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .wayland = .{ - .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#1164c9eaa59442e6a8ec8e994fd5d30c23e4ed6d", - .hash = "122064a0e836c603b42720f101cd1b983f9b79f2457b58afdfa1aca1d7c406e80b83", + .url = "git+https://codeberg.org/ifreund/zig-wayland.git#092e3424345d9c0a9467771b2f629fa01560a69f", + .hash = "1220ab835f090bde18b74191e88c4ab3bd49364d310bd9912eccebd3c47bad7957a3", }, }, diff --git a/scripts/openbrowser/.gitignore b/scripts/openbrowser/.gitignore deleted file mode 100644 index 1ae1b10..0000000 --- a/scripts/openbrowser/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -zig-cache/ -zig-out/ -deps.zig -gyro.lock -.gyro diff --git a/scripts/openbrowser/build.zig b/scripts/openbrowser/build.zig index 03c3255..5d722b3 100644 --- a/scripts/openbrowser/build.zig +++ b/scripts/openbrowser/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "openbrowser", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = mode, }); @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void { b.installArtifact(exe); const desktop_install_step = b.addInstallFile( - .{ .path = "assets/openbrowser.desktop" }, + b.path("assets/openbrowser.desktop"), "share/applications/openbrowser.desktop", ); b.getInstallStep().dependOn(&desktop_install_step.step); diff --git a/scripts/openbrowser/src/main.zig b/scripts/openbrowser/src/main.zig index cbd9892..bce52b4 100644 --- a/scripts/openbrowser/src/main.zig +++ b/scripts/openbrowser/src/main.zig @@ -60,6 +60,6 @@ fn start(browser: []const u8, alloc: std.mem.Allocator) !void { std.log.info("child argv: {s}", .{argv}); - var child = std.ChildProcess.init(argv, alloc); + var child = std.process.Child.init(argv, alloc); _ = try child.spawnAndWait(); } diff --git a/scripts/playvid/.gitignore b/scripts/playvid/.gitignore deleted file mode 100644 index 5da67ec..0000000 --- a/scripts/playvid/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -zig-cache/ -zig-out/ -flake.lock diff --git a/scripts/playvid/build.zig b/scripts/playvid/build.zig index c479c10..3b9414a 100644 --- a/scripts/playvid/build.zig +++ b/scripts/playvid/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "playvid", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); diff --git a/scripts/prompt/.gitignore b/scripts/prompt/.gitignore deleted file mode 100644 index 6ed8398..0000000 --- a/scripts/prompt/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -zig-*/ -.gyro/ -deps.zig -gyro.lock diff --git a/scripts/prompt/build.zig b/scripts/prompt/build.zig index 942f10c..182ee18 100644 --- a/scripts/prompt/build.zig +++ b/scripts/prompt/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "prompt", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = mode, }); diff --git a/scripts/prompt/build.zig.zon b/scripts/prompt/build.zig.zon index 7e8cb93..4edb1b5 100644 --- a/scripts/prompt/build.zig.zon +++ b/scripts/prompt/build.zig.zon @@ -6,12 +6,12 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .ansi_term = .{ - .url = "git+https://github.com/LordMZTE/ansi-term.git#73c03175068679685535111dbea72cade075719e", - .hash = "1220ea86ace34b38e49c1d737c5f857d88346af10695a992b38e10cb0a73b6a19ef7", + .url = "git+https://github.com/LordMZTE/ansi-term.git#86a00a97e5d72d21c8632006c73483c4187b6d98", + .hash = "12200719196e0abd325efa248fb03882c8fa2c7130e3ae1d57dbff72afc846b28495", }, .known_folders = .{ - .url = "git+https://github.com/ziglibs/known-folders.git#2aa7f2e9855d45b20072e15107fb379b9380adbe", - .hash = "12209925016f4b5486a713828ead3bcc900fa4f039c93de1894aa7d5253f7633b92c", + .url = "git+https://github.com/ziglibs/known-folders.git#47076c6b11214a218e9244471d8762310820911a", + .hash = "12209d2738a2e1dbd3781c2e5f01a2ea877dcfeea53efdfa1913247297d328e6b207", }, }, } diff --git a/scripts/randomwallpaper/.gitignore b/scripts/randomwallpaper/.gitignore deleted file mode 100644 index e73c965..0000000 --- a/scripts/randomwallpaper/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -zig-cache/ -zig-out/ diff --git a/scripts/randomwallpaper/build.zig b/scripts/randomwallpaper/build.zig index 00219f3..39de8bd 100644 --- a/scripts/randomwallpaper/build.zig +++ b/scripts/randomwallpaper/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "randomwallpaper", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = mode, }); diff --git a/scripts/sysupdate.rkt b/scripts/sysupdate.rkt index 88fc7bc..654dde3 100755 --- a/scripts/sysupdate.rkt +++ b/scripts/sysupdate.rkt @@ -23,7 +23,6 @@ (apply cmd (if (noint) '("paru" "-Syu" "--noconfirm") '("paru" "-Syu"))) -(cmd "alecor" "mkcache") (cmd "tldr" "--update") (unless (empty? failures) diff --git a/scripts/vinput/.gitignore b/scripts/vinput/.gitignore deleted file mode 100644 index 1ae1b10..0000000 --- a/scripts/vinput/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -zig-cache/ -zig-out/ -deps.zig -gyro.lock -.gyro diff --git a/scripts/vinput/build.zig b/scripts/vinput/build.zig index a24679c..4af76cc 100644 --- a/scripts/vinput/build.zig +++ b/scripts/vinput/build.zig @@ -7,13 +7,14 @@ pub fn build(b: *std.Build) void { const mode = b.standardOptimizeOption(.{}); const scanner = Scanner.create(b, .{}); - const wayland_mod = scanner.mod; + const wayland_mod = b.createModule(.{ .root_source_file = scanner.result }); const exe = b.addExecutable(.{ .name = "vinput", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = mode, + .link_libc = true, }); exe.root_module.addImport("common", b.dependency("common", .{}).module("common")); @@ -27,6 +28,8 @@ pub fn build(b: *std.Build) void { scanner.generate("wl_shm", 1); scanner.generate("xdg_wm_base", 2); + scanner.addCSource(exe); + exe.root_module.linkSystemLibrary("wayland-client", .{}); b.installArtifact(exe); diff --git a/scripts/vinput/build.zig.zon b/scripts/vinput/build.zig.zon index 49bd63a..7fc829c 100644 --- a/scripts/vinput/build.zig.zon +++ b/scripts/vinput/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .wayland = .{ - .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#1164c9eaa59442e6a8ec8e994fd5d30c23e4ed6d", - .hash = "122064a0e836c603b42720f101cd1b983f9b79f2457b58afdfa1aca1d7c406e80b83", + .url = "git+https://codeberg.org/ifreund/zig-wayland.git#092e3424345d9c0a9467771b2f629fa01560a69f", + .hash = "1220ab835f090bde18b74191e88c4ab3bd49364d310bd9912eccebd3c47bad7957a3", }, }, } diff --git a/scripts/vinput/src/ClipboardConnection.zig b/scripts/vinput/src/ClipboardConnection.zig index e91737d..0b0e1ec 100644 --- a/scripts/vinput/src/ClipboardConnection.zig +++ b/scripts/vinput/src/ClipboardConnection.zig @@ -137,7 +137,7 @@ pub fn getContent(self: *ClipboardConnection, out_fd: std.posix.fd_t) !void { t: ?[:0]const u8 = null, fn offerListener(_: *wl.DataOffer, event: wl.DataOffer.Event, mt: *@This()) void { - const text_types = std.ComptimeStringMap(void, .{ + const text_types = std.StaticStringMap(void).initComptime(.{ .{ "TEXT", {} }, .{ "STRING", {} }, .{ "UTF8_STRING", {} }, diff --git a/scripts/vinput/src/main.zig b/scripts/vinput/src/main.zig index cb909ec..7ea21d7 100644 --- a/scripts/vinput/src/main.zig +++ b/scripts/vinput/src/main.zig @@ -60,7 +60,7 @@ pub fn main() !void { std.log.info("invoking editor with command {s}", .{&editor_argv}); - var nvide_child = std.ChildProcess.init(&editor_argv, alloc); + var nvide_child = std.process.Child.init(&editor_argv, alloc); _ = try nvide_child.spawnAndWait(); const stat = std.fs.cwd().statFile(filename) catch |e| { diff --git a/scripts/withjava/.gitignore b/scripts/withjava/.gitignore deleted file mode 100644 index fe95f8d..0000000 --- a/scripts/withjava/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zig-* diff --git a/scripts/withjava/build.zig b/scripts/withjava/build.zig index 112c8eb..42a62c5 100644 --- a/scripts/withjava/build.zig +++ b/scripts/withjava/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *std.Build) !void { const exe = b.addExecutable(.{ .name = "withjava", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); diff --git a/scripts/withjava/src/main.zig b/scripts/withjava/src/main.zig index 23d0520..5847704 100644 --- a/scripts/withjava/src/main.zig +++ b/scripts/withjava/src/main.zig @@ -47,7 +47,7 @@ pub fn main() !u8 { for (std.os.argv[2..], child_argv) |a1, *a2| a2.* = std.mem.span(a1); - var child = std.ChildProcess.init(child_argv, alloc); + var child = std.process.Child.init(child_argv, alloc); child.env_map = &env; const term = try child.spawnAndWait(); diff --git a/scripts/wlbg/.gitignore b/scripts/wlbg/.gitignore deleted file mode 100644 index fe95f8d..0000000 --- a/scripts/wlbg/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zig-* diff --git a/scripts/wlbg/build.zig b/scripts/wlbg/build.zig index c3fd93e..11c249e 100644 --- a/scripts/wlbg/build.zig +++ b/scripts/wlbg/build.zig @@ -7,13 +7,14 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const scanner = Scanner.create(b, .{}); - const wayland_mod = scanner.mod; + const wayland_mod = b.createModule(.{ .root_source_file = scanner.result }); const exe = b.addExecutable(.{ .name = "wlbg", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, + .link_libc = true, }); exe.root_module.addImport("common", b.dependency("common", .{}).module("common")); @@ -31,6 +32,8 @@ pub fn build(b: *std.Build) void { scanner.generate("wl_seat", 8); scanner.generate("wl_output", 4); + scanner.addCSource(exe); + exe.root_module.linkSystemLibrary("wayland-client", .{}); exe.root_module.linkSystemLibrary("wayland-egl", .{}); exe.root_module.linkSystemLibrary("EGL", .{}); diff --git a/scripts/wlbg/build.zig.zon b/scripts/wlbg/build.zig.zon index 8dcc29b..1ec4b71 100644 --- a/scripts/wlbg/build.zig.zon +++ b/scripts/wlbg/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .wayland = .{ - .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#1164c9eaa59442e6a8ec8e994fd5d30c23e4ed6d", - .hash = "122064a0e836c603b42720f101cd1b983f9b79f2457b58afdfa1aca1d7c406e80b83", + .url = "git+https://codeberg.org/ifreund/zig-wayland.git#092e3424345d9c0a9467771b2f629fa01560a69f", + .hash = "1220ab835f090bde18b74191e88c4ab3bd49364d310bd9912eccebd3c47bad7957a3", }, }, } diff --git a/setup/commands/install-scripts.rkt b/setup/commands/install-scripts.rkt index c4f0d5c..b95c03e 100644 --- a/setup/commands/install-scripts.rkt +++ b/setup/commands/install-scripts.rkt @@ -16,7 +16,6 @@ (install-link "scripts/videos-duration.sh" (bin-path "videos-duration")) ;; Compiled scripts - (install-zig "scripts/alecor") (install-zig "scripts/hyprtool") (install-rust "scripts/i3status") (install-zig "scripts/mzteinit")