build: make build_options generally available
parent
6893024c51
commit
5a29dd3ef5
|
|
@ -8,6 +8,7 @@ const builtin = @import("builtin");
|
|||
const ApprtRuntime = @import("../apprt/runtime.zig").Runtime;
|
||||
const FontBackend = @import("../font/backend.zig").Backend;
|
||||
const RendererBackend = @import("../renderer/backend.zig").Backend;
|
||||
const TerminalBuildOptions = @import("../terminal/build_options.zig").Options;
|
||||
const XCFramework = @import("GhosttyXCFramework.zig");
|
||||
const WasmTarget = @import("../os/wasm/target.zig").Target;
|
||||
const expandPath = @import("../os/path.zig").expand;
|
||||
|
|
@ -490,6 +491,23 @@ pub fn addOptions(self: *const Config, step: *std.Build.Step.Options) !void {
|
|||
);
|
||||
}
|
||||
|
||||
/// Returns the build options for the terminal module. This assumes a
|
||||
/// Ghostty executable being built. Callers should modify this as needed.
|
||||
pub fn terminalOptions(self: *const Config) TerminalBuildOptions {
|
||||
return .{
|
||||
.artifact = .ghostty,
|
||||
.simd = self.simd,
|
||||
.oniguruma = true,
|
||||
.slow_runtime_safety = switch (self.optimize) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe,
|
||||
.ReleaseSmall,
|
||||
.ReleaseFast,
|
||||
=> false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns a baseline CPU target retaining all the other CPU configs.
|
||||
pub fn baselineTarget(self: *const Config) std.Build.ResolvedTarget {
|
||||
// Set our cpu model as baseline. There may need to be other modifications
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ const std = @import("std");
|
|||
const Config = @import("Config.zig");
|
||||
const SharedDeps = @import("SharedDeps.zig");
|
||||
|
||||
const vt_options = @import("../terminal/build_options.zig");
|
||||
|
||||
vt: *std.Build.Module,
|
||||
|
||||
pub fn init(
|
||||
|
|
@ -15,6 +13,18 @@ pub fn init(
|
|||
cfg: *const Config,
|
||||
deps: *const SharedDeps,
|
||||
) !GhosttyZig {
|
||||
// General build options
|
||||
const general_options = b.addOptions();
|
||||
try cfg.addOptions(general_options);
|
||||
|
||||
// Terminal module build options
|
||||
var vt_options = cfg.terminalOptions();
|
||||
vt_options.artifact = .lib;
|
||||
// We presently don't allow Oniguruma in our Zig module at all.
|
||||
// We should expose this as a build option in the future so we can
|
||||
// conditionally do this.
|
||||
vt_options.oniguruma = false;
|
||||
|
||||
const vt = b.addModule("ghostty-vt", .{
|
||||
.root_source_file = b.path("src/lib_vt.zig"),
|
||||
.target = cfg.target,
|
||||
|
|
@ -24,23 +34,8 @@ pub fn init(
|
|||
.link_libc = if (cfg.simd) true else null,
|
||||
.link_libcpp = if (cfg.simd) true else null,
|
||||
});
|
||||
vt_options.addOptions(b, vt, .{
|
||||
.artifact = .lib,
|
||||
.simd = cfg.simd,
|
||||
|
||||
// We presently don't allow Oniguruma in our Zig module at all.
|
||||
// We should expose this as a build option in the future so we can
|
||||
// conditionally do this.
|
||||
.oniguruma = false,
|
||||
|
||||
.slow_runtime_safety = switch (cfg.optimize) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe,
|
||||
.ReleaseSmall,
|
||||
.ReleaseFast,
|
||||
=> false,
|
||||
},
|
||||
});
|
||||
vt.addOptions("build_options", general_options);
|
||||
vt_options.add(b, vt);
|
||||
|
||||
// We always need unicode tables
|
||||
deps.unicode_tables.addModuleImport(vt);
|
||||
|
|
|
|||
|
|
@ -108,20 +108,7 @@ pub fn add(
|
|||
step.root_module.addOptions("build_options", self.options);
|
||||
|
||||
// Every exe needs the terminal options
|
||||
{
|
||||
const vt_options = @import("../terminal/build_options.zig");
|
||||
vt_options.addOptions(b, step.root_module, .{
|
||||
.artifact = .ghostty,
|
||||
.simd = self.config.simd,
|
||||
.slow_runtime_safety = switch (optimize) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe,
|
||||
.ReleaseSmall,
|
||||
.ReleaseFast,
|
||||
=> false,
|
||||
},
|
||||
});
|
||||
}
|
||||
self.config.terminalOptions().add(b, step.root_module);
|
||||
|
||||
// Freetype
|
||||
_ = b.systemIntegrationOption("freetype", .{}); // Shows it in help
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
|
||||
pub const Options = struct {
|
||||
/// The target artifact to build. This will gate some functionality.
|
||||
artifact: Artifact = .ghostty,
|
||||
artifact: Artifact,
|
||||
|
||||
/// Whether Oniguruma regex support is available. If this isn't
|
||||
/// available, some features will be disabled. This may be outdated,
|
||||
|
|
@ -11,17 +11,36 @@ pub const Options = struct {
|
|||
/// - Kitty graphics protocol
|
||||
/// - Tmux control mode
|
||||
///
|
||||
oniguruma: bool = true,
|
||||
oniguruma: bool,
|
||||
|
||||
/// Whether to build SIMD-accelerated code paths. This pulls in more
|
||||
/// build-time dependencies and adds libc as a runtime dependency,
|
||||
/// but results in significant performance improvements.
|
||||
simd: bool = true,
|
||||
simd: bool,
|
||||
|
||||
/// True if we should enable the "slow" runtime safety checks. These
|
||||
/// are runtime safety checks that are slower than typical and should
|
||||
/// generally be disabled in production builds.
|
||||
slow_runtime_safety: bool = false,
|
||||
slow_runtime_safety: bool,
|
||||
|
||||
/// Add the required build options for the terminal module.
|
||||
pub fn add(
|
||||
self: Options,
|
||||
b: *std.Build,
|
||||
m: *std.Build.Module,
|
||||
) void {
|
||||
const opts = b.addOptions();
|
||||
opts.addOption(Artifact, "artifact", self.artifact);
|
||||
opts.addOption(bool, "oniguruma", self.oniguruma);
|
||||
opts.addOption(bool, "simd", self.simd);
|
||||
opts.addOption(bool, "slow_runtime_safety", self.slow_runtime_safety);
|
||||
|
||||
// These are synthesized based on other options.
|
||||
opts.addOption(bool, "kitty_graphics", self.oniguruma);
|
||||
opts.addOption(bool, "tmux_control_mode", self.oniguruma);
|
||||
|
||||
m.addOptions("terminal_options", opts);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Artifact = enum {
|
||||
|
|
@ -31,22 +50,3 @@ pub const Artifact = enum {
|
|||
/// libghostty-vt, Zig module
|
||||
lib,
|
||||
};
|
||||
|
||||
/// Add the required build options for the terminal module.
|
||||
pub fn addOptions(
|
||||
b: *std.Build,
|
||||
m: *std.Build.Module,
|
||||
v: Options,
|
||||
) void {
|
||||
const opts = b.addOptions();
|
||||
opts.addOption(Artifact, "artifact", v.artifact);
|
||||
opts.addOption(bool, "oniguruma", v.oniguruma);
|
||||
opts.addOption(bool, "simd", v.simd);
|
||||
opts.addOption(bool, "slow_runtime_safety", v.slow_runtime_safety);
|
||||
|
||||
// These are synthesized based on other options.
|
||||
opts.addOption(bool, "kitty_graphics", v.oniguruma);
|
||||
opts.addOption(bool, "tmux_control_mode", v.oniguruma);
|
||||
|
||||
m.addOptions("terminal_options", opts);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue