ghostty/src/build_config.zig
2023-02-19 10:44:55 -08:00

44 lines
1.3 KiB
Zig

//! Build options, available at comptime. Used to configure features. This
//! will reproduce some of the fields from builtin and build_options just
//! so we can limit the amount of imports we need AND give us the ability
//! to shim logic and values into them later.
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
/// The artifact we're producing. This can be used to determine if we're
/// building a standalone exe, an embedded lib, etc.
pub const artifact = Artifact.detect();
/// Whether our devmode UI is enabled or not. This requires imgui to be
/// compiled.
pub const devmode_enabled = artifact == .exe;
pub const Artifact = enum {
/// Standalone executable
exe,
/// Embeddable library
lib,
/// The WASM-targetted module.
wasm_module,
pub fn detect() Artifact {
if (builtin.target.isWasm()) {
assert(builtin.output_mode == .Obj);
assert(builtin.link_mode == .Static);
return .wasm_module;
}
return switch (builtin.output_mode) {
.Exe => .exe,
.Lib => .lib,
else => {
@compileLog(builtin.output_mode);
@compileError("unsupported artifact output mode");
},
};
}
};