Skip to content

Commit fcb4f79

Browse files
committed
allow for non root options
1 parent c12054e commit fcb4f79

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/build/ModuleDeps.zig

+8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ pub fn add(
9393
const optimize = module.optimize.?;
9494
const resolved_target = target.result;
9595

96+
if (module.import_table.get("options") == null) {
97+
module.addAnonymousImport("options", .{
98+
.root_source_file = b.path("src/noop.zig"),
99+
.target = target,
100+
.optimize = optimize,
101+
});
102+
}
103+
96104
// We maintain a list of our static libraries and return it so that
97105
// we can build a single fat static library for the final app.
98106
var static_libs = LazyPathList.init(b.allocator);

src/build/SharedDeps.zig

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ pub fn add(
9191
// correct to always match our step.
9292
const target = step.root_module.resolved_target.?;
9393
const optimize = step.root_module.optimize.?;
94+
if (step.root_module.import_table.get("options") == null) {
95+
step.root_module.addAnonymousImport("options", .{
96+
.root_source_file = b.path("src/noop.zig"),
97+
.target = target,
98+
.optimize = optimize,
99+
});
100+
}
94101

95102
// We maintain a list of our static libraries and return it so that
96103
// we can build a single fat static library for the final app.

src/noop.zig

Whitespace-only changes.

src/options.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const build_config = @import("build_config.zig");
1010
const root = @import("root");
1111

1212
/// Stdlib-wide options that can be overridden by the root file.
13-
pub const options: type = if (@hasDecl(root, "ghostty_options")) root.ghostty_options else Options;
13+
pub const options: type = if (@hasDecl(root, "ghostty_options")) root.ghostty_options else if (@hasDecl(@import("options"), "ghostty_options")) @import("options").ghostty_options else Options;
1414
const Options = struct {
1515
pub const Renderer = switch (build_config.renderer) {
1616
.metal => Metal,

0 commit comments

Comments
 (0)