diff --git a/build.zig b/build.zig index c6c461b4c..b515ba251 100644 --- a/build.zig +++ b/build.zig @@ -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(); diff --git a/src/build/GhosttyLibVt.zig b/src/build/GhosttyLibVt.zig index eda49a38d..9c995952a 100644 --- a/src/build/GhosttyLibVt.zig +++ b/src/build/GhosttyLibVt.zig @@ -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); +}