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