refactor(build): simplify dependency detection logic
- Removes unnecessary marker constant from build.zig that existed solely to signal build root status - Uses filesystem check (@src().file access) instead of compile-time declaration lookup to detect when ghostty is a dependency - Same behavior with less indirection: file resolves from build root only when ghostty is the main projectpull/9914/head
parent
1d7fe9e70d
commit
a0a915a06f
|
|
@ -318,8 +318,3 @@ pub fn build(b: *std.Build) !void {
|
|||
try translations_step.addError("cannot update translations when i18n is disabled", .{});
|
||||
}
|
||||
}
|
||||
|
||||
/// Marker used by Config.zig to detect if ghostty is the build root.
|
||||
/// This avoids running logic such as Git tag checking when Ghostty
|
||||
/// is used as a dependency.
|
||||
pub const _ghostty_build_root = true;
|
||||
|
|
|
|||
|
|
@ -219,20 +219,14 @@ pub fn init(b: *std.Build, appVersion: []const u8) !Config {
|
|||
else version: {
|
||||
const app_version = try std.SemanticVersion.parse(appVersion);
|
||||
|
||||
// Detect if ghostty is being built as a dependency by checking if the
|
||||
// build root has our marker. When used as a dependency, we skip git
|
||||
// detection entirely to avoid reading the downstream project's git state.
|
||||
const is_dependency = !@hasDecl(
|
||||
@import("root"),
|
||||
"_ghostty_build_root",
|
||||
);
|
||||
if (is_dependency) {
|
||||
break :version .{
|
||||
// Is ghostty a dependency? If so, skip git detection.
|
||||
// @src().file won't resolve from b.build_root unless ghostty
|
||||
// is the project being built.
|
||||
b.build_root.handle.access(@src().file, .{}) catch break :version .{
|
||||
.major = app_version.major,
|
||||
.minor = app_version.minor,
|
||||
.patch = app_version.patch,
|
||||
};
|
||||
}
|
||||
|
||||
// If no explicit version is given, we try to detect it from git.
|
||||
const vsn = GitVersion.detect(b) catch |err| switch (err) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue