mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-18 17:56:09 +03:00
build: make the xcframework step dsym aware, even though we don't use it (#7898)
This was in pursuit of trying to get line numbers in `zig build run` on macOS to work, but I wasn't able to figure that out and this wasn't the right path because static libs can't have dsyms. But, it may still be useful to make the xcframework step dsym aware for future use so I'm PRing this. This also updates our libghostty build steps to use the new `root_module` form which is recommend for Zig 0.14 and we forgot to update long ago.
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
const GhosttyLib = @This();
|
const GhosttyLib = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const RunStep = std.Build.Step.Run;
|
||||||
const Config = @import("Config.zig");
|
const Config = @import("Config.zig");
|
||||||
const SharedDeps = @import("SharedDeps.zig");
|
const SharedDeps = @import("SharedDeps.zig");
|
||||||
const LibtoolStep = @import("LibtoolStep.zig");
|
const LibtoolStep = @import("LibtoolStep.zig");
|
||||||
@ -11,6 +12,7 @@ step: *std.Build.Step,
|
|||||||
|
|
||||||
/// The final static library file
|
/// The final static library file
|
||||||
output: std.Build.LazyPath,
|
output: std.Build.LazyPath,
|
||||||
|
dsym: ?std.Build.LazyPath,
|
||||||
|
|
||||||
pub fn initStatic(
|
pub fn initStatic(
|
||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
@ -18,9 +20,14 @@ pub fn initStatic(
|
|||||||
) !GhosttyLib {
|
) !GhosttyLib {
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "ghostty",
|
.name = "ghostty",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main_c.zig"),
|
.root_source_file = b.path("src/main_c.zig"),
|
||||||
.target = deps.config.target,
|
.target = deps.config.target,
|
||||||
.optimize = deps.config.optimize,
|
.optimize = deps.config.optimize,
|
||||||
|
.strip = deps.config.strip,
|
||||||
|
.omit_frame_pointer = deps.config.strip,
|
||||||
|
.unwind_tables = if (deps.config.strip) .none else .sync,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
|
|
||||||
@ -37,6 +44,7 @@ pub fn initStatic(
|
|||||||
if (!deps.config.target.result.os.tag.isDarwin()) return .{
|
if (!deps.config.target.result.os.tag.isDarwin()) return .{
|
||||||
.step = &lib.step,
|
.step = &lib.step,
|
||||||
.output = lib.getEmittedBin(),
|
.output = lib.getEmittedBin(),
|
||||||
|
.dsym = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a static lib that contains all our dependencies.
|
// Create a static lib that contains all our dependencies.
|
||||||
@ -50,6 +58,9 @@ pub fn initStatic(
|
|||||||
return .{
|
return .{
|
||||||
.step = libtool.step,
|
.step = libtool.step,
|
||||||
.output = libtool.output,
|
.output = libtool.output,
|
||||||
|
|
||||||
|
// Static libraries cannot have dSYMs because they aren't linked.
|
||||||
|
.dsym = null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,16 +70,35 @@ pub fn initShared(
|
|||||||
) !GhosttyLib {
|
) !GhosttyLib {
|
||||||
const lib = b.addSharedLibrary(.{
|
const lib = b.addSharedLibrary(.{
|
||||||
.name = "ghostty",
|
.name = "ghostty",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main_c.zig"),
|
.root_source_file = b.path("src/main_c.zig"),
|
||||||
.target = deps.config.target,
|
.target = deps.config.target,
|
||||||
.optimize = deps.config.optimize,
|
.optimize = deps.config.optimize,
|
||||||
.strip = deps.config.strip,
|
.strip = deps.config.strip,
|
||||||
|
.omit_frame_pointer = deps.config.strip,
|
||||||
|
.unwind_tables = if (deps.config.strip) .none else .sync,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
_ = try deps.add(lib);
|
_ = try deps.add(lib);
|
||||||
|
|
||||||
|
// Get our debug symbols
|
||||||
|
const dsymutil: ?std.Build.LazyPath = dsymutil: {
|
||||||
|
if (!deps.config.target.result.os.tag.isDarwin()) {
|
||||||
|
break :dsymutil null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dsymutil = RunStep.create(b, "dsymutil");
|
||||||
|
dsymutil.addArgs(&.{"dsymutil"});
|
||||||
|
dsymutil.addFileArg(lib.getEmittedBin());
|
||||||
|
dsymutil.addArgs(&.{"-o"});
|
||||||
|
const output = dsymutil.addOutputFileArg("libghostty.dSYM");
|
||||||
|
break :dsymutil output;
|
||||||
|
};
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.step = &lib.step,
|
.step = &lib.step,
|
||||||
.output = lib.getEmittedBin(),
|
.output = lib.getEmittedBin(),
|
||||||
|
.dsym = dsymutil,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +125,10 @@ pub fn initMacOSUniversal(
|
|||||||
return .{
|
return .{
|
||||||
.step = universal.step,
|
.step = universal.step,
|
||||||
.output = universal.output,
|
.output = universal.output,
|
||||||
|
|
||||||
|
// You can't run dsymutil on a universal binary, you have to
|
||||||
|
// do it on the individual binaries.
|
||||||
|
.dsym = null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,20 +64,24 @@ pub fn init(
|
|||||||
.{
|
.{
|
||||||
.library = macos_universal.output,
|
.library = macos_universal.output,
|
||||||
.headers = b.path("include"),
|
.headers = b.path("include"),
|
||||||
|
.dsym = macos_universal.dsym,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.library = ios.output,
|
.library = ios.output,
|
||||||
.headers = b.path("include"),
|
.headers = b.path("include"),
|
||||||
|
.dsym = ios.dsym,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.library = ios_sim.output,
|
.library = ios_sim.output,
|
||||||
.headers = b.path("include"),
|
.headers = b.path("include"),
|
||||||
|
.dsym = ios_sim.dsym,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
.native => &.{.{
|
.native => &.{.{
|
||||||
.library = macos_native.output,
|
.library = macos_native.output,
|
||||||
.headers = b.path("include"),
|
.headers = b.path("include"),
|
||||||
|
.dsym = macos_native.dsym,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,9 @@ pub const Library = struct {
|
|||||||
|
|
||||||
/// Path to a directory with the headers.
|
/// Path to a directory with the headers.
|
||||||
headers: LazyPath,
|
headers: LazyPath,
|
||||||
|
|
||||||
|
/// Path to a debug symbols file (.dSYM) if available.
|
||||||
|
dsym: ?LazyPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
step: *Step,
|
step: *Step,
|
||||||
@ -52,6 +55,10 @@ pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep {
|
|||||||
run.addFileArg(lib.library);
|
run.addFileArg(lib.library);
|
||||||
run.addArg("-headers");
|
run.addArg("-headers");
|
||||||
run.addFileArg(lib.headers);
|
run.addFileArg(lib.headers);
|
||||||
|
if (lib.dsym) |dsym| {
|
||||||
|
run.addArg("-debug-symbols");
|
||||||
|
run.addFileArg(dsym);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
run.addArg("-output");
|
run.addArg("-output");
|
||||||
run.addArg(opts.out_path);
|
run.addArg(opts.out_path);
|
||||||
|
Reference in New Issue
Block a user