feat: support zig `0.13.0`

This commit is contained in:
jinzhongjia 2024-07-03 19:53:29 +08:00
parent cbe7b37564
commit b08e711d32
4 changed files with 14 additions and 16 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
.idea/
zig-cache/
zig-out/
valgrind.log
valgrind.log
.zig-cache

View File

@ -25,7 +25,7 @@ pub fn build(b: *std.Build) !void {
const exe = b.addExecutable(.{
.name = "ly",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
@ -38,14 +38,14 @@ pub fn build(b: *std.Build) !void {
const clap = b.dependency("clap", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("clap", clap.module("clap"));
exe.addIncludePath(.{ .path = "include" });
exe.addIncludePath(b.path("include"));
exe.linkSystemLibrary("pam");
exe.linkSystemLibrary("xcb");
exe.linkLibC();
// HACK: Only fails with ReleaseSafe, so we'll override it.
const translate_c = b.addTranslateC(.{
.root_source_file = .{ .path = "include/termbox2.h" },
.root_source_file = b.path("include/termbox2.h"),
.target = target,
.optimize = if (optimize == .ReleaseSafe) .ReleaseFast else optimize,
});
@ -94,8 +94,7 @@ pub fn build(b: *std.Build) !void {
pub fn ExeInstaller(install_conf: bool) type {
return struct {
pub fn make(step: *std.Build.Step, progress: *std.Progress.Node) !void {
_ = progress;
pub fn make(step: *std.Build.Step, _: std.Progress.Node) anyerror!void {
try install_ly(step.owner.allocator, install_conf);
}
};
@ -108,8 +107,7 @@ const InitSystem = enum {
};
pub fn ServiceInstaller(comptime init_system: InitSystem) type {
return struct {
pub fn make(step: *std.Build.Step, progress: *std.Progress.Node) !void {
_ = progress;
pub fn make(step: *std.Build.Step, _: std.Progress.Node) !void {
const allocator = step.owner.allocator;
switch (init_system) {
.Openrc => {
@ -217,8 +215,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
}
}
pub fn uninstallall(step: *std.Build.Step, progress: *std.Progress.Node) !void {
_ = progress;
pub fn uninstallall(step: *std.Build.Step, _: std.Progress.Node) !void {
try std.fs.cwd().deleteTree(data_directory);
const allocator = step.owner.allocator;

View File

@ -4,12 +4,12 @@
.minimum_zig_version = "0.12.0",
.dependencies = .{
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/8c98e6404b22aafc0184e999d8f068b81cc22fa1.tar.gz",
.hash = "122014e73fd712190e109950837b97f6143f02d7e2b6986e1db70b6f4aadb5ba6a0d",
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.0.tar.gz",
.hash = "12207ee987ce045596cb992cfb15b0d6d9456e50d4721c3061c69dabc2962053644d",
},
.zigini = .{
.url = "https://github.com/Kawaii-Ash/zigini/archive/ce1f322482099db058f5d9fdd05fbfa255d79723.tar.gz",
.hash = "1220e7a99793a0430e0a7c0b938cb3c98321035bc297e21cd0e2413cf740b4923b9f",
.url = "https://github.com/Kawaii-Ash/zigini/archive/0f8967515464730a0031497718ebeecbeae32a07.tar.gz",
.hash = "1220b7f2e51153392255d2ab9418c55000a86ecab9f48c291385e784645948179c59",
},
},
.paths = .{""},

View File

@ -479,7 +479,7 @@ pub fn main() !void {
run = false;
} else if (pressed_key == sleep_key) {
if (config.sleep_cmd) |sleep_cmd| {
var sleep = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator);
var sleep = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator);
_ = sleep.spawnAndWait() catch .{};
}
}
@ -584,7 +584,7 @@ pub fn main() !void {
update = true;
var restore_cursor = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", config.term_restore_cursor_cmd }, allocator);
var restore_cursor = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.term_restore_cursor_cmd }, allocator);
_ = restore_cursor.spawnAndWait() catch .{};
},
else => {