mirror of
https://github.com/fairyglade/ly.git
synced 2026-05-06 07:10:36 +00:00
Update to Zig 0.16.0 (#962)
Signed-off-by: AnErrupTion <anerruption@disroot.org> ## What are the changes about? Ports the code base to Zig 0.16.0. ## What existing issue does this resolve? N/A ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/962
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const Translator = @import("translate_c").Translator;
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
@@ -12,6 +13,29 @@ pub fn build(b: *std.Build) void {
|
||||
const zigini = b.dependency("zigini", .{ .target = target, .optimize = optimize });
|
||||
mod.addImport("zigini", zigini.module("zigini"));
|
||||
|
||||
const translate_c = b.dependency("translate_c", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
addCImport(b, mod, translate_c, target, optimize, "pam", "#include <security/pam_appl.h>");
|
||||
addCImport(b, mod, translate_c, target, optimize, "utmp", "#include <utmpx.h>");
|
||||
addCImport(b, mod, translate_c, target, optimize, "xcb", "#include <xcb/xcb.h>");
|
||||
if (target.result.os.tag == .freebsd) {
|
||||
addCImport(b, mod, translate_c, target, optimize, "pwd",
|
||||
\\#include <pwd.h>
|
||||
\\#include <sys/types.h>
|
||||
\\#include <login_cap.h>
|
||||
);
|
||||
} else {
|
||||
addCImport(b, mod, translate_c, target, optimize, "pwd", "#include <pwd.h>");
|
||||
}
|
||||
addCImport(b, mod, translate_c, target, optimize, "stdlib", "#include <stdlib.h>");
|
||||
addCImport(b, mod, translate_c, target, optimize, "unistd", "#include <unistd.h>");
|
||||
addCImport(b, mod, translate_c, target, optimize, "grp", "#include <grp.h>");
|
||||
addCImport(b, mod, translate_c, target, optimize, "system_time", "#include <sys/time.h>");
|
||||
addCImport(b, mod, translate_c, target, optimize, "time", "#include <time.h>");
|
||||
|
||||
const mod_tests = b.addTest(.{
|
||||
.root_module = mod,
|
||||
});
|
||||
@@ -20,3 +44,20 @@ pub fn build(b: *std.Build) void {
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&run_mod_tests.step);
|
||||
}
|
||||
|
||||
fn addCImport(
|
||||
b: *std.Build,
|
||||
mod: *std.Build.Module,
|
||||
translate_c: *std.Build.Dependency,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
comptime name: []const u8,
|
||||
comptime bytes: []const u8,
|
||||
) void {
|
||||
const pam: Translator = .init(translate_c, .{
|
||||
.c_source_file = b.addWriteFiles().add(name ++ ".h", bytes),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
mod.addImport(name, pam.mod);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user