mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-31 12:49:03 +00:00
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. Key parts: * In addition to its previous responsibilities, the global state now houses state for global I/O implementations and the process environment. It is now also utilized in the main application along with the C library. Where necessary, global state is isolated from key parts of the implementation (e.g., in libghostty subsystems), and it's expected that this list will grow. * We currently manage our own C translation layer where necessary. In these cases, cImport has been removed in favor of the new external translate-c package. Due to fixes that have needed be made to properly translate the dependencies that were swapped out, as mentioned, we have had to backport fixes from the current translate-c package (and the upstream Arocc dependency). We will host this ourselves until Zig 0.17.0 is released with these fixes. * Where necessary (only a small number of cases), some stdlib code from 0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in lib/compat. Co-authored-by: Leah Amelia Chen <hi@pluie.me>
78 lines
2.0 KiB
Zig
78 lines
2.0 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const lib = b.addLibrary(.{
|
|
.name = "z",
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
}),
|
|
.linkage = .static,
|
|
});
|
|
if (target.result.os.tag.isDarwin()) {
|
|
const apple_sdk = @import("apple_sdk");
|
|
try apple_sdk.addPaths(b, lib);
|
|
}
|
|
|
|
if (b.lazyDependency("zlib", .{})) |upstream| {
|
|
lib.root_module.addIncludePath(upstream.path(""));
|
|
lib.installHeadersDirectory(
|
|
upstream.path(""),
|
|
"",
|
|
.{ .include_extensions = &.{".h"} },
|
|
);
|
|
|
|
var flags: std.ArrayList([]const u8) = .empty;
|
|
defer flags.deinit(b.allocator);
|
|
try flags.appendSlice(b.allocator, &.{
|
|
"-DHAVE_SYS_TYPES_H",
|
|
"-DHAVE_STDINT_H",
|
|
"-DHAVE_STDDEF_H",
|
|
});
|
|
if (target.result.abi == .msvc) {
|
|
try flags.appendSlice(b.allocator, &.{
|
|
"-fno-sanitize=undefined",
|
|
"-fno-sanitize-trap=undefined",
|
|
});
|
|
}
|
|
if (target.result.os.tag != .windows) {
|
|
try flags.append(b.allocator, "-DZ_HAVE_UNISTD_H");
|
|
}
|
|
if (target.result.abi == .msvc) {
|
|
try flags.appendSlice(b.allocator, &.{
|
|
"-D_CRT_SECURE_NO_DEPRECATE",
|
|
"-D_CRT_NONSTDC_NO_DEPRECATE",
|
|
});
|
|
}
|
|
lib.root_module.addCSourceFiles(.{
|
|
.root = upstream.path(""),
|
|
.files = srcs,
|
|
.flags = flags.items,
|
|
});
|
|
}
|
|
|
|
b.installArtifact(lib);
|
|
}
|
|
|
|
const srcs: []const []const u8 = &.{
|
|
"adler32.c",
|
|
"compress.c",
|
|
"crc32.c",
|
|
"deflate.c",
|
|
"gzclose.c",
|
|
"gzlib.c",
|
|
"gzread.c",
|
|
"gzwrite.c",
|
|
"inflate.c",
|
|
"infback.c",
|
|
"inftrees.c",
|
|
"inffast.c",
|
|
"trees.c",
|
|
"uncompr.c",
|
|
"zutil.c",
|
|
};
|