Revert "build: options to enable/disable terminfo & termcap install"

This reverts commit 8f49a227b7c352083b0815e7818db900402513e0.
This commit is contained in:
Mitchell Hashimoto
2025-01-23 19:38:13 -08:00
parent 4b82e0aa2b
commit c0eb6985ee
3 changed files with 23 additions and 49 deletions

View File

@ -55,8 +55,6 @@ emit_helpgen: bool = false,
emit_docs: bool = false, emit_docs: bool = false,
emit_webdata: bool = false, emit_webdata: bool = false,
emit_xcframework: bool = false, emit_xcframework: bool = false,
emit_terminfo: bool = false,
emit_termcap: bool = false,
/// Environmental properties /// Environmental properties
env: std.process.EnvMap, env: std.process.EnvMap,
@ -308,32 +306,11 @@ pub fn init(b: *std.Build) !Config {
break :emit_docs path != null; break :emit_docs path != null;
}; };
config.emit_terminfo = b.option(
bool,
"emit-terminfo",
"Install Ghostty terminfo source file",
) orelse switch (target.result.os.tag) {
.windows => true,
else => switch (optimize) {
.Debug => true,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => false,
},
};
config.emit_termcap = b.option(
bool,
"emit-termcap",
"Install Ghostty termcap file",
) orelse false;
config.emit_webdata = b.option( config.emit_webdata = b.option(
bool, bool,
"emit-webdata", "emit-webdata",
"Build the website data for the website.", "Build the website data for the website.",
) orelse switch (optimize) { ) orelse false;
.Debug => true,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => false,
};
config.emit_xcframework = b.option( config.emit_xcframework = b.option(
bool, bool,

View File

@ -23,12 +23,9 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
// Write it // Write it
var wf = b.addWriteFiles(); var wf = b.addWriteFiles();
const source = wf.add("ghostty.terminfo", str.items); const src_source = wf.add("share/terminfo/ghostty.terminfo", str.items);
const src_install = b.addInstallFile(src_source, "share/terminfo/ghostty.terminfo");
if (cfg.emit_terminfo) { try steps.append(&src_install.step);
const source_install = b.addInstallFile(source, "share/terminfo/ghostty.terminfo");
try steps.append(&source_install.step);
}
// Windows doesn't have the binaries below. // Windows doesn't have the binaries below.
if (cfg.target.result.os.tag == .windows) break :terminfo; if (cfg.target.result.os.tag == .windows) break :terminfo;
@ -36,10 +33,10 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
// Convert to termcap source format if thats helpful to people and // Convert to termcap source format if thats helpful to people and
// install it. The resulting value here is the termcap source in case // install it. The resulting value here is the termcap source in case
// that is used for other commands. // that is used for other commands.
if (cfg.emit_termcap) { {
const run_step = RunStep.create(b, "infotocap"); const run_step = RunStep.create(b, "infotocap");
run_step.addArgs(&.{ "infotocap", "-" }); run_step.addArg("infotocap");
run_step.setStdIn(.{ .lazy_path = source }); run_step.addFileArg(src_source);
const out_source = run_step.captureStdOut(); const out_source = run_step.captureStdOut();
_ = run_step.captureStdErr(); // so we don't see stderr _ = run_step.captureStdErr(); // so we don't see stderr
@ -51,21 +48,24 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
{ {
const run_step = RunStep.create(b, "tic"); const run_step = RunStep.create(b, "tic");
run_step.addArgs(&.{ "tic", "-x", "-o" }); run_step.addArgs(&.{ "tic", "-x", "-o" });
const path = run_step.addOutputDirectoryArg("share/terminfo"); const path = run_step.addOutputFileArg("terminfo");
run_step.addArg("-"); run_step.addFileArg(src_source);
run_step.setStdIn(.{ .lazy_path = source });
_ = run_step.captureStdErr(); // so we don't see stderr _ = run_step.captureStdErr(); // so we don't see stderr
try steps.append(&run_step.step); // Depend on the terminfo source install step so that Zig build
// creates the "share" directory for us.
run_step.step.dependOn(&src_install.step);
// Use cp -R instead of Step.InstallDir because we need to preserve {
// symlinks in the terminfo database. Zig's InstallDir step doesn't // Use cp -R instead of Step.InstallDir because we need to preserve
// handle symlinks correctly yet. // symlinks in the terminfo database. Zig's InstallDir step doesn't
const copy_step = RunStep.create(b, "copy terminfo db"); // handle symlinks correctly yet.
copy_step.addArgs(&.{ "cp", "-R" }); const copy_step = RunStep.create(b, "copy terminfo db");
copy_step.addFileArg(path); copy_step.addArgs(&.{ "cp", "-R" });
copy_step.addArg(b.fmt("{s}/share", .{b.install_path})); copy_step.addFileArg(path);
try steps.append(&copy_step.step); copy_step.addArg(b.fmt("{s}/share", .{b.install_path}));
try steps.append(&copy_step.step);
}
} }
} }

View File

@ -21,10 +21,7 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 {
// This is the sentinel value we look for in the path to know // This is the sentinel value we look for in the path to know
// we've found the resources directory. // we've found the resources directory.
const sentinel = switch (comptime builtin.target.os.tag) { const sentinel = "terminfo/ghostty.termcap";
.windows => "terminfo/ghostty.terminfo",
else => "terminfo/x/xterm-ghostty",
};
// Get the path to our running binary // Get the path to our running binary
var exe_buf: [std.fs.max_path_bytes]u8 = undefined; var exe_buf: [std.fs.max_path_bytes]u8 = undefined;