mirror of https://github.com/fairyglade/ly.git
Allow building without X11 support
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
0ee28927cf
commit
8c69472065
13
build.zig
13
build.zig
|
@ -13,9 +13,9 @@ comptime {
|
|||
}
|
||||
|
||||
const ly_version = std.SemanticVersion{ .major = 1, .minor = 1, .patch = 0 };
|
||||
|
||||
var dest_directory: []const u8 = undefined;
|
||||
var data_directory: []const u8 = undefined;
|
||||
var default_tty: u8 = undefined;
|
||||
var exe_name: []const u8 = undefined;
|
||||
|
||||
const ProgressNode = if (current_zig.minor == 12) *std.Progress.Node else std.Progress.Node;
|
||||
|
@ -23,21 +23,20 @@ const ProgressNode = if (current_zig.minor == 12) *std.Progress.Node else std.Pr
|
|||
pub fn build(b: *std.Build) !void {
|
||||
dest_directory = b.option([]const u8, "dest_directory", "Specify a destination directory for installation") orelse "";
|
||||
data_directory = b.option([]const u8, "data_directory", "Specify a default data directory (default is /etc/ly). This path gets embedded into the binary") orelse "/etc/ly";
|
||||
default_tty = b.option(u8, "default_tty", "set default TTY") orelse 2;
|
||||
|
||||
exe_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly";
|
||||
|
||||
const bin_directory = try b.allocator.dupe(u8, data_directory);
|
||||
data_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, data_directory });
|
||||
|
||||
const build_options = b.addOptions();
|
||||
build_options.addOption([]const u8, "data_directory", bin_directory);
|
||||
|
||||
const version_str = try getVersionStr(b, "ly", ly_version);
|
||||
const default_tty = b.option(u8, "default_tty", "Set the TTY (default is 2)") orelse 2;
|
||||
const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support (default is on)") orelse true;
|
||||
|
||||
build_options.addOption([]const u8, "data_directory", bin_directory);
|
||||
build_options.addOption([]const u8, "version", version_str);
|
||||
|
||||
build_options.addOption(u8, "tty", default_tty);
|
||||
build_options.addOption(bool, "enable_x11_support", enable_x11_support);
|
||||
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
@ -59,7 +58,7 @@ pub fn build(b: *std.Build) !void {
|
|||
|
||||
exe.addIncludePath(b.path("include"));
|
||||
exe.linkSystemLibrary("pam");
|
||||
exe.linkSystemLibrary("xcb");
|
||||
if (enable_x11_support) exe.linkSystemLibrary("xcb");
|
||||
exe.linkLibC();
|
||||
|
||||
// HACK: Only fails with ReleaseSafe, so we'll override it.
|
||||
|
|
|
@ -45,6 +45,7 @@ insert = insert
|
|||
login = login
|
||||
logout = logged out
|
||||
normal = normal
|
||||
no_x11_support = x11 support disabled at compile-time
|
||||
numlock = numlock
|
||||
password = password
|
||||
restart = reboot
|
||||
|
|
|
@ -45,6 +45,7 @@ insert = insertion
|
|||
login = identifiant
|
||||
logout = déconnecté
|
||||
normal = normal
|
||||
no_x11_support = support pour x11 désactivé lors de la compilation
|
||||
numlock = verr.num
|
||||
password = mot de passe
|
||||
restart = redémarrer
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const build_options = @import("build_options");
|
||||
const enums = @import("enums.zig");
|
||||
const interop = @import("interop.zig");
|
||||
const TerminalBuffer = @import("tui/TerminalBuffer.zig");
|
||||
|
@ -142,7 +143,7 @@ fn startSession(
|
|||
switch (current_environment.display_server) {
|
||||
.wayland => try executeWaylandCmd(pwd.pw_shell, config.wayland_cmd, current_environment.cmd),
|
||||
.shell => try executeShellCmd(pwd.pw_shell),
|
||||
.xinitrc, .x11 => {
|
||||
.xinitrc, .x11 => if (build_options.enable_x11_support) {
|
||||
var vt_buf: [5]u8 = undefined;
|
||||
const vt = try std.fmt.bufPrint(&vt_buf, "vt{d}", .{config.tty});
|
||||
try executeX11Cmd(pwd.pw_shell, pwd.pw_dir, config, current_environment.cmd, vt);
|
||||
|
|
|
@ -45,6 +45,7 @@ insert: []const u8 = "insert",
|
|||
login: []const u8 = "login:",
|
||||
logout: []const u8 = "logged out",
|
||||
normal: []const u8 = "normal",
|
||||
no_x11_support: []const u8 = "x11 support disabled at compile-time",
|
||||
numlock: []const u8 = "numlock",
|
||||
other: []const u8 = "other",
|
||||
password: []const u8 = "password:",
|
||||
|
|
15
src/main.zig
15
src/main.zig
|
@ -128,6 +128,8 @@ pub fn main() !void {
|
|||
}
|
||||
}
|
||||
|
||||
if (!build_options.enable_x11_support) try info_line.setText(lang.no_x11_support);
|
||||
|
||||
interop.setNumlock(config.numlock) catch {};
|
||||
|
||||
if (config.initial_info_text) |text| {
|
||||
|
@ -178,14 +180,17 @@ pub fn main() !void {
|
|||
desktop.addEnvironment(.{ .Name = lang.shell }, "", .shell) catch {
|
||||
try info_line.setText(lang.err_alloc);
|
||||
};
|
||||
if (config.xinitrc) |xinitrc| {
|
||||
desktop.addEnvironment(.{ .Name = lang.xinitrc, .Exec = xinitrc }, "", .xinitrc) catch {
|
||||
try info_line.setText(lang.err_alloc);
|
||||
};
|
||||
|
||||
if (build_options.enable_x11_support) {
|
||||
if (config.xinitrc) |xinitrc| {
|
||||
desktop.addEnvironment(.{ .Name = lang.xinitrc, .Exec = xinitrc }, "", .xinitrc) catch {
|
||||
try info_line.setText(lang.err_alloc);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
try desktop.crawl(config.waylandsessions, .wayland);
|
||||
try desktop.crawl(config.xsessions, .x11);
|
||||
if (build_options.enable_x11_support) try desktop.crawl(config.xsessions, .x11);
|
||||
|
||||
var login = try Text.init(allocator, &buffer, config.max_login_len);
|
||||
defer login.deinit();
|
||||
|
|
Loading…
Reference in New Issue