terminal: always use C ABI for now

This commit is contained in:
Mitchell Hashimoto
2026-03-25 08:40:27 -07:00
parent 3c9c3a4f54
commit ac85a2f3d6
3 changed files with 11 additions and 9 deletions

View File

@@ -264,4 +264,7 @@ test {
_ = terminal;
_ = @import("lib/main.zig");
@import("std").testing.refAllDecls(input);
if (comptime terminal.options.c_abi) {
_ = terminal.c_api;
}
}

View File

@@ -5,14 +5,12 @@ const lib = @import("../lib/main.zig");
/// The target for the terminal lib in particular.
pub const target: lib.Target = if (build_options.c_abi) .c else .zig;
/// The calling convention to use for C APIs. If we're not building for
/// C ABI then we use auto which allows our C APIs to be cleanly called
/// by Zig. This is required because we modify our struct layouts based
/// on C ABI too.
pub const calling_conv: std.builtin.CallingConvention = if (build_options.c_abi)
.c
else
.auto;
/// The calling convention to use for C APIs.
///
/// This is always .c for now. I want to make this "Zig" when we're not
/// building the C ABI but there are bigger issues we need to resolve to
/// make that possible (change it and see for yourself).
pub const calling_conv: std.builtin.CallingConvention = .c;
/// Forwarded decls from lib that are used.
pub const alloc = lib.allocator;

View File

@@ -73,7 +73,8 @@ pub const Attribute = sgr.Attribute;
pub const Options = @import("build_options.zig").Options;
pub const options = @import("terminal_options");
pub const c_api = @import("c/main.zig");
/// This is set to true when we're building the C library.
pub const c_api = if (options.c_abi) @import("c/main.zig") else void;
test {
@import("std").testing.refAllDecls(@This());