build: shared object is a dylib on macOS

pull/8895/head
Mitchell Hashimoto 2025-09-23 15:15:15 -07:00
parent 3d04fbb451
commit def4969aff
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 18 additions and 5 deletions

View File

@ -101,9 +101,8 @@ pub fn build(b: *std.Build) !void {
const libghostty_vt_shared = try buildpkg.GhosttyLibVt.initShared(
b,
&mod,
&deps,
);
libghostty_vt_shared.install(libvt_step, "libghostty-vt.so");
libghostty_vt_shared.install(libvt_step, "libghostty-vt");
libghostty_vt_shared.installHeader(libvt_step);
// Helpgen

View File

@ -589,6 +589,16 @@ pub fn genericMacOSTarget(
});
}
/// The extension to use for a shared library on the given target.
pub fn sharedLibExt(target: std.Build.ResolvedTarget) []const u8 {
return if (target.result.os.tag.isDarwin())
"dylib"
else if (target.result.os.tag == .windows)
return "dll"
else
return "so";
}
/// The possible entrypoints for the exe artifact. This has no effect on
/// other artifact types (i.e. lib, wasm_module).
///

View File

@ -15,11 +15,14 @@ step: *std.Build.Step,
output: std.Build.LazyPath,
dsym: ?std.Build.LazyPath,
/// Library extension, e.g. "dylib", "so", "dll"
ext: []const u8,
pub fn initShared(
b: *std.Build,
zig: *const GhosttyZig,
deps: *const SharedDeps,
) !GhosttyLibVt {
const target = zig.vt.resolved_target.?;
const lib = b.addSharedLibrary(.{
.name = "ghostty-vt",
.root_module = zig.vt,
@ -27,7 +30,7 @@ pub fn initShared(
// Get our debug symbols
const dsymutil: ?std.Build.LazyPath = dsymutil: {
if (!deps.config.target.result.os.tag.isDarwin()) {
if (!target.result.os.tag.isDarwin()) {
break :dsymutil null;
}
@ -43,6 +46,7 @@ pub fn initShared(
.step = &lib.step,
.output = lib.getEmittedBin(),
.dsym = dsymutil,
.ext = Config.sharedLibExt(target),
};
}
@ -54,7 +58,7 @@ pub fn install(
const b = self.step.owner;
const lib_install = b.addInstallLibFile(
self.output,
name,
b.fmt("{s}.{s}", .{ name, self.ext }),
);
step.dependOn(&lib_install.step);
}