build: add pkg-config for libghostty-vt

This commit is contained in:
Mitchell Hashimoto
2025-09-24 12:22:04 -07:00
parent 0944f051aa
commit 513cdf667b
2 changed files with 33 additions and 0 deletions

View File

@@ -104,6 +104,8 @@ pub fn build(b: *std.Build) !void {
); );
libghostty_vt_shared.install(libvt_step); libghostty_vt_shared.install(libvt_step);
libghostty_vt_shared.install(b.getInstallStep()); libghostty_vt_shared.install(b.getInstallStep());
libghostty_vt_shared.installPkgConfig(libvt_step);
libghostty_vt_shared.installPkgConfig(b.getInstallStep());
// Helpgen // Helpgen
if (config.emit_helpgen) deps.help_strings.install(); if (config.emit_helpgen) deps.help_strings.install();

View File

@@ -17,6 +17,7 @@ artifact: *std.Build.Step.InstallArtifact,
/// The final library file /// The final library file
output: std.Build.LazyPath, output: std.Build.LazyPath,
dsym: ?std.Build.LazyPath, dsym: ?std.Build.LazyPath,
pkg_config: std.Build.LazyPath,
pub fn initShared( pub fn initShared(
b: *std.Build, b: *std.Build,
@@ -46,11 +47,29 @@ pub fn initShared(
break :dsymutil output; break :dsymutil output;
}; };
// pkg-config
const pc: std.Build.LazyPath = pc: {
const wf = b.addWriteFiles();
break :pc wf.add("libghostty-vt.pc", b.fmt(
\\prefix={s}
\\includedir=${{prefix}}/include
\\libdir=${{prefix}}/lib
\\
\\Name: libghostty-vt
\\URL: https://github.com/ghostty-org/ghostty
\\Description: Ghostty VT library
\\Version: 0.1.0
\\Cflags: -I${{includedir}}
\\Libs: -L${{libdir}} -lghostty-vt
, .{b.install_prefix}));
};
return .{ return .{
.step = &lib.step, .step = &lib.step,
.artifact = b.addInstallArtifact(lib, .{}), .artifact = b.addInstallArtifact(lib, .{}),
.output = lib.getEmittedBin(), .output = lib.getEmittedBin(),
.dsym = dsymutil, .dsym = dsymutil,
.pkg_config = pc,
}; };
} }
@@ -60,3 +79,15 @@ pub fn install(
) void { ) void {
step.dependOn(&self.artifact.step); step.dependOn(&self.artifact.step);
} }
pub fn installPkgConfig(
self: *const GhosttyLibVt,
step: *std.Build.Step,
) void {
const b = step.owner;
step.dependOn(&b.addInstallFileWithDir(
self.pkg_config,
.prefix,
"share/pkgconfig/libghostty-vt.pc",
).step);
}