Merge pull request #1879 from ghostty-org/zig13

Zig 0.13
This commit is contained in:
Mitchell Hashimoto
2024-06-24 15:35:30 -07:00
committed by GitHub
30 changed files with 162 additions and 132 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
.direnv/
.flatpak-builder/
zig-cache/
.zig-cache/
zig-out/
/result*
example/*.wasm

View File

@ -1017,7 +1017,7 @@ fn addDeps(
// on x86_64.
if (step.rootModuleTarget().os.tag == .linux) {
const triple = try step.rootModuleTarget().linuxTriple(b.allocator);
step.addLibraryPath(.{ .path = b.fmt("/usr/lib/{s}", .{triple}) });
step.addLibraryPath(.{ .cwd_relative = b.fmt("/usr/lib/{s}", .{triple}) });
}
// C files
@ -1028,11 +1028,31 @@ fn addDeps(
// C++ files
step.linkLibCpp();
step.addIncludePath(b.path("src"));
step.addCSourceFiles(.{ .files = &.{
"src/simd/codepoint_width.cpp",
"src/simd/index_of.cpp",
"src/simd/vt.cpp",
} });
{
// From hwy/detect_targets.h
const HWY_AVX3_SPR: c_int = 1 << 4;
const HWY_AVX3_ZEN4: c_int = 1 << 6;
const HWY_AVX3_DL: c_int = 1 << 7;
const HWY_AVX3: c_int = 1 << 8;
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// To workaround this we just disable AVX512 support completely.
// The performance difference between AVX2 and AVX512 is not
// significant for our use case and AVX512 is very rare on consumer
// hardware anyways.
const HWY_DISABLED_TARGETS: c_int = HWY_AVX3_SPR | HWY_AVX3_ZEN4 | HWY_AVX3_DL | HWY_AVX3;
step.addCSourceFiles(.{
.files = &.{
"src/simd/codepoint_width.cpp",
"src/simd/index_of.cpp",
"src/simd/vt.cpp",
},
.flags = if (step.rootModuleTarget().cpu.arch == .x86_64) &.{
b.fmt("-DHWY_DISABLED_TARGETS={}", .{HWY_DISABLED_TARGETS}),
} else &.{},
});
}
// If we're building a lib we have some different deps
const lib = step.kind == .lib;
@ -1485,7 +1505,7 @@ fn root() []const u8 {
}
/// ANSI escape codes for colored log output
const color_map = std.ComptimeStringMap([]const u8, .{
const color_map = std.StaticStringMap([]const u8).initComptime(.{
&.{ "black", "30m" },
&.{ "blue", "34m" },
&.{ "b", "1m" },

View File

@ -5,25 +5,25 @@
.dependencies = .{
// Zig libs
.libxev = .{
.url = "https://github.com/mitchellh/libxev/archive/efde8a170836334901ed2d59c98bf832eb48ae3a.tar.gz",
.hash = "1220bf10f4fc109ca0b50520075e2e730900956e220adee616a01f3f91bc8a802695",
.url = "https://github.com/mitchellh/libxev/archive/a42b74ae8139738a14148f94543c659ec2d5b92b.tar.gz",
.hash = "1220ff99305b4072365c5b1dfada4ba2fa3dc51b38118f39365cdc63469953840365",
},
.mach_glfw = .{
.url = "https://github.com/mitchellh/mach-glfw/archive/20c773d86df269722d8926f98bc8af26ebd90999.tar.gz",
.hash = "1220d6df7eb57501616e86ed812854164ff02d2f4a0eaa06b8301f32950d8d3e89df",
.url = "https://github.com/mitchellh/mach-glfw/archive/37c2995f31abcf7e8378fba68ddcf4a3faa02de0.tar.gz",
.hash = "12206ed982e709e565d536ce930701a8c07edfd2cfdce428683f3f2a601d37696a62",
.lazy = true,
},
.zig_objc = .{
.url = "https://github.com/mitchellh/zig-objc/archive/9e2174ed9b5a2c11bf1779cf6c819260c8091888.tar.gz",
.hash = "1220014cd3774aa0b18320e6527ed7b3270412c70958ab16a3c55070ffb7f2042f87",
.url = "https://github.com/mitchellh/zig-objc/archive/fe5ac419530cf800294369d996133fe9cd067aec.tar.gz",
.hash = "122034b3e15d582d8d101a7713e5f13c872b8b8eb6d9cb47515b8e34ee75e122630d",
},
.zig_js = .{
.url = "https://github.com/mitchellh/zig-js/archive/d4edb682733aef8dc3933683272bdf7c8b9fe658.tar.gz",
.hash = "1220df81f0e65cc9ccd3628572c611e6f267a71f1bff1be19d50f4ac49ee2a83c324",
.url = "https://github.com/mitchellh/zig-js/archive/d0b8b0a57c52fbc89f9d9fecba75ca29da7dd7d1.tar.gz",
.hash = "12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc",
},
.ziglyph = .{
.url = "https://deps.files.ghostty.dev/ziglyph-0e17bd36a4e882b194a87c283bd78562ea215116.tar.gz",
.hash = "12208553f3f47e51494e187f4c0e6f6b3844e3993436cad4a0e8c4db4e99645967b5",
.url = "https://deps.files.ghostty.dev/ziglyph-b89d43d1e3fb01b6074bc1f7fc980324b04d26a5.tar.gz",
.hash = "12207831bce7d4abce57b5a98e8f3635811cfefd160bca022eb91fe905d36a02cf25",
},
// C libs

6
flake.lock generated
View File

@ -197,11 +197,11 @@
]
},
"locked": {
"lastModified": 1719231019,
"narHash": "sha256-ZHU2A+xs7I5rqDagBtnGPc+GyIwhMaa8Za9h+8qTCiw=",
"lastModified": 1717848532,
"narHash": "sha256-d+xIUvSTreHl8pAmU1fnmkfDTGQYCn2Rb/zOwByxS2M=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "1141abbf0c667677569c887bfbb1500039b5295e",
"rev": "02fc5cc555fc14fda40c42d7c3250efa43812b43",
"type": "github"
},
"original": {

View File

@ -39,13 +39,13 @@
inherit (pkgs-unstable) tracy;
inherit (zls.packages.${system}) zls;
zig = zig.packages.${system}."0.12.1";
zig = zig.packages.${system}."0.13.0";
wraptest = pkgs-stable.callPackage ./nix/wraptest.nix {};
};
packages.${system} = let
mkArgs = optimize: {
inherit (pkgs-unstable) zig_0_12 lib;
inherit (pkgs-unstable) zig_0_13 lib;
inherit optimize;
revision = self.shortRev or self.dirtyShortRev or "dirty";

View File

@ -22,7 +22,7 @@
git,
ncurses,
pkg-config,
zig_0_12,
zig_0_13,
pandoc,
revision ? "dirty",
optimize ? "Debug",
@ -34,7 +34,7 @@
# https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653 is
# ultimately acted on and has made its way to a nixpkgs implementation, this
# can probably be removed in favor of that.
zig012Hook = zig_0_12.hook.overrideAttrs {
zig012Hook = zig_0_13.hook.overrideAttrs {
zig_default_flags = "-Dcpu=baseline -Doptimize=${optimize}";
};
@ -79,7 +79,7 @@
name = "ghostty-cache";
nativeBuildInputs = [
git
zig_0_12.hook
zig_0_13.hook
];
dontConfigure = true;

View File

@ -1,3 +1,3 @@
# This file is auto-generated! check build-support/check-zig-cache-hash.sh for
# more details.
"sha256-C+YVTjCuEDLZYZ9/bXfTI2bYVUKUtmxMQsttEcBJQwM="
"sha256-NqrQqTPssEKMIAVHab06KYsK6lk8pS4zy+o8iT8FCYA="

View File

@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("cimgui", .{
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});
@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void {
}
lib.addIncludePath(imgui.path(""));
module.addIncludePath(.{ .path = "vendor" });
module.addIncludePath(b.path("vendor"));
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -49,7 +49,7 @@ pub fn build(b: *std.Build) !void {
});
}
lib.addCSourceFile(.{ .file = .{ .path = "vendor/cimgui.cpp" }, .flags = flags.items });
lib.addCSourceFile(.{ .file = b.path("vendor/cimgui.cpp"), .flags = flags.items });
lib.addCSourceFile(.{ .file = imgui.path("imgui.cpp"), .flags = flags.items });
lib.addCSourceFile(.{ .file = imgui.path("imgui_draw.cpp"), .flags = flags.items });
lib.addCSourceFile(.{ .file = imgui.path("imgui_demo.cpp"), .flags = flags.items });
@ -80,7 +80,7 @@ pub fn build(b: *std.Build) !void {
}
lib.installHeadersDirectory(
.{ .path = "vendor" },
b.path("vendor"),
"",
.{ .include_extensions = &.{".h"} },
);
@ -89,7 +89,7 @@ pub fn build(b: *std.Build) !void {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void {
) orelse (target.result.os.tag != .windows);
const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true;
const module = b.addModule("fontconfig", .{ .root_source_file = .{ .path = "main.zig" } });
const module = b.addModule("fontconfig", .{ .root_source_file = b.path("main.zig") });
const upstream = b.dependency("fontconfig", .{});
const lib = b.addStaticLibrary(.{
@ -39,9 +39,9 @@ pub fn build(b: *std.Build) !void {
}
lib.addIncludePath(upstream.path(""));
lib.addIncludePath(.{ .path = "override/include" });
lib.addIncludePath(b.path("override/include"));
module.addIncludePath(upstream.path(""));
module.addIncludePath(.{ .path = "override/include" });
module.addIncludePath(b.path("override/include"));
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -172,7 +172,7 @@ pub fn build(b: *std.Build) !void {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false;
const module = b.addModule("freetype", .{ .root_source_file = .{ .path = "main.zig" } });
const module = b.addModule("freetype", .{ .root_source_file = b.path("main.zig") });
const upstream = b.dependency("freetype", .{});
const lib = b.addStaticLibrary(.{
@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void {
}
module.addIncludePath(upstream.path("include"));
module.addIncludePath(.{ .path = "" });
module.addIncludePath(b.path(""));
// Dependencies
const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize });
@ -81,7 +81,7 @@ pub fn build(b: *std.Build) !void {
}),
}
lib.installHeader(.{ .path = "freetype-zig.h" }, "freetype-zig.h");
lib.installHeader(b.path("freetype-zig.h"), "freetype-zig.h");
lib.installHeadersDirectory(
upstream.path("include"),
"",
@ -93,7 +93,7 @@ pub fn build(b: *std.Build) !void {
if (target.query.isNative()) {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("glslang", .{
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});
@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void {
b.installArtifact(lib);
module.addIncludePath(upstream.path(""));
module.addIncludePath(.{ .path = "override" });
module.addIncludePath(b.path("override"));
if (target.result.isDarwin()) {
const apple_sdk = @import("apple_sdk");
try apple_sdk.addPaths(b, module);
@ -24,7 +24,7 @@ pub fn build(b: *std.Build) !void {
if (target.query.isNative()) {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});
@ -52,7 +52,7 @@ fn buildGlslang(
lib.linkLibC();
lib.linkLibCpp();
lib.addIncludePath(upstream.path(""));
lib.addIncludePath(.{ .path = "override" });
lib.addIncludePath(b.path("override"));
if (target.result.isDarwin()) {
const apple_sdk = @import("apple_sdk");
try apple_sdk.addPaths(b, &lib.root_module);

View File

@ -17,7 +17,7 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("harfbuzz", .{});
const module = b.addModule("harfbuzz", .{
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
@ -91,7 +91,7 @@ pub fn build(b: *std.Build) !void {
{
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -7,7 +7,7 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("highway", .{});
const module = b.addModule("highway", .{
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});
@ -95,7 +95,7 @@ pub fn build(b: *std.Build) !void {
{
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -23,7 +23,7 @@ pub fn build(b: *std.Build) !void {
const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize });
lib.linkLibrary(zlib_dep.artifact("z"));
lib.addIncludePath(upstream.path(""));
lib.addIncludePath(.{ .path = "" });
lib.addIncludePath(b.path(""));
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -40,7 +40,7 @@ pub fn build(b: *std.Build) !void {
.flags = flags.items,
});
lib.installHeader(.{ .path = "pnglibconf.h" }, "pnglibconf.h");
lib.installHeader(b.path("pnglibconf.h"), "pnglibconf.h");
lib.installHeadersDirectory(
upstream.path(""),
"",

View File

@ -14,12 +14,12 @@ pub fn build(b: *std.Build) !void {
lib.linkLibC();
lib.addIncludePath(upstream.path("include"));
lib.addIncludePath(.{ .path = "override/include" });
lib.addIncludePath(b.path("override/include"));
if (target.result.os.tag == .windows) {
lib.addIncludePath(.{ .path = "override/config/win32" });
lib.addIncludePath(b.path("override/config/win32"));
lib.linkSystemLibrary("ws2_32");
} else {
lib.addIncludePath(.{ .path = "override/config/posix" });
lib.addIncludePath(b.path("override/config/posix"));
}
var flags = std.ArrayList([]const u8).init(b.allocator);
@ -101,7 +101,7 @@ pub fn build(b: *std.Build) !void {
});
lib.installHeader(
.{ .path = "override/include/libxml/xmlversion.h" },
b.path("override/include/libxml/xmlversion.h"),
"libxml/xmlversion.h",
);
lib.installHeadersDirectory(

View File

@ -7,7 +7,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("macos", .{
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});
@ -21,11 +21,11 @@ pub fn build(b: *std.Build) !void {
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
lib.addCSourceFile(.{
.file = .{ .path = "os/log.c" },
.file = b.path("os/log.c"),
.flags = flags.items,
});
lib.addCSourceFile(.{
.file = .{ .path = "text/ext.c" },
.file = b.path("text/ext.c"),
.flags = flags.items,
});
lib.linkFramework("CoreFoundation");
@ -55,7 +55,7 @@ pub fn build(b: *std.Build) !void {
{
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("oniguruma", .{ .root_source_file = .{ .path = "main.zig" } });
const module = b.addModule("oniguruma", .{ .root_source_file = b.path("main.zig") });
const upstream = b.dependency("oniguruma", .{});
const lib = try buildOniguruma(b, upstream, target, optimize);
@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void {
if (target.query.isNative()) {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -2,52 +2,52 @@ const std = @import("std");
const c = @import("c.zig");
pub const Encoding = opaque {
pub const ascii: *Encoding = @ptrCast(c.ONIG_ENCODING_ASCII);
pub const iso_8859_1: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_1);
pub const iso_8859_2: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_2);
pub const iso_8859_3: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_3);
pub const iso_8859_4: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_4);
pub const iso_8859_5: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_5);
pub const iso_8859_6: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_6);
pub const iso_8859_7: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_7);
pub const iso_8859_8: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_8);
pub const iso_8859_9: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_9);
pub const iso_8859_10: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_10);
pub const iso_8859_11: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_11);
pub const iso_8859_13: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_13);
pub const iso_8859_14: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_14);
pub const iso_8859_15: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_15);
pub const iso_8859_16: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_16);
pub const utf8: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF8);
pub const utf16_be: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF16_BE);
pub const utf16_le: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF16_LE);
pub const utf32_be: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF32_BE);
pub const utf32_le: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF32_LE);
pub const euc_jp: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_JP);
pub const euc_tw: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_TW);
pub const euc_kr: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_KR);
pub const euc_cn: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_CN);
pub const sjis: *Encoding = @ptrCast(c.ONIG_ENCODING_SJIS);
pub const koi8: *Encoding = @ptrCast(c.ONIG_ENCODING_KOI8);
pub const koi8_r: *Encoding = @ptrCast(c.ONIG_ENCODING_KOI8_R);
pub const cp1251: *Encoding = @ptrCast(c.ONIG_ENCODING_CP1251);
pub const big5: *Encoding = @ptrCast(c.ONIG_ENCODING_BIG5);
pub const gb18030: *Encoding = @ptrCast(c.ONIG_ENCODING_GB18030);
pub const ascii: *Encoding = @ptrCast(c.ONIG_ENCODING_ASCII());
pub const iso_8859_1: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_1());
pub const iso_8859_2: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_2());
pub const iso_8859_3: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_3());
pub const iso_8859_4: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_4());
pub const iso_8859_5: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_5());
pub const iso_8859_6: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_6());
pub const iso_8859_7: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_7());
pub const iso_8859_8: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_8());
pub const iso_8859_9: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_9());
pub const iso_8859_10: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_10());
pub const iso_8859_11: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_11());
pub const iso_8859_13: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_13());
pub const iso_8859_14: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_14());
pub const iso_8859_15: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_15());
pub const iso_8859_16: *Encoding = @ptrCast(c.ONIG_ENCODING_ISO_8859_16());
pub const utf8: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF8());
pub const utf16_be: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF16_BE());
pub const utf16_le: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF16_LE());
pub const utf32_be: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF32_BE());
pub const utf32_le: *Encoding = @ptrCast(c.ONIG_ENCODING_UTF32_LE());
pub const euc_jp: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_JP());
pub const euc_tw: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_TW());
pub const euc_kr: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_KR());
pub const euc_cn: *Encoding = @ptrCast(c.ONIG_ENCODING_EUC_CN());
pub const sjis: *Encoding = @ptrCast(c.ONIG_ENCODING_SJIS());
pub const koi8: *Encoding = @ptrCast(c.ONIG_ENCODING_KOI8());
pub const koi8_r: *Encoding = @ptrCast(c.ONIG_ENCODING_KOI8_R());
pub const cp1251: *Encoding = @ptrCast(c.ONIG_ENCODING_CP1251());
pub const big5: *Encoding = @ptrCast(c.ONIG_ENCODING_BIG5());
pub const gb18030: *Encoding = @ptrCast(c.ONIG_ENCODING_GB18030());
};
pub const Syntax = opaque {
pub const default: *Syntax = @ptrCast(c.ONIG_SYNTAX_ONIGURUMA);
pub const asis: *Syntax = @ptrCast(c.ONIG_SYNTAX_ASIS);
pub const posix_basic: *Syntax = @ptrCast(c.ONIG_SYNTAX_POSIX_BASIC);
pub const posix_extended: *Syntax = @ptrCast(c.ONIG_SYNTAX_POSIX_EXTENDED);
pub const emacs: *Syntax = @ptrCast(c.ONIG_SYNTAX_EMACS);
pub const grep: *Syntax = @ptrCast(c.ONIG_SYNTAX_GREP);
pub const gnu_regex: *Syntax = @ptrCast(c.ONIG_SYNTAX_GNU_REGEX);
pub const java: *Syntax = @ptrCast(c.ONIG_SYNTAX_JAVA);
pub const perl: *Syntax = @ptrCast(c.ONIG_SYNTAX_PERL);
pub const perl_ng: *Syntax = @ptrCast(c.ONIG_SYNTAX_PERL_NG);
pub const ruby: *Syntax = @ptrCast(c.ONIG_SYNTAX_RUBY);
pub const oniguruma: *Syntax = @ptrCast(c.ONIG_SYNTAX_ONIGURUMA);
pub const default: *Syntax = @ptrCast(c.ONIG_SYNTAX_ONIGURUMA());
pub const asis: *Syntax = @ptrCast(c.ONIG_SYNTAX_ASIS());
pub const posix_basic: *Syntax = @ptrCast(c.ONIG_SYNTAX_POSIX_BASIC());
pub const posix_extended: *Syntax = @ptrCast(c.ONIG_SYNTAX_POSIX_EXTENDED());
pub const emacs: *Syntax = @ptrCast(c.ONIG_SYNTAX_EMACS());
pub const grep: *Syntax = @ptrCast(c.ONIG_SYNTAX_GREP());
pub const gnu_regex: *Syntax = @ptrCast(c.ONIG_SYNTAX_GNU_REGEX());
pub const java: *Syntax = @ptrCast(c.ONIG_SYNTAX_JAVA());
pub const perl: *Syntax = @ptrCast(c.ONIG_SYNTAX_PERL());
pub const perl_ng: *Syntax = @ptrCast(c.ONIG_SYNTAX_PERL_NG());
pub const ruby: *Syntax = @ptrCast(c.ONIG_SYNTAX_RUBY());
pub const oniguruma: *Syntax = @ptrCast(c.ONIG_SYNTAX_ONIGURUMA());
};
pub const Option = packed struct(c_uint) {

View File

@ -1,6 +1,6 @@
const std = @import("std");
pub fn build(b: *std.Build) !void {
const module = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } });
module.addIncludePath(.{ .path = "../../vendor/glad/include" });
const module = b.addModule("opengl", .{ .root_source_file = b.path("main.zig") });
module.addIncludePath(b.path("../../vendor/glad/include"));
}

View File

@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("pixman", .{ .root_source_file = .{ .path = "main.zig" } });
const module = b.addModule("pixman", .{ .root_source_file = b.path("main.zig") });
const upstream = b.dependency("pixman", .{});
const lib = b.addStaticLibrary(.{
@ -22,9 +22,9 @@ pub fn build(b: *std.Build) !void {
}
lib.addIncludePath(upstream.path(""));
lib.addIncludePath(.{ .path = "" });
lib.addIncludePath(b.path(""));
module.addIncludePath(upstream.path("pixman"));
module.addIncludePath(.{ .path = "" });
module.addIncludePath(b.path(""));
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -62,7 +62,7 @@ pub fn build(b: *std.Build) !void {
.flags = flags.items,
});
lib.installHeader(.{ .path = "pixman-version.h" }, "pixman-version.h");
lib.installHeader(b.path("pixman-version.h"), "pixman-version.h");
lib.installHeadersDirectory(
upstream.path("pixman"),
"",
@ -74,7 +74,7 @@ pub fn build(b: *std.Build) !void {
if (target.query.isNative()) {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -10,7 +10,7 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
});
lib.linkLibCpp();
lib.addIncludePath(.{ .path = "vendor" });
lib.addIncludePath(b.path("vendor"));
if (target.result.isDarwin()) {
const apple_sdk = @import("apple_sdk");
@ -19,7 +19,9 @@ pub fn build(b: *std.Build) !void {
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
try flags.appendSlice(&.{});
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// (See root Ghostty build.zig on why we do this)
try flags.appendSlice(&.{"-DSIMDUTF_IMPLEMENTATION_ICELAKE=0"});
lib.addCSourceFiles(.{
.flags = flags.items,
@ -28,7 +30,7 @@ pub fn build(b: *std.Build) !void {
},
});
lib.installHeadersDirectory(
.{ .path = "vendor" },
b.path("vendor"),
"",
.{ .include_extensions = &.{".h"} },
);

View File

@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("spirv_cross", .{});
const module = b.addModule("spirv_cross", .{ .root_source_file = .{ .path = "main.zig" } });
const module = b.addModule("spirv_cross", .{ .root_source_file = b.path("main.zig") });
module.addIncludePath(upstream.path(""));
const lib = try buildSpirvCross(b, upstream, target, optimize);
@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void {
if (target.query.isNative()) {
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -72,7 +72,7 @@ test "accelFromTrigger" {
try testing.expectEqualStrings("<Super>q", (try accelFromTrigger(&buf, .{
.mods = .{ .super = true },
.key = .q,
.key = .{ .translated = .q },
})).?);
}

View File

@ -31,7 +31,7 @@ pub fn run(alloc: std.mem.Allocator) !u8 {
var keys = std.ArrayList([]const u8).init(alloc);
defer keys.deinit();
for (x11_color.map.kvs) |kv| try keys.append(kv.key);
for (x11_color.map.keys()) |key| try keys.append(key);
std.mem.sortUnstable([]const u8, keys.items, {}, struct {
fn lessThan(_: void, lhs: []const u8, rhs: []const u8) bool {

View File

@ -44,7 +44,7 @@ pub const Entry = struct {
/// key value for Entry.
const code_to_key = code_to_key: {
@setEvalBranchQuota(5000);
break :code_to_key std.ComptimeStringMap(Key, .{
break :code_to_key std.StaticStringMap(Key).initComptime(.{
.{ "KeyA", .a },
.{ "KeyB", .b },
.{ "KeyC", .c },

View File

@ -123,8 +123,8 @@ fn logFn(
const prefix = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
// Lock so we are thread-safe
std.debug.getStderrMutex().lock();
defer std.debug.getStderrMutex().unlock();
std.debug.lockStdErr();
defer std.debug.unlockStdErr();
// On Mac, we use unified logging. To view this:
//

View File

@ -622,7 +622,10 @@ test "image load: rgb, not compressed, temporary file" {
var tmp_dir = try internal_os.TempDir.init();
defer tmp_dir.deinit();
const data = @embedFile("testdata/image-rgb-none-20x15-2147483647-raw.data");
try tmp_dir.dir.writeFile("image.data", data);
try tmp_dir.dir.writeFile(.{
.sub_path = "image.data",
.data = data,
});
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = try tmp_dir.dir.realpath("image.data", &buf);
@ -656,7 +659,10 @@ test "image load: rgb, not compressed, regular file" {
var tmp_dir = try internal_os.TempDir.init();
defer tmp_dir.deinit();
const data = @embedFile("testdata/image-rgb-none-20x15-2147483647-raw.data");
try tmp_dir.dir.writeFile("image.data", data);
try tmp_dir.dir.writeFile(.{
.sub_path = "image.data",
.data = data,
});
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = try tmp_dir.dir.realpath("image.data", &buf);
@ -688,7 +694,10 @@ test "image load: png, not compressed, regular file" {
var tmp_dir = try internal_os.TempDir.init();
defer tmp_dir.deinit();
const data = @embedFile("testdata/image-png-none-50x76-2147483647-raw.data");
try tmp_dir.dir.writeFile("image.data", data);
try tmp_dir.dir.writeFile(.{
.sub_path = "image.data",
.data = data,
});
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const path = try tmp_dir.dir.realpath("image.data", &buf);

View File

@ -47,7 +47,7 @@ pub const MouseShape = enum(c_int) {
}
};
const string_map = std.ComptimeStringMap(MouseShape, .{
const string_map = std.StaticStringMap(MouseShape).initComptime(.{
// W3C
.{ "default", .default },
.{ "context-menu", .context_menu },

View File

@ -5,7 +5,9 @@ const RGB = @import("color.zig").RGB;
/// The map of all available X11 colors.
pub const map = colorMap() catch @compileError("failed to parse rgb.txt");
fn colorMap() !type {
pub const ColorMap = std.StaticStringMapWithEql(RGB, std.static_string_map.eqlAsciiIgnoreCase);
fn colorMap() !ColorMap {
@setEvalBranchQuota(100_000);
const KV = struct { []const u8, RGB };
@ -31,11 +33,7 @@ fn colorMap() !type {
}
assert(i == len);
return std.ComptimeStringMapWithEql(
RGB,
kvs,
std.comptime_string_map.eqlAsciiIgnoreCase,
);
return ColorMap.initComptime(kvs);
}
/// This is the rgb.txt file from the X11 project. This was last sourced

View File

@ -65,10 +65,10 @@ pub fn encode(self: Source, writer: anytype) !void {
}
}
/// Returns a ComptimeStringMap for all of the capabilities in this terminfo.
/// Returns a StaticStringMap for all of the capabilities in this terminfo.
/// The value is the value that should be sent as a response to XTGETTCAP.
/// Important: the value is the FULL response included the escape sequences.
pub fn xtgettcapMap(comptime self: Source) type {
pub fn xtgettcapMap(comptime self: Source) std.StaticStringMap([]const u8) {
const KV = struct { []const u8, []const u8 };
// We have all of our capabilities plus To, TN, and RGB which aren't
@ -145,7 +145,7 @@ pub fn xtgettcapMap(comptime self: Source) type {
}
const kvs_final = kvs;
return std.ComptimeStringMap([]const u8, &kvs_final);
return std.StaticStringMap([]const u8).initComptime(&kvs_final);
}
fn hexencode(comptime input: []const u8) []const u8 {