Skip to content

Commit f46a36f

Browse files
committed
allow for non root options
1 parent c8b79ae commit f46a36f

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

build.zig

+6
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,9 @@ fn addDeps(
10911091
const exe_options = b.addOptions();
10921092
try config.addOptions(exe_options);
10931093
step.root_module.addOptions("build_options", exe_options);
1094+
if (step.root_module.import_table.get("options") == null) {
1095+
step.root_module.addAnonymousImport("options", .{ .root_source_file = b.path("src/noop.zig") });
1096+
}
10941097

10951098
// We maintain a list of our static libraries and return it so that
10961099
// we can build a single fat static library for the final app.
@@ -1925,6 +1928,9 @@ fn addModuleDeps(
19251928
step: *std.Build.Module,
19261929
config: BuildConfig,
19271930
) !LazyPathList {
1931+
if (step.import_table.get("options") == null) {
1932+
step.addAnonymousImport("options", .{ .root_source_file = b.path("src/noop.zig") });
1933+
}
19281934
// All object targets get access to a standard build_options module
19291935
const exe_options = b.addOptions();
19301936
try config.addOptions(exe_options);

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)