build: add pkg-config for libghostty-vt

pull/8895/head
Mitchell Hashimoto 2025-09-24 12:22:04 -07:00
parent 0944f051aa
commit 513cdf667b
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
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(b.getInstallStep());
libghostty_vt_shared.installPkgConfig(libvt_step);
libghostty_vt_shared.installPkgConfig(b.getInstallStep());
// Helpgen
if (config.emit_helpgen) deps.help_strings.install();

View File

@ -17,6 +17,7 @@ artifact: *std.Build.Step.InstallArtifact,
/// The final library file
output: std.Build.LazyPath,
dsym: ?std.Build.LazyPath,
pkg_config: std.Build.LazyPath,
pub fn initShared(
b: *std.Build,
@ -46,11 +47,29 @@ pub fn initShared(
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 .{
.step = &lib.step,
.artifact = b.addInstallArtifact(lib, .{}),
.output = lib.getEmittedBin(),
.dsym = dsymutil,
.pkg_config = pc,
};
}
@ -60,3 +79,15 @@ pub fn install(
) void {
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);
}