Replaces #8372 

Before merge I'm going to squash this and give @pluiedev coauthor, since
I took a lot of her work. I just have to go through this myself to make
sure I learn all the changes in Zig 0.15, but as I got things, I copy
and pasted her work in. My work is probably less thorough and there are
places we can convert deprecated things, probably, but this results in
green CI.

## Benchmarks

It looks like there are some speed regressions in isolated places. I'm
not sure if this is noise or not, I'm going to keep running some tests.
If someone can check macOS that'd be helpful (my vtebench is down on
macOS atm), cc @qwerasd205 if interested.

On an x86_64 system:


![output](https://github.com/user-attachments/assets/25395c18-2560-45c8-9fd3-d524bc5cbfb8)
This commit is contained in:
Mitchell Hashimoto
2025-10-03 07:12:12 -07:00
committed by GitHub
183 changed files with 2574 additions and 2217 deletions

View File

@@ -14,7 +14,6 @@ jobs:
- build-dist - build-dist
- build-examples - build-examples
- build-flatpak - build-flatpak
- build-freebsd
- build-libghostty-vt - build-libghostty-vt
- build-linux - build-linux
- build-linux-libghostty - build-linux-libghostty
@@ -333,7 +332,7 @@ jobs:
run: nix build .#ghostty-releasefast run: nix build .#ghostty-releasefast
- name: Check version - name: Check version
run: result/bin/ghostty +version | grep -q 'builtin.OptimizeMode.ReleaseFast' run: result/bin/ghostty +version | grep -q '.ReleaseFast'
- name: Check to see if the binary has been stripped - name: Check to see if the binary has been stripped
run: nm result/bin/.ghostty-wrapped 2>&1 | grep -q 'no symbols' run: nm result/bin/.ghostty-wrapped 2>&1 | grep -q 'no symbols'
@@ -342,7 +341,7 @@ jobs:
run: nix build .#ghostty-debug run: nix build .#ghostty-debug
- name: Check version - name: Check version
run: result/bin/ghostty +version | grep -q 'builtin.OptimizeMode.Debug' run: result/bin/ghostty +version | grep -q '.Debug'
- name: Check to see if the binary has not been stripped - name: Check to see if the binary has not been stripped
run: nm result/bin/.ghostty-wrapped 2>&1 | grep -q 'main_ghostty.main' run: nm result/bin/.ghostty-wrapped 2>&1 | grep -q 'main_ghostty.main'
@@ -513,7 +512,7 @@ jobs:
$fileContent = Get-Content -Path "build.zig" -Raw $fileContent = Get-Content -Path "build.zig" -Raw
$pattern = 'buildpkg\.requireZig\("(.*?)"\);' $pattern = 'buildpkg\.requireZig\("(.*?)"\);'
$zigVersion = [regex]::Match($fileContent, $pattern).Groups[1].Value $zigVersion = [regex]::Match($fileContent, $pattern).Groups[1].Value
$version = "zig-windows-x86_64-$zigVersion" $version = "zig-x86_64-windows-$zigVersion"
Write-Output $version Write-Output $version
$uri = "https://ziglang.org/download/$zigVersion/$version.zip" $uri = "https://ziglang.org/download/$zigVersion/$version.zip"
Invoke-WebRequest -Uri "$uri" -OutFile ".\zig-windows.zip" Invoke-WebRequest -Uri "$uri" -OutFile ".\zig-windows.zip"
@@ -1138,6 +1137,7 @@ jobs:
name: Build on FreeBSD name: Build on FreeBSD
needs: test needs: test
runs-on: namespace-profile-mitchellh-sm-systemd runs-on: namespace-profile-mitchellh-sm-systemd
if: false # FIXME: FreeBSD does not yet ship with Zig 0.15
strategy: strategy:
matrix: matrix:
release: release:

View File

@@ -4,7 +4,7 @@ const builtin = @import("builtin");
const buildpkg = @import("src/build/main.zig"); const buildpkg = @import("src/build/main.zig");
comptime { comptime {
buildpkg.requireZig("0.14.0"); buildpkg.requireZig("0.15.1");
} }
pub fn build(b: *std.Build) !void { pub fn build(b: *std.Build) !void {
@@ -249,8 +249,6 @@ pub fn build(b: *std.Build) !void {
{ {
const mod_vt_test = b.addTest(.{ const mod_vt_test = b.addTest(.{
.root_module = mod.vt, .root_module = mod.vt,
.target = config.target,
.optimize = config.optimize,
.filters = test_filters, .filters = test_filters,
}); });
const mod_vt_test_run = b.addRunArtifact(mod_vt_test); const mod_vt_test_run = b.addRunArtifact(mod_vt_test);
@@ -258,8 +256,6 @@ pub fn build(b: *std.Build) !void {
const mod_vt_c_test = b.addTest(.{ const mod_vt_c_test = b.addTest(.{
.root_module = mod.vt_c, .root_module = mod.vt_c,
.target = config.target,
.optimize = config.optimize,
.filters = test_filters, .filters = test_filters,
}); });
const mod_vt_c_test_run = b.addRunArtifact(mod_vt_c_test); const mod_vt_c_test_run = b.addRunArtifact(mod_vt_c_test);
@@ -280,6 +276,8 @@ pub fn build(b: *std.Build) !void {
.omit_frame_pointer = false, .omit_frame_pointer = false,
.unwind_tables = .sync, .unwind_tables = .sync,
}), }),
// Crash on x86_64 without this
.use_llvm = true,
}); });
if (config.emit_test_exe) b.installArtifact(test_exe); if (config.emit_test_exe) b.installArtifact(test_exe);
_ = try deps.add(test_exe); _ = try deps.add(test_exe);
@@ -289,7 +287,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(&test_run.step); test_step.dependOn(&test_run.step);
// Normal tests always test our libghostty modules // Normal tests always test our libghostty modules
test_step.dependOn(test_lib_vt_step); //test_step.dependOn(test_lib_vt_step);
// Valgrind test running // Valgrind test running
const valgrind_run = b.addSystemCommand(&.{ const valgrind_run = b.addSystemCommand(&.{

View File

@@ -3,54 +3,55 @@
.version = "1.2.1", .version = "1.2.1",
.paths = .{""}, .paths = .{""},
.fingerprint = 0x64407a2a0b4147e5, .fingerprint = 0x64407a2a0b4147e5,
.minimum_zig_version = "0.14.1", .minimum_zig_version = "0.15.1",
.dependencies = .{ .dependencies = .{
// Zig libs // Zig libs
.libxev = .{ .libxev = .{
// mitchellh/libxev // mitchellh/libxev
.url = "https://github.com/mitchellh/libxev/archive/7f803181b158a10fec8619f793e3b4df515566cb.tar.gz", .url = "https://github.com/mitchellh/libxev/archive/34fa50878aec6e5fa8f532867001ab3c36fae23e.tar.gz",
.hash = "libxev-0.0.0-86vtc2UaEwDfiTKX3iBI-s_hdzfzWQUarT3MUrmUQl-Q", .hash = "libxev-0.0.0-86vtc4IcEwCqEYxEYoN_3KXmc6A9VLcm22aVImfvecYs",
.lazy = true, .lazy = true,
}, },
.vaxis = .{ .vaxis = .{
// rockorager/libvaxis // rockorager/libvaxis
.url = "git+https://github.com/rockorager/libvaxis#1f41c121e8fc153d9ce8c6eb64b2bbab68ad7d23", .url = "https://github.com/rockorager/libvaxis/archive/9fc9015d5f147568e18c5e7ca28f15bf8b293760.tar.gz",
.hash = "vaxis-0.1.0-BWNV_FUICQAFZnTCL11TUvnUr1Y0_ZdqtXHhd51d76Rn", .hash = "vaxis-0.5.1-BWNV_O8fCQAeUeVrESVc-2BdXloEXkFqReDJL7Q6XTSZ",
.lazy = true, .lazy = true,
}, },
.z2d = .{ .z2d = .{
// vancluever/z2d // vancluever/z2d
.url = "https://github.com/vancluever/z2d/archive/refs/tags/v0.8.1.tar.gz", .url = "https://github.com/vancluever/z2d/archive/a1237f6881d99b75abd8a20a934e62e34b44a005.tar.gz",
.hash = "z2d-0.8.1-j5P_Hq8vDwB8ZaDA54-SzESDLF2zznG_zvTHiQNJImZP", .hash = "z2d-0.8.2-pre-j5P_HlVRFgCsBTQ3EgUoKbYHx5JMnyH1mHsOSPiafnef",
.lazy = true, .lazy = true,
}, },
.zig_objc = .{ .zig_objc = .{
// mitchellh/zig-objc // mitchellh/zig-objc
.url = "https://github.com/mitchellh/zig-objc/archive/c9e917a4e15a983b672ca779c7985d738a2d517c.tar.gz", .url = "https://github.com/mitchellh/zig-objc/archive/f356ed02833f0f1b8e84d50bed9e807bf7cdc0ae.tar.gz",
.hash = "zig_objc-0.0.0-Ir_SpwsPAQBJgi9YRm2ubJMfdoysSq5gKpsIj3izQ8Zk", .hash = "zig_objc-0.0.0-Ir_Sp5gTAQCvxxR7oVIrPXxXwsfKgVP7_wqoOQrZjFeK",
.lazy = true, .lazy = true,
}, },
.zig_js = .{ .zig_js = .{
// mitchellh/zig-js // mitchellh/zig-js
.url = "https://deps.files.ghostty.org/zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.tar.gz", .url = "https://github.com/mitchellh/zig-js/archive/04db83c617da1956ac5adc1cb9ba1e434c1cb6fd.tar.gz",
.hash = "N-V-__8AAB9YCQBaZtQjJZVndk-g_GDIK-NTZcIa63bFp9yZ", .hash = "zig_js-0.0.0-rjCAV-6GAADxFug7rDmPH-uM_XcnJ5NmuAMJCAscMjhi",
.lazy = true, .lazy = true,
}, },
.uucode = .{ .uucode = .{
.url = "https://github.com/jacobsandlund/uucode/archive/190706c6b56f0842d29778007f74f7d3d1335fc5.tar.gz", // TODO: currently the use-llvm branch because its broken on self-hosted
.hash = "uucode-0.1.0-ZZjBPpAFQABNCvd9cVPBg4I7233Ays-NWfWphPNqGbyE", .url = "https://github.com/jacobsandlund/uucode/archive/f81f8ef8518b8ec5a7fca30ec5fdbc76cc6197df.tar.gz",
.hash = "uucode-0.1.0-ZZjBPjQHQADuCy1VMWftjrMl3iWqgMpUugWVQJG6_7xT",
}, },
.zig_wayland = .{ .zig_wayland = .{
// codeberg ifreund/zig-wayland // codeberg ifreund/zig-wayland
.url = "https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz", .url = "https://codeberg.org/ifreund/zig-wayland/archive/1b5c038ec10da20ed3a15b0b2a6db1c21383e8ea.tar.gz",
.hash = "wayland-0.4.0-dev-lQa1kjfIAQCmhhQu3xF0KH-94-TzeMXOqfnP0-Dg6Wyy", .hash = "wayland-0.5.0-dev-lQa1khrMAQDJDwYFKpdH3HizherB7sHo5dKMECfvxQHe",
.lazy = true, .lazy = true,
}, },
.zf = .{ .zf = .{
// natecraddock/zf // natecraddock/zf
.url = "https://github.com/natecraddock/zf/archive/7aacbe6d155d64d15937ca95ca6c014905eb531f.tar.gz", .url = "https://github.com/jcollie/zf/archive/52ad2e5528ab754f77437edf08a07b5ec843661c.tar.gz",
.hash = "zf-0.10.3-OIRy8aiIAACLrBllz0zjxaH0aOe5oNm3KtEMyCntST-9", .hash = "zf-0.10.3-OIRy8QGJAACJcu3tCGtfbJnnd3Y4QL7OW_X8PJ8u_ASR",
.lazy = true, .lazy = true,
}, },
.gobject = .{ .gobject = .{

75
build.zig.zon.json generated
View File

@@ -64,10 +64,10 @@
"url": "https://deps.files.ghostty.org/libpng-1220aa013f0c83da3fb64ea6d327f9173fa008d10e28bc9349eac3463457723b1c66.tar.gz", "url": "https://deps.files.ghostty.org/libpng-1220aa013f0c83da3fb64ea6d327f9173fa008d10e28bc9349eac3463457723b1c66.tar.gz",
"hash": "sha256-/syVtGzwXo4/yKQUdQ4LparQDYnp/fF16U/wQcrxoDo=" "hash": "sha256-/syVtGzwXo4/yKQUdQ4LparQDYnp/fF16U/wQcrxoDo="
}, },
"libxev-0.0.0-86vtc2UaEwDfiTKX3iBI-s_hdzfzWQUarT3MUrmUQl-Q": { "libxev-0.0.0-86vtc4IcEwCqEYxEYoN_3KXmc6A9VLcm22aVImfvecYs": {
"name": "libxev", "name": "libxev",
"url": "https://github.com/mitchellh/libxev/archive/7f803181b158a10fec8619f793e3b4df515566cb.tar.gz", "url": "https://github.com/mitchellh/libxev/archive/34fa50878aec6e5fa8f532867001ab3c36fae23e.tar.gz",
"hash": "sha256-KaozYKEhhT/6sInef7/8O/60LDBJN+8QmdLuNY1Gkmc=" "hash": "sha256-YAPqa5bkpRihKPkyMn15oRvTCZaxO3O66ymRY3lIfdc="
}, },
"N-V-__8AAG3RoQEyRC2Vw7Qoro5SYBf62IHn3HjqtNVY6aWK": { "N-V-__8AAG3RoQEyRC2Vw7Qoro5SYBf62IHn3HjqtNVY6aWK": {
"name": "libxml2", "name": "libxml2",
@@ -109,15 +109,20 @@
"url": "https://deps.files.ghostty.org/utfcpp-1220d4d18426ca72fc2b7e56ce47273149815501d0d2395c2a98c726b31ba931e641.tar.gz", "url": "https://deps.files.ghostty.org/utfcpp-1220d4d18426ca72fc2b7e56ce47273149815501d0d2395c2a98c726b31ba931e641.tar.gz",
"hash": "sha256-/8ZooxDndgfTk/PBizJxXyI9oerExNbgV5oR345rWc8=" "hash": "sha256-/8ZooxDndgfTk/PBizJxXyI9oerExNbgV5oR345rWc8="
}, },
"uucode-0.1.0-ZZjBPpAFQABNCvd9cVPBg4I7233Ays-NWfWphPNqGbyE": { "uucode-0.1.0-ZZjBPjQHQADuCy1VMWftjrMl3iWqgMpUugWVQJG6_7xT": {
"name": "uucode", "name": "uucode",
"url": "https://github.com/jacobsandlund/uucode/archive/190706c6b56f0842d29778007f74f7d3d1335fc5.tar.gz", "url": "https://github.com/jacobsandlund/uucode/archive/f81f8ef8518b8ec5a7fca30ec5fdbc76cc6197df.tar.gz",
"hash": "sha256-iq9Oyns5e5Tnz2BKPPPTuyJ03BN4bK0dsmSPE1s0wig=" "hash": "sha256-VomSYOF8fRJwb/8GtVG/QqR6c95zSkQt4649C/4KXAc="
}, },
"vaxis-0.1.0-BWNV_FUICQAFZnTCL11TUvnUr1Y0_ZdqtXHhd51d76Rn": { "vaxis-0.5.1-BWNV_H0PCQAeMusmtLzh9P9xO2IW242GZ2IRe9iKYhcA": {
"name": "vaxis", "name": "vaxis",
"url": "git+https://github.com/rockorager/libvaxis#1f41c121e8fc153d9ce8c6eb64b2bbab68ad7d23", "url": "https://github.com/rockorager/libvaxis/archive/1bf887aa7e3736bad69fd4e277a378946edb0f2a.tar.gz",
"hash": "sha256-bNZ3oveT6vPChjimPJ/GGfcdivlAeJdl/xfWM+S/MHY=" "hash": "sha256-eq5YC26OY0i2cdQJ0ZXMZ+o2vHQLEFNNGzQt5Zuz4BM="
},
"vaxis-0.5.1-BWNV_O8fCQAeUeVrESVc-2BdXloEXkFqReDJL7Q6XTSZ": {
"name": "vaxis",
"url": "https://github.com/rockorager/libvaxis/archive/9fc9015d5f147568e18c5e7ca28f15bf8b293760.tar.gz",
"hash": "sha256-7H5a0J7uUsrzlO7JNAf/Ussi9WxvmsbyJSmhqvl+rqI="
}, },
"N-V-__8AAKrHGAAs2shYq8UkE6bGcR1QJtLTyOE_lcosMn6t": { "N-V-__8AAKrHGAAs2shYq8UkE6bGcR1QJtLTyOE_lcosMn6t": {
"name": "wayland", "name": "wayland",
@@ -134,40 +139,50 @@
"url": "https://deps.files.ghostty.org/wuffs-122037b39d577ec2db3fd7b2130e7b69ef6cc1807d68607a7c232c958315d381b5cd.tar.gz", "url": "https://deps.files.ghostty.org/wuffs-122037b39d577ec2db3fd7b2130e7b69ef6cc1807d68607a7c232c958315d381b5cd.tar.gz",
"hash": "sha256-nkzSCr6W5sTG7enDBXEIhgEm574uLD41UVR2wlC+HBM=" "hash": "sha256-nkzSCr6W5sTG7enDBXEIhgEm574uLD41UVR2wlC+HBM="
}, },
"z2d-0.8.1-j5P_Hq8vDwB8ZaDA54-SzESDLF2zznG_zvTHiQNJImZP": { "z2d-0.8.2-pre-j5P_HlVRFgCsBTQ3EgUoKbYHx5JMnyH1mHsOSPiafnef": {
"name": "z2d", "name": "z2d",
"url": "https://github.com/vancluever/z2d/archive/refs/tags/v0.8.1.tar.gz", "url": "https://github.com/vancluever/z2d/archive/a1237f6881d99b75abd8a20a934e62e34b44a005.tar.gz",
"hash": "sha256-0DbDKSYA1ejhVx/WbOkwTgD57PNRFcnRviqBh8xpPZ0=" "hash": "sha256-5/qRZAIh1U42v7jql9W0jr2zzQZtu39DxJPLVrSybJg="
}, },
"zf-0.10.3-OIRy8aiIAACLrBllz0zjxaH0aOe5oNm3KtEMyCntST-9": { "zf-0.10.3-OIRy8QGJAACJcu3tCGtfbJnnd3Y4QL7OW_X8PJ8u_ASR": {
"name": "zf", "name": "zf",
"url": "https://github.com/natecraddock/zf/archive/7aacbe6d155d64d15937ca95ca6c014905eb531f.tar.gz", "url": "https://github.com/jcollie/zf/archive/52ad2e5528ab754f77437edf08a07b5ec843661c.tar.gz",
"hash": "sha256-3nulNQd/4rZ4paeXJYXwAliNNyRNsIOX/q3z1JB8C7I=" "hash": "sha256-8BinbanSfZeBA8SBAopVxwJObN36/BTpxVHABKicsMQ="
}, },
"zg-0.13.4-AAAAAGiZ7QLz4pvECFa_wG4O4TP4FLABHHbemH2KakWM": { "zg-0.14.1-oGqU3J4_tAKBfyes3AWleKDjo-IcYvnEwaB8qxOqFMwM": {
"name": "zg", "name": "zg",
"url": "git+https://codeberg.org/atman/zg#4a002763419a34d61dcbb1f415821b83b9bf8ddc", "url": "git+https://codeberg.org/ivanstepanovftw/zg#4fe689e56ce2ed5a8f59308b471bccd7da89fac9",
"hash": "sha256-fo3l6cjkrr/godElTGnQzalBsasN7J73IDIRmw7v1gA=" "hash": "sha256-P0ieLuOQ05wKVaMmeNKJIxCWMIdyeKkmhsj8Ps80BGU="
}, },
"N-V-__8AAB9YCQBaZtQjJZVndk-g_GDIK-NTZcIa63bFp9yZ": { "zg-0.15.1-oGqU3M0-tALZCy7boQS86znlBloyKx6--JriGlY0Paa9": {
"name": "zg",
"url": "https://codeberg.org/chaten/zg/archive/749197a3f9d25e211615960c02380a3d659b20f9.tar.gz",
"hash": "sha256-BZhz1nPqxK6hdsJQ66n7Jk4zMgFSGLXm8eU0CX/7mDI="
},
"zig_js-0.0.0-rjCAV-6GAADxFug7rDmPH-uM_XcnJ5NmuAMJCAscMjhi": {
"name": "zig_js", "name": "zig_js",
"url": "https://deps.files.ghostty.org/zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.tar.gz", "url": "https://github.com/mitchellh/zig-js/archive/04db83c617da1956ac5adc1cb9ba1e434c1cb6fd.tar.gz",
"hash": "sha256-fyNeCVbC9UAaKJY6JhAZlT0A479M/AKYMPIWEZbDWD0=" "hash": "sha256-TCAY5WAV05UEuAkDhq2c6Tk/ODgAhdnDI3O/flb8c6M="
}, },
"zig_objc-0.0.0-Ir_SpwsPAQBJgi9YRm2ubJMfdoysSq5gKpsIj3izQ8Zk": { "zig_objc-0.0.0-Ir_Sp5gTAQCvxxR7oVIrPXxXwsfKgVP7_wqoOQrZjFeK": {
"name": "zig_objc", "name": "zig_objc",
"url": "https://github.com/mitchellh/zig-objc/archive/c9e917a4e15a983b672ca779c7985d738a2d517c.tar.gz", "url": "https://github.com/mitchellh/zig-objc/archive/f356ed02833f0f1b8e84d50bed9e807bf7cdc0ae.tar.gz",
"hash": "sha256-o3vl7qfkSi0bKXa6JWuF92qMEGP8Af/shcip5nRo5Nw=" "hash": "sha256-3YSvc3YlNW/NciyzCQnzsujXAmZ89XlxSqfqvArAjsw="
}, },
"wayland-0.4.0-dev-lQa1kjfIAQCmhhQu3xF0KH-94-TzeMXOqfnP0-Dg6Wyy": { "wayland-0.5.0-dev-lQa1khrMAQDJDwYFKpdH3HizherB7sHo5dKMECfvxQHe": {
"name": "zig_wayland", "name": "zig_wayland",
"url": "https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz", "url": "https://codeberg.org/ifreund/zig-wayland/archive/1b5c038ec10da20ed3a15b0b2a6db1c21383e8ea.tar.gz",
"hash": "sha256-E77GZ15APYbbO1WzmuJi8eG9/iQFbc2CgkNBxjCLUhk=" "hash": "sha256-TxRrc17Q1Sf1IOO/cdPpP3LD0PpYOujt06SFH3B5Ek4="
}, },
"zigimg-0.1.0-lly-O6N2EABOxke8dqyzCwhtUCAafqP35zC7wsZ4Ddxj": { "zigimg-0.1.0-8_eo2mWmEgBoqdr0sH9O5GTqDHthkoEPM5_tipcBRreL": {
"name": "zigimg", "name": "zigimg",
"url": "git+https://github.com/TUSF/zigimg#31268548fe3276c0e95f318a6c0d2ab10565b58d", "url": "git+https://github.com/ivanstepanovftw/zigimg#aa4c31db872612c39edbb79f753b3cd9a79fe726",
"hash": "sha256-oblfr2FIzuqq0FLo/RrzCwUX1NJJuT53EwD3nP3KwN0=" "hash": "sha256-Ko5RuxxTAvpUHCnWEdHqNl7b+PVUAxg1/OPmzGGjdt0="
},
"zigimg-0.1.0-8_eo2vHnEwCIVW34Q14Ec-xUlzIoVg86-7FU2ypPtxms": {
"name": "zigimg",
"url": "https://github.com/ivanstepanovftw/zigimg/archive/d7b7ab0ba0899643831ef042bd73289510b39906.tar.gz",
"hash": "sha256-LB7Xa6KzVRRUSwwnyWM+y6fDG+kIDjfnoBDJO1obxVM="
}, },
"N-V-__8AAB0eQwD-0MdOEBmz7intriBReIsIDNlukNVoNu6o": { "N-V-__8AAB0eQwD-0MdOEBmz7intriBReIsIDNlukNVoNu6o": {
"name": "zlib", "name": "zlib",

84
build.zig.zon.nix generated
View File

@@ -187,11 +187,11 @@ in
}; };
} }
{ {
name = "libxev-0.0.0-86vtc2UaEwDfiTKX3iBI-s_hdzfzWQUarT3MUrmUQl-Q"; name = "libxev-0.0.0-86vtc4IcEwCqEYxEYoN_3KXmc6A9VLcm22aVImfvecYs";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "libxev"; name = "libxev";
url = "https://github.com/mitchellh/libxev/archive/7f803181b158a10fec8619f793e3b4df515566cb.tar.gz"; url = "https://github.com/mitchellh/libxev/archive/34fa50878aec6e5fa8f532867001ab3c36fae23e.tar.gz";
hash = "sha256-KaozYKEhhT/6sInef7/8O/60LDBJN+8QmdLuNY1Gkmc="; hash = "sha256-YAPqa5bkpRihKPkyMn15oRvTCZaxO3O66ymRY3lIfdc=";
}; };
} }
{ {
@@ -259,19 +259,27 @@ in
}; };
} }
{ {
name = "uucode-0.1.0-ZZjBPpAFQABNCvd9cVPBg4I7233Ays-NWfWphPNqGbyE"; name = "uucode-0.1.0-ZZjBPjQHQADuCy1VMWftjrMl3iWqgMpUugWVQJG6_7xT";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "uucode"; name = "uucode";
url = "https://github.com/jacobsandlund/uucode/archive/190706c6b56f0842d29778007f74f7d3d1335fc5.tar.gz"; url = "https://github.com/jacobsandlund/uucode/archive/f81f8ef8518b8ec5a7fca30ec5fdbc76cc6197df.tar.gz";
hash = "sha256-iq9Oyns5e5Tnz2BKPPPTuyJ03BN4bK0dsmSPE1s0wig="; hash = "sha256-VomSYOF8fRJwb/8GtVG/QqR6c95zSkQt4649C/4KXAc=";
}; };
} }
{ {
name = "vaxis-0.1.0-BWNV_FUICQAFZnTCL11TUvnUr1Y0_ZdqtXHhd51d76Rn"; name = "vaxis-0.5.1-BWNV_H0PCQAeMusmtLzh9P9xO2IW242GZ2IRe9iKYhcA";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "vaxis"; name = "vaxis";
url = "git+https://github.com/rockorager/libvaxis#1f41c121e8fc153d9ce8c6eb64b2bbab68ad7d23"; url = "https://github.com/rockorager/libvaxis/archive/1bf887aa7e3736bad69fd4e277a378946edb0f2a.tar.gz";
hash = "sha256-bNZ3oveT6vPChjimPJ/GGfcdivlAeJdl/xfWM+S/MHY="; hash = "sha256-eq5YC26OY0i2cdQJ0ZXMZ+o2vHQLEFNNGzQt5Zuz4BM=";
};
}
{
name = "vaxis-0.5.1-BWNV_O8fCQAeUeVrESVc-2BdXloEXkFqReDJL7Q6XTSZ";
path = fetchZigArtifact {
name = "vaxis";
url = "https://github.com/rockorager/libvaxis/archive/9fc9015d5f147568e18c5e7ca28f15bf8b293760.tar.gz";
hash = "sha256-7H5a0J7uUsrzlO7JNAf/Ussi9WxvmsbyJSmhqvl+rqI=";
}; };
} }
{ {
@@ -299,59 +307,75 @@ in
}; };
} }
{ {
name = "z2d-0.8.1-j5P_Hq8vDwB8ZaDA54-SzESDLF2zznG_zvTHiQNJImZP"; name = "z2d-0.8.2-pre-j5P_HlVRFgCsBTQ3EgUoKbYHx5JMnyH1mHsOSPiafnef";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "z2d"; name = "z2d";
url = "https://github.com/vancluever/z2d/archive/refs/tags/v0.8.1.tar.gz"; url = "https://github.com/vancluever/z2d/archive/a1237f6881d99b75abd8a20a934e62e34b44a005.tar.gz";
hash = "sha256-0DbDKSYA1ejhVx/WbOkwTgD57PNRFcnRviqBh8xpPZ0="; hash = "sha256-5/qRZAIh1U42v7jql9W0jr2zzQZtu39DxJPLVrSybJg=";
}; };
} }
{ {
name = "zf-0.10.3-OIRy8aiIAACLrBllz0zjxaH0aOe5oNm3KtEMyCntST-9"; name = "zf-0.10.3-OIRy8QGJAACJcu3tCGtfbJnnd3Y4QL7OW_X8PJ8u_ASR";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "zf"; name = "zf";
url = "https://github.com/natecraddock/zf/archive/7aacbe6d155d64d15937ca95ca6c014905eb531f.tar.gz"; url = "https://github.com/jcollie/zf/archive/52ad2e5528ab754f77437edf08a07b5ec843661c.tar.gz";
hash = "sha256-3nulNQd/4rZ4paeXJYXwAliNNyRNsIOX/q3z1JB8C7I="; hash = "sha256-8BinbanSfZeBA8SBAopVxwJObN36/BTpxVHABKicsMQ=";
}; };
} }
{ {
name = "zg-0.13.4-AAAAAGiZ7QLz4pvECFa_wG4O4TP4FLABHHbemH2KakWM"; name = "zg-0.14.1-oGqU3J4_tAKBfyes3AWleKDjo-IcYvnEwaB8qxOqFMwM";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "zg"; name = "zg";
url = "git+https://codeberg.org/atman/zg#4a002763419a34d61dcbb1f415821b83b9bf8ddc"; url = "git+https://codeberg.org/ivanstepanovftw/zg#4fe689e56ce2ed5a8f59308b471bccd7da89fac9";
hash = "sha256-fo3l6cjkrr/godElTGnQzalBsasN7J73IDIRmw7v1gA="; hash = "sha256-P0ieLuOQ05wKVaMmeNKJIxCWMIdyeKkmhsj8Ps80BGU=";
}; };
} }
{ {
name = "N-V-__8AAB9YCQBaZtQjJZVndk-g_GDIK-NTZcIa63bFp9yZ"; name = "zg-0.15.1-oGqU3M0-tALZCy7boQS86znlBloyKx6--JriGlY0Paa9";
path = fetchZigArtifact {
name = "zg";
url = "https://codeberg.org/chaten/zg/archive/749197a3f9d25e211615960c02380a3d659b20f9.tar.gz";
hash = "sha256-BZhz1nPqxK6hdsJQ66n7Jk4zMgFSGLXm8eU0CX/7mDI=";
};
}
{
name = "zig_js-0.0.0-rjCAV-6GAADxFug7rDmPH-uM_XcnJ5NmuAMJCAscMjhi";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "zig_js"; name = "zig_js";
url = "https://deps.files.ghostty.org/zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.tar.gz"; url = "https://github.com/mitchellh/zig-js/archive/04db83c617da1956ac5adc1cb9ba1e434c1cb6fd.tar.gz";
hash = "sha256-fyNeCVbC9UAaKJY6JhAZlT0A479M/AKYMPIWEZbDWD0="; hash = "sha256-TCAY5WAV05UEuAkDhq2c6Tk/ODgAhdnDI3O/flb8c6M=";
}; };
} }
{ {
name = "zig_objc-0.0.0-Ir_SpwsPAQBJgi9YRm2ubJMfdoysSq5gKpsIj3izQ8Zk"; name = "zig_objc-0.0.0-Ir_Sp5gTAQCvxxR7oVIrPXxXwsfKgVP7_wqoOQrZjFeK";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "zig_objc"; name = "zig_objc";
url = "https://github.com/mitchellh/zig-objc/archive/c9e917a4e15a983b672ca779c7985d738a2d517c.tar.gz"; url = "https://github.com/mitchellh/zig-objc/archive/f356ed02833f0f1b8e84d50bed9e807bf7cdc0ae.tar.gz";
hash = "sha256-o3vl7qfkSi0bKXa6JWuF92qMEGP8Af/shcip5nRo5Nw="; hash = "sha256-3YSvc3YlNW/NciyzCQnzsujXAmZ89XlxSqfqvArAjsw=";
}; };
} }
{ {
name = "wayland-0.4.0-dev-lQa1kjfIAQCmhhQu3xF0KH-94-TzeMXOqfnP0-Dg6Wyy"; name = "wayland-0.5.0-dev-lQa1khrMAQDJDwYFKpdH3HizherB7sHo5dKMECfvxQHe";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "zig_wayland"; name = "zig_wayland";
url = "https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz"; url = "https://codeberg.org/ifreund/zig-wayland/archive/1b5c038ec10da20ed3a15b0b2a6db1c21383e8ea.tar.gz";
hash = "sha256-E77GZ15APYbbO1WzmuJi8eG9/iQFbc2CgkNBxjCLUhk="; hash = "sha256-TxRrc17Q1Sf1IOO/cdPpP3LD0PpYOujt06SFH3B5Ek4=";
}; };
} }
{ {
name = "zigimg-0.1.0-lly-O6N2EABOxke8dqyzCwhtUCAafqP35zC7wsZ4Ddxj"; name = "zigimg-0.1.0-8_eo2mWmEgBoqdr0sH9O5GTqDHthkoEPM5_tipcBRreL";
path = fetchZigArtifact { path = fetchZigArtifact {
name = "zigimg"; name = "zigimg";
url = "git+https://github.com/TUSF/zigimg#31268548fe3276c0e95f318a6c0d2ab10565b58d"; url = "git+https://github.com/ivanstepanovftw/zigimg#aa4c31db872612c39edbb79f753b3cd9a79fe726";
hash = "sha256-oblfr2FIzuqq0FLo/RrzCwUX1NJJuT53EwD3nP3KwN0="; hash = "sha256-Ko5RuxxTAvpUHCnWEdHqNl7b+PVUAxg1/OPmzGGjdt0=";
};
}
{
name = "zigimg-0.1.0-8_eo2vHnEwCIVW34Q14Ec-xUlzIoVg86-7FU2ypPtxms";
path = fetchZigArtifact {
name = "zigimg";
url = "https://github.com/ivanstepanovftw/zigimg/archive/d7b7ab0ba0899643831ef042bd73289510b39906.tar.gz";
hash = "sha256-LB7Xa6KzVRRUSwwnyWM+y6fDG+kIDjfnoBDJO1obxVM=";
}; };
} }
{ {

23
build.zig.zon.txt generated
View File

@@ -1,7 +1,7 @@
git+https://codeberg.org/atman/zg#4a002763419a34d61dcbb1f415821b83b9bf8ddc git+https://codeberg.org/ivanstepanovftw/zg#4fe689e56ce2ed5a8f59308b471bccd7da89fac9
git+https://github.com/TUSF/zigimg#31268548fe3276c0e95f318a6c0d2ab10565b58d git+https://github.com/ivanstepanovftw/zigimg#aa4c31db872612c39edbb79f753b3cd9a79fe726
git+https://github.com/rockorager/libvaxis#1f41c121e8fc153d9ce8c6eb64b2bbab68ad7d23 https://codeberg.org/chaten/zg/archive/749197a3f9d25e211615960c02380a3d659b20f9.tar.gz
https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz https://codeberg.org/ifreund/zig-wayland/archive/1b5c038ec10da20ed3a15b0b2a6db1c21383e8ea.tar.gz
https://deps.files.ghostty.org/JetBrainsMono-2.304.tar.gz https://deps.files.ghostty.org/JetBrainsMono-2.304.tar.gz
https://deps.files.ghostty.org/NerdFontsSymbolsOnly-3.4.0.tar.gz https://deps.files.ghostty.org/NerdFontsSymbolsOnly-3.4.0.tar.gz
https://deps.files.ghostty.org/breakpad-b99f444ba5f6b98cac261cbb391d8766b34a5918.tar.gz https://deps.files.ghostty.org/breakpad-b99f444ba5f6b98cac261cbb391d8766b34a5918.tar.gz
@@ -24,12 +24,15 @@ https://deps.files.ghostty.org/utfcpp-1220d4d18426ca72fc2b7e56ce47273149815501d0
https://deps.files.ghostty.org/wayland-9cb3d7aa9dc995ffafdbdef7ab86a949d0fb0e7d.tar.gz https://deps.files.ghostty.org/wayland-9cb3d7aa9dc995ffafdbdef7ab86a949d0fb0e7d.tar.gz
https://deps.files.ghostty.org/wayland-protocols-258d8f88f2c8c25a830c6316f87d23ce1a0f12d9.tar.gz https://deps.files.ghostty.org/wayland-protocols-258d8f88f2c8c25a830c6316f87d23ce1a0f12d9.tar.gz
https://deps.files.ghostty.org/wuffs-122037b39d577ec2db3fd7b2130e7b69ef6cc1807d68607a7c232c958315d381b5cd.tar.gz https://deps.files.ghostty.org/wuffs-122037b39d577ec2db3fd7b2130e7b69ef6cc1807d68607a7c232c958315d381b5cd.tar.gz
https://deps.files.ghostty.org/zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.tar.gz
https://deps.files.ghostty.org/zlib-1220fed0c74e1019b3ee29edae2051788b080cd96e90d56836eea857b0b966742efb.tar.gz https://deps.files.ghostty.org/zlib-1220fed0c74e1019b3ee29edae2051788b080cd96e90d56836eea857b0b966742efb.tar.gz
https://github.com/ghostty-org/zig-gobject/releases/download/2025-09-20-20-1/ghostty-gobject-2025-09-20-20-1.tar.zst https://github.com/ghostty-org/zig-gobject/releases/download/2025-09-20-20-1/ghostty-gobject-2025-09-20-20-1.tar.zst
https://github.com/jacobsandlund/uucode/archive/190706c6b56f0842d29778007f74f7d3d1335fc5.tar.gz https://github.com/ivanstepanovftw/zigimg/archive/d7b7ab0ba0899643831ef042bd73289510b39906.tar.gz
https://github.com/jacobsandlund/uucode/archive/f81f8ef8518b8ec5a7fca30ec5fdbc76cc6197df.tar.gz
https://github.com/jcollie/zf/archive/52ad2e5528ab754f77437edf08a07b5ec843661c.tar.gz
https://github.com/mbadolato/iTerm2-Color-Schemes/releases/download/release-20250922-150534-d28055b/ghostty-themes.tgz https://github.com/mbadolato/iTerm2-Color-Schemes/releases/download/release-20250922-150534-d28055b/ghostty-themes.tgz
https://github.com/mitchellh/libxev/archive/7f803181b158a10fec8619f793e3b4df515566cb.tar.gz https://github.com/mitchellh/libxev/archive/34fa50878aec6e5fa8f532867001ab3c36fae23e.tar.gz
https://github.com/mitchellh/zig-objc/archive/c9e917a4e15a983b672ca779c7985d738a2d517c.tar.gz https://github.com/mitchellh/zig-js/archive/04db83c617da1956ac5adc1cb9ba1e434c1cb6fd.tar.gz
https://github.com/natecraddock/zf/archive/7aacbe6d155d64d15937ca95ca6c014905eb531f.tar.gz https://github.com/mitchellh/zig-objc/archive/f356ed02833f0f1b8e84d50bed9e807bf7cdc0ae.tar.gz
https://github.com/vancluever/z2d/archive/refs/tags/v0.8.1.tar.gz https://github.com/rockorager/libvaxis/archive/1bf887aa7e3736bad69fd4e277a378946edb0f2a.tar.gz
https://github.com/rockorager/libvaxis/archive/9fc9015d5f147568e18c5e7ca28f15bf8b293760.tar.gz
https://github.com/vancluever/z2d/archive/a1237f6881d99b75abd8a20a934e62e34b44a005.tar.gz

View File

@@ -2,7 +2,7 @@
.name = .c_vt, .name = .c_vt,
.version = "0.0.0", .version = "0.0.0",
.fingerprint = 0x413a8529b1255f9a, .fingerprint = 0x413a8529b1255f9a,
.minimum_zig_version = "0.14.1", .minimum_zig_version = "0.15.1",
.dependencies = .{ .dependencies = .{
// Ghostty dependency. In reality, you'd probably use a URL-based // Ghostty dependency. In reality, you'd probably use a URL-based
// dependency like the one showed (and commented out) below this one. // dependency like the one showed (and commented out) below this one.

View File

@@ -2,7 +2,7 @@
.name = .zig_vt, .name = .zig_vt,
.version = "0.0.0", .version = "0.0.0",
.fingerprint = 0x6045575a7a8387e6, .fingerprint = 0x6045575a7a8387e6,
.minimum_zig_version = "0.14.1", .minimum_zig_version = "0.15.1",
.dependencies = .{ .dependencies = .{
// Ghostty dependency. In reality, you'd probably use a URL-based // Ghostty dependency. In reality, you'd probably use a URL-based
// dependency like the one showed (and commented out) below this one. // dependency like the one showed (and commented out) below this one.

16
flake.lock generated
View File

@@ -36,15 +36,15 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1748189127, "lastModified": 315532800,
"narHash": "sha256-zRDR+EbbeObu4V2X5QCd2Bk5eltfDlCr5yvhBwUT6pY=", "narHash": "sha256-YwoXN6fthkakCFD7nXPcUK+rkNr6ZTNTuF8zdGaxZo0=",
"rev": "7c43f080a7f28b2774f3b3f43234ca11661bf334", "rev": "dc704e6102e76aad573f63b74c742cd96f8f1e6c",
"type": "tarball", "type": "tarball",
"url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.802491.7c43f080a7f2/nixexprs.tar.xz" "url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre870318.dc704e6102e7/nixexprs.tar.xz"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
"url": "https://channels.nixos.org/nixos-25.05/nixexprs.tar.xz" "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
@@ -97,11 +97,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1748261582, "lastModified": 1759192380,
"narHash": "sha256-3i0IL3s18hdDlbsf0/E+5kyPRkZwGPbSFngq5eToiAA=", "narHash": "sha256-0BWJgt4OSzxCESij5oo8WLWrPZ+1qLp8KUQe32QeV4Q=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "aafb1b093fb838f7a02613b719e85ec912914221", "rev": "0bcd1401ed43d10f10cbded49624206553e92f57",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -5,7 +5,9 @@
# We want to stay as up to date as possible but need to be careful that the # We want to stay as up to date as possible but need to be careful that the
# glibc versions used by our dependencies from Nix are compatible with the # glibc versions used by our dependencies from Nix are compatible with the
# system glibc that the user is building for. # system glibc that the user is building for.
nixpkgs.url = "https://channels.nixos.org/nixos-25.05/nixexprs.tar.xz"; #
# We are currently on unstable to get Zig 0.15 for our package.nix
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
# Used for shell.nix # Used for shell.nix
@@ -47,7 +49,7 @@
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in {
devShell.${system} = pkgs.callPackage ./nix/devShell.nix { devShell.${system} = pkgs.callPackage ./nix/devShell.nix {
zig = zig.packages.${system}."0.14.1"; zig = zig.packages.${system}."0.15.1";
wraptest = pkgs.callPackage ./nix/wraptest.nix {}; wraptest = pkgs.callPackage ./nix/wraptest.nix {};
zon2nix = zon2nix; zon2nix = zon2nix;
}; };

View File

@@ -13,12 +13,12 @@ modules:
- chmod a+x /app/zig/zig - chmod a+x /app/zig/zig
sources: sources:
- type: archive - type: archive
sha256: 24aeeec8af16c381934a6cd7d95c807a8cb2cf7df9fa40d359aa884195c4716c sha256: c61c5da6edeea14ca51ecd5e4520c6f4189ef5250383db33d01848293bfafe05
url: https://ziglang.org/download/0.14.1/zig-x86_64-linux-0.14.1.tar.xz url: https://ziglang.org/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz
only-arches: [x86_64] only-arches: [x86_64]
- type: archive - type: archive
sha256: f7a654acc967864f7a050ddacfaa778c7504a0eca8d2b678839c21eea47c992b sha256: bb4a8d2ad735e7fba764c497ddf4243cb129fece4148da3222a7046d3f1f19fe
url: https://ziglang.org/download/0.14.1/zig-aarch64-linux-0.14.1.tar.xz url: https://ziglang.org/download/0.15.1/zig-aarch64-linux-0.15.1.tar.xz
only-arches: [aarch64] only-arches: [aarch64]
- name: bzip2-redirect - name: bzip2-redirect

View File

@@ -79,9 +79,9 @@
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://github.com/mitchellh/libxev/archive/7f803181b158a10fec8619f793e3b4df515566cb.tar.gz", "url": "https://github.com/mitchellh/libxev/archive/34fa50878aec6e5fa8f532867001ab3c36fae23e.tar.gz",
"dest": "vendor/p/libxev-0.0.0-86vtc2UaEwDfiTKX3iBI-s_hdzfzWQUarT3MUrmUQl-Q", "dest": "vendor/p/libxev-0.0.0-86vtc4IcEwCqEYxEYoN_3KXmc6A9VLcm22aVImfvecYs",
"sha256": "29aa3360a121853ffab089de7fbffc3bfeb42c304937ef1099d2ee358d469267" "sha256": "6003ea6b96e4a518a128f932327d79a11bd30996b13b73baeb29916379487dd7"
}, },
{ {
"type": "archive", "type": "archive",
@@ -133,15 +133,21 @@
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://github.com/jacobsandlund/uucode/archive/190706c6b56f0842d29778007f74f7d3d1335fc5.tar.gz", "url": "https://github.com/jacobsandlund/uucode/archive/f81f8ef8518b8ec5a7fca30ec5fdbc76cc6197df.tar.gz",
"dest": "vendor/p/uucode-0.1.0-ZZjBPpAFQABNCvd9cVPBg4I7233Ays-NWfWphPNqGbyE", "dest": "vendor/p/uucode-0.1.0-ZZjBPjQHQADuCy1VMWftjrMl3iWqgMpUugWVQJG6_7xT",
"sha256": "8aaf4eca7b397b94e7cf604a3cf3d3bb2274dc13786cad1db2648f135b34c228" "sha256": "56899260e17c7d12706fff06b551bf42a47a73de734a442de3ae3d0bfe0a5c07"
}, },
{ {
"type": "git", "type": "archive",
"url": "https://github.com/rockorager/libvaxis", "url": "https://github.com/rockorager/libvaxis/archive/1bf887aa7e3736bad69fd4e277a378946edb0f2a.tar.gz",
"commit": "1f41c121e8fc153d9ce8c6eb64b2bbab68ad7d23", "dest": "vendor/p/vaxis-0.5.1-BWNV_H0PCQAeMusmtLzh9P9xO2IW242GZ2IRe9iKYhcA",
"dest": "vendor/p/vaxis-0.1.0-BWNV_FUICQAFZnTCL11TUvnUr1Y0_ZdqtXHhd51d76Rn" "sha256": "7aae580b6e8e6348b671d409d195cc67ea36bc740b10534d1b342de59bb3e013"
},
{
"type": "archive",
"url": "https://github.com/rockorager/libvaxis/archive/9fc9015d5f147568e18c5e7ca28f15bf8b293760.tar.gz",
"dest": "vendor/p/vaxis-0.5.1-BWNV_O8fCQAeUeVrESVc-2BdXloEXkFqReDJL7Q6XTSZ",
"sha256": "ec7e5ad09eee52caf394eec93407ff52cb22f56c6f9ac6f22529a1aaf97eaea2"
}, },
{ {
"type": "archive", "type": "archive",
@@ -163,45 +169,57 @@
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://github.com/vancluever/z2d/archive/refs/tags/v0.8.1.tar.gz", "url": "https://github.com/vancluever/z2d/archive/a1237f6881d99b75abd8a20a934e62e34b44a005.tar.gz",
"dest": "vendor/p/z2d-0.8.1-j5P_Hq8vDwB8ZaDA54-SzESDLF2zznG_zvTHiQNJImZP", "dest": "vendor/p/z2d-0.8.2-pre-j5P_HlVRFgCsBTQ3EgUoKbYHx5JMnyH1mHsOSPiafnef",
"sha256": "d036c3292600d5e8e1571fd66ce9304e00f9ecf35115c9d1be2a8187cc693d9d" "sha256": "e7fa91640221d54e36bfb8ea97d5b48ebdb3cd066dbb7f43c493cb56b4b26c98"
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://github.com/natecraddock/zf/archive/7aacbe6d155d64d15937ca95ca6c014905eb531f.tar.gz", "url": "https://github.com/jcollie/zf/archive/52ad2e5528ab754f77437edf08a07b5ec843661c.tar.gz",
"dest": "vendor/p/zf-0.10.3-OIRy8aiIAACLrBllz0zjxaH0aOe5oNm3KtEMyCntST-9", "dest": "vendor/p/zf-0.10.3-OIRy8QGJAACJcu3tCGtfbJnnd3Y4QL7OW_X8PJ8u_ASR",
"sha256": "de7ba535077fe2b678a5a7972585f002588d37244db08397feadf3d4907c0bb2" "sha256": "f018a76da9d27d978103c481028a55c7024e6cddfafc14e9c551c004a89cb0c4"
}, },
{ {
"type": "git", "type": "git",
"url": "https://codeberg.org/atman/zg", "url": "https://codeberg.org/ivanstepanovftw/zg",
"commit": "4a002763419a34d61dcbb1f415821b83b9bf8ddc", "commit": "4fe689e56ce2ed5a8f59308b471bccd7da89fac9",
"dest": "vendor/p/zg-0.13.4-AAAAAGiZ7QLz4pvECFa_wG4O4TP4FLABHHbemH2KakWM" "dest": "vendor/p/zg-0.14.1-oGqU3J4_tAKBfyes3AWleKDjo-IcYvnEwaB8qxOqFMwM"
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://deps.files.ghostty.org/zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.tar.gz", "url": "https://codeberg.org/chaten/zg/archive/749197a3f9d25e211615960c02380a3d659b20f9.tar.gz",
"dest": "vendor/p/N-V-__8AAB9YCQBaZtQjJZVndk-g_GDIK-NTZcIa63bFp9yZ", "dest": "vendor/p/zg-0.15.1-oGqU3M0-tALZCy7boQS86znlBloyKx6--JriGlY0Paa9",
"sha256": "7f235e0956c2f5401a28963a261019953d00e3bf4cfc029830f2161196c3583d" "sha256": "059873d673eac4aea176c250eba9fb264e3332015218b5e6f1e534097ffb9832"
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://github.com/mitchellh/zig-objc/archive/c9e917a4e15a983b672ca779c7985d738a2d517c.tar.gz", "url": "https://github.com/mitchellh/zig-js/archive/04db83c617da1956ac5adc1cb9ba1e434c1cb6fd.tar.gz",
"dest": "vendor/p/zig_objc-0.0.0-Ir_SpwsPAQBJgi9YRm2ubJMfdoysSq5gKpsIj3izQ8Zk", "dest": "vendor/p/zig_js-0.0.0-rjCAV-6GAADxFug7rDmPH-uM_XcnJ5NmuAMJCAscMjhi",
"sha256": "a37be5eea7e44a2d1b2976ba256b85f76a8c1063fc01ffec85c8a9e67468e4dc" "sha256": "4c2018e56015d39504b8090386ad9ce9393f38380085d9c32373bf7e56fc73a3"
}, },
{ {
"type": "archive", "type": "archive",
"url": "https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz", "url": "https://github.com/mitchellh/zig-objc/archive/f356ed02833f0f1b8e84d50bed9e807bf7cdc0ae.tar.gz",
"dest": "vendor/p/wayland-0.4.0-dev-lQa1kjfIAQCmhhQu3xF0KH-94-TzeMXOqfnP0-Dg6Wyy", "dest": "vendor/p/zig_objc-0.0.0-Ir_Sp5gTAQCvxxR7oVIrPXxXwsfKgVP7_wqoOQrZjFeK",
"sha256": "13bec6675e403d86db3b55b39ae262f1e1bdfe24056dcd82824341c6308b5219" "sha256": "dd84af737625356fcd722cb30909f3b2e8d702667cf579714aa7eabc0ac08ecc"
},
{
"type": "archive",
"url": "https://codeberg.org/ifreund/zig-wayland/archive/1b5c038ec10da20ed3a15b0b2a6db1c21383e8ea.tar.gz",
"dest": "vendor/p/wayland-0.5.0-dev-lQa1khrMAQDJDwYFKpdH3HizherB7sHo5dKMECfvxQHe",
"sha256": "4f146b735ed0d527f520e3bf71d3e93f72c3d0fa583ae8edd3a4851f7079124e"
}, },
{ {
"type": "git", "type": "git",
"url": "https://github.com/TUSF/zigimg", "url": "https://github.com/ivanstepanovftw/zigimg",
"commit": "31268548fe3276c0e95f318a6c0d2ab10565b58d", "commit": "aa4c31db872612c39edbb79f753b3cd9a79fe726",
"dest": "vendor/p/zigimg-0.1.0-lly-O6N2EABOxke8dqyzCwhtUCAafqP35zC7wsZ4Ddxj" "dest": "vendor/p/zigimg-0.1.0-8_eo2mWmEgBoqdr0sH9O5GTqDHthkoEPM5_tipcBRreL"
},
{
"type": "archive",
"url": "https://github.com/ivanstepanovftw/zigimg/archive/d7b7ab0ba0899643831ef042bd73289510b39906.tar.gz",
"dest": "vendor/p/zigimg-0.1.0-8_eo2vHnEwCIVW34Q14Ec-xUlzIoVg86-7FU2ypPtxms",
"sha256": "2c1ed76ba2b35514544b0c27c9633ecba7c31be9080e37e7a010c93b5a1bc553"
}, },
{ {
"type": "archive", "type": "archive",

View File

@@ -10,7 +10,7 @@
git, git,
ncurses, ncurses,
pkg-config, pkg-config,
zig_0_14, zig_0_15,
pandoc, pandoc,
revision ? "dirty", revision ? "dirty",
optimize ? "Debug", optimize ? "Debug",
@@ -27,7 +27,7 @@
# https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653 is # https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653 is
# ultimately acted on and has made its way to a nixpkgs implementation, this # ultimately acted on and has made its way to a nixpkgs implementation, this
# can probably be removed in favor of that. # can probably be removed in favor of that.
zig_hook = zig_0_14.hook.overrideAttrs { zig_hook = zig_0_15.hook.overrideAttrs {
zig_default_flags = "-Dcpu=baseline -Doptimize=${optimize} --color off"; zig_default_flags = "-Dcpu=baseline -Doptimize=${optimize} --color off";
}; };
gi_typelib_path = import ./build-support/gi-typelib-path.nix { gi_typelib_path = import ./build-support/gi-typelib-path.nix {

View File

@@ -46,19 +46,19 @@ pub fn addPaths(
// find the SDK path. // find the SDK path.
const libc = try std.zig.LibCInstallation.findNative(.{ const libc = try std.zig.LibCInstallation.findNative(.{
.allocator = b.allocator, .allocator = b.allocator,
.target = step.rootModuleTarget(), .target = &step.rootModuleTarget(),
.verbose = false, .verbose = false,
}); });
// Render the file compatible with the `--libc` Zig flag. // Render the file compatible with the `--libc` Zig flag.
var list: std.ArrayList(u8) = .init(b.allocator); var stream: std.io.Writer.Allocating = .init(b.allocator);
defer list.deinit(); defer stream.deinit();
try libc.render(list.writer()); try libc.render(&stream.writer);
// Create a temporary file to store the libc path because // Create a temporary file to store the libc path because
// `--libc` expects a file path. // `--libc` expects a file path.
const wf = b.addWriteFiles(); const wf = b.addWriteFiles();
const path = wf.add("libc.txt", list.items); const path = wf.add("libc.txt", stream.written());
// Determine our framework path. Zig has a bug where it doesn't // Determine our framework path. Zig has a bug where it doesn't
// parse this from the libc txt file for `-framework` flags: // parse this from the libc txt file for `-framework` flags:

View File

@@ -19,9 +19,8 @@ pub fn build(b: *std.Build) !void {
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{});
if (b.lazyDependency("breakpad", .{})) |upstream| { if (b.lazyDependency("breakpad", .{})) |upstream| {
lib.addIncludePath(upstream.path("src")); lib.addIncludePath(upstream.path("src"));

View File

@@ -55,19 +55,19 @@ pub fn build(b: *std.Build) !void {
if (imgui_) |imgui| lib.addIncludePath(imgui.path("")); if (imgui_) |imgui| lib.addIncludePath(imgui.path(""));
module.addIncludePath(b.path("vendor")); module.addIncludePath(b.path("vendor"));
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DCIMGUI_FREETYPE=1", "-DCIMGUI_FREETYPE=1",
"-DIMGUI_USE_WCHAR32=1", "-DIMGUI_USE_WCHAR32=1",
"-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1", "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1",
}); });
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)", "-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)",
}); });
} else { } else {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DIMGUI_IMPL_API=extern\t\"C\"", "-DIMGUI_IMPL_API=extern\t\"C\"",
}); });
} }

View File

@@ -82,9 +82,9 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
lib.addIncludePath(b.path("override/include")); lib.addIncludePath(b.path("override/include"));
module.addIncludePath(b.path("override/include")); module.addIncludePath(b.path("override/include"));
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_DIRENT_H", "-DHAVE_DIRENT_H",
"-DHAVE_FCNTL_H", "-DHAVE_FCNTL_H",
"-DHAVE_STDLIB_H", "-DHAVE_STDLIB_H",
@@ -129,12 +129,12 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
}); });
switch (target.result.ptrBitWidth()) { switch (target.result.ptrBitWidth()) {
32 => try flags.appendSlice(&.{ 32 => try flags.appendSlice(b.allocator, &.{
"-DSIZEOF_VOID_P=4", "-DSIZEOF_VOID_P=4",
"-DALIGNOF_VOID_P=4", "-DALIGNOF_VOID_P=4",
}), }),
64 => try flags.appendSlice(&.{ 64 => try flags.appendSlice(b.allocator, &.{
"-DSIZEOF_VOID_P=8", "-DSIZEOF_VOID_P=8",
"-DALIGNOF_VOID_P=8", "-DALIGNOF_VOID_P=8",
}), }),
@@ -142,14 +142,14 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
else => @panic("unsupported arch"), else => @panic("unsupported arch"),
} }
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"", "-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"",
"-DFC_TEMPLATEDIR=\"c:/share/fontconfig/conf.avail\"", "-DFC_TEMPLATEDIR=\"c:/share/fontconfig/conf.avail\"",
"-DCONFIGDIR=\"c:/etc/fonts/conf.d\"", "-DCONFIGDIR=\"c:/etc/fonts/conf.d\"",
"-DFC_DEFAULT_FONTS=\"\\t<dir>WINDOWSFONTDIR</dir>\\n\\t<dir>WINDOWSUSERFONTDIR</dir>\\n\"", "-DFC_DEFAULT_FONTS=\"\\t<dir>WINDOWSFONTDIR</dir>\\n\\t<dir>WINDOWSUSERFONTDIR</dir>\\n\"",
}); });
} else { } else {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_FSTATFS", "-DHAVE_FSTATFS",
"-DHAVE_FSTATVFS", "-DHAVE_FSTATVFS",
"-DHAVE_GETOPT", "-DHAVE_GETOPT",
@@ -173,13 +173,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
}); });
if (target.result.os.tag == .freebsd) { if (target.result.os.tag == .freebsd) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DFC_TEMPLATEDIR=\"/usr/local/etc/fonts/conf.avail\"", "-DFC_TEMPLATEDIR=\"/usr/local/etc/fonts/conf.avail\"",
"-DFONTCONFIG_PATH=\"/usr/local/etc/fonts\"", "-DFONTCONFIG_PATH=\"/usr/local/etc/fonts\"",
"-DCONFIGDIR=\"/usr/local/etc/fonts/conf.d\"", "-DCONFIGDIR=\"/usr/local/etc/fonts/conf.d\"",
}); });
} else { } else {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DFC_TEMPLATEDIR=\"/usr/share/fontconfig/conf.avail\"", "-DFC_TEMPLATEDIR=\"/usr/share/fontconfig/conf.avail\"",
"-DFONTCONFIG_PATH=\"/etc/fonts\"", "-DFONTCONFIG_PATH=\"/etc/fonts\"",
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"", "-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
@@ -187,7 +187,7 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
} }
if (target.result.os.tag == .linux) { if (target.result.os.tag == .linux) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_SYS_STATFS_H", "-DHAVE_SYS_STATFS_H",
"-DHAVE_SYS_VFS_H", "-DHAVE_SYS_VFS_H",
}); });
@@ -214,14 +214,14 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
// Libxml2 // Libxml2
_ = b.systemIntegrationOption("libxml2", .{}); // So it shows up in help _ = b.systemIntegrationOption("libxml2", .{}); // So it shows up in help
if (libxml2_enabled) { if (libxml2_enabled) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DENABLE_LIBXML2", "-DENABLE_LIBXML2",
"-DLIBXML_STATIC", "-DLIBXML_STATIC",
"-DLIBXML_PUSH_ENABLED", "-DLIBXML_PUSH_ENABLED",
}); });
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
// NOTE: this should be defined on all targets // NOTE: this should be defined on all targets
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-Werror=implicit-function-declaration", "-Werror=implicit-function-declaration",
}); });
} }

View File

@@ -77,9 +77,9 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DFT2_BUILD_LIBRARY", "-DFT2_BUILD_LIBRARY",
"-DFT_CONFIG_OPTION_SYSTEM_ZLIB=1", "-DFT_CONFIG_OPTION_SYSTEM_ZLIB=1",
@@ -103,7 +103,7 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
// Libpng // Libpng
_ = b.systemIntegrationOption("libpng", .{}); // So it shows up in help _ = b.systemIntegrationOption("libpng", .{}); // So it shows up in help
if (libpng_enabled) { if (libpng_enabled) {
try flags.append("-DFT_CONFIG_OPTION_USE_PNG=1"); try flags.append(b.allocator, "-DFT_CONFIG_OPTION_USE_PNG=1");
if (b.systemIntegrationOption("libpng", .{})) { if (b.systemIntegrationOption("libpng", .{})) {
lib.linkSystemLibrary2("libpng", dynamic_link_opts); lib.linkSystemLibrary2("libpng", dynamic_link_opts);

View File

@@ -193,8 +193,8 @@ pub const Face = struct {
) void { ) void {
c.FT_Set_Transform( c.FT_Set_Transform(
self.handle, self.handle,
@constCast(@ptrCast(matrix)), @ptrCast(@constCast(matrix)),
@constCast(@ptrCast(delta)), @ptrCast(@constCast(delta)),
); );
} }
}; };

View File

@@ -59,9 +59,9 @@ fn buildGlslang(
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-fno-sanitize=undefined", "-fno-sanitize=undefined",
"-fno-sanitize-trap=undefined", "-fno-sanitize-trap=undefined",
}); });

View File

@@ -36,10 +36,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
const optimize = options.optimize; const optimize = options.optimize;
// Shared library // Shared library
const lib = b.addSharedLibrary(.{ const lib = b.addLibrary(.{
.name = "gtk4-layer-shell", .name = "gtk4-layer-shell",
.target = target, .linkage = .dynamic,
.optimize = optimize, .root_module = b.createModule(.{
.target = target,
.optimize = optimize,
}),
}); });
b.installArtifact(lib); b.installArtifact(lib);

View File

@@ -111,13 +111,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
const dynamic_link_opts = options.dynamic_link_opts; const dynamic_link_opts = options.dynamic_link_opts;
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_STDBOOL_H", "-DHAVE_STDBOOL_H",
}); });
if (target.result.os.tag != .windows) { if (target.result.os.tag != .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_UNISTD_H", "-DHAVE_UNISTD_H",
"-DHAVE_SYS_MMAN_H", "-DHAVE_SYS_MMAN_H",
"-DHAVE_PTHREAD=1", "-DHAVE_PTHREAD=1",
@@ -127,7 +127,7 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
// Freetype // Freetype
_ = b.systemIntegrationOption("freetype", .{}); // So it shows up in help _ = b.systemIntegrationOption("freetype", .{}); // So it shows up in help
if (freetype_enabled) { if (freetype_enabled) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_FREETYPE=1", "-DHAVE_FREETYPE=1",
// Let's just assume a new freetype // Let's just assume a new freetype
@@ -153,7 +153,7 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
} }
if (coretext_enabled) { if (coretext_enabled) {
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"}); try flags.appendSlice(b.allocator, &.{"-DHAVE_CORETEXT=1"});
lib.linkFramework("CoreText"); lib.linkFramework("CoreText");
module.linkFramework("CoreText", .{}); module.linkFramework("CoreText", .{});
} }

View File

@@ -31,9 +31,9 @@ pub fn build(b: *std.Build) !void {
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
// Avoid changing binaries based on the current time and date. // Avoid changing binaries based on the current time and date.
"-Wno-builtin-macro-redefined", "-Wno-builtin-macro-redefined",
"-D__DATE__=\"redacted\"", "-D__DATE__=\"redacted\"",
@@ -69,7 +69,7 @@ pub fn build(b: *std.Build) !void {
"-fno-vectorize", "-fno-vectorize",
}); });
if (target.result.os.tag != .windows) { if (target.result.os.tag != .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-fmath-errno", "-fmath-errno",
"-fno-exceptions", "-fno-exceptions",
}); });

View File

@@ -22,9 +22,9 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_CONFIG_H", "-DHAVE_CONFIG_H",
"-DLOCALEDIR=\"\"", "-DLOCALEDIR=\"\"",
}); });

View File

@@ -46,9 +46,9 @@ pub fn build(b: *std.Build) !void {
} }
if (b.lazyDependency("libpng", .{})) |upstream| { if (b.lazyDependency("libpng", .{})) |upstream| {
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DPNG_ARM_NEON_OPT=0", "-DPNG_ARM_NEON_OPT=0",
"-DPNG_POWERPC_VSX_OPT=0", "-DPNG_POWERPC_VSX_OPT=0",
"-DPNG_INTEL_SSE_OPT=0", "-DPNG_INTEL_SSE_OPT=0",

View File

@@ -25,9 +25,9 @@ pub fn build(b: *std.Build) !void {
lib.addIncludePath(b.path("override/config/posix")); lib.addIncludePath(b.path("override/config/posix"));
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
// Version info, hardcoded // Version info, hardcoded
comptime "-DLIBXML_VERSION=" ++ Version.number(), comptime "-DLIBXML_VERSION=" ++ Version.number(),
comptime "-DLIBXML_VERSION_STRING=" ++ Version.string(), comptime "-DLIBXML_VERSION_STRING=" ++ Version.string(),
@@ -46,7 +46,7 @@ pub fn build(b: *std.Build) !void {
"-DWITHOUT_TRIO=1", "-DWITHOUT_TRIO=1",
}); });
if (target.result.os.tag != .windows) { if (target.result.os.tag != .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_ARPA_INET_H=1", "-DHAVE_ARPA_INET_H=1",
"-DHAVE_ARPA_NAMESER_H=1", "-DHAVE_ARPA_NAMESER_H=1",
"-DHAVE_DL_H=1", "-DHAVE_DL_H=1",
@@ -74,25 +74,25 @@ pub fn build(b: *std.Build) !void {
var nameBuf: [32]u8 = undefined; var nameBuf: [32]u8 = undefined;
const name = std.ascii.upperString(&nameBuf, field.name); const name = std.ascii.upperString(&nameBuf, field.name);
const define = try std.fmt.allocPrint(b.allocator, "-DLIBXML_{s}_ENABLED=1", .{name}); const define = try std.fmt.allocPrint(b.allocator, "-DLIBXML_{s}_ENABLED=1", .{name});
try flags.append(define); try flags.append(b.allocator, define);
if (std.mem.eql(u8, field.name, "history")) { if (std.mem.eql(u8, field.name, "history")) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_LIBHISTORY=1", "-DHAVE_LIBHISTORY=1",
"-DHAVE_LIBREADLINE=1", "-DHAVE_LIBREADLINE=1",
}); });
} }
if (std.mem.eql(u8, field.name, "mem_debug")) { if (std.mem.eql(u8, field.name, "mem_debug")) {
try flags.append("-DDEBUG_MEMORY_LOCATION=1"); try flags.append(b.allocator, "-DDEBUG_MEMORY_LOCATION=1");
} }
if (std.mem.eql(u8, field.name, "regexp")) { if (std.mem.eql(u8, field.name, "regexp")) {
try flags.append("-DLIBXML_UNICODE_ENABLED=1"); try flags.append(b.allocator, "-DLIBXML_UNICODE_ENABLED=1");
} }
if (std.mem.eql(u8, field.name, "run_debug")) { if (std.mem.eql(u8, field.name, "run_debug")) {
try flags.append("-DLIBXML_DEBUG_RUNTIME=1"); try flags.append(b.allocator, "-DLIBXML_DEBUG_RUNTIME=1");
} }
if (std.mem.eql(u8, field.name, "thread")) { if (std.mem.eql(u8, field.name, "thread")) {
try flags.append("-DHAVE_LIBPTHREAD=1"); try flags.append(b.allocator, "-DHAVE_LIBPTHREAD=1");
} }
} }
} }

View File

@@ -68,7 +68,7 @@ pub const MutableArray = opaque {
comptime Elem: type, comptime Elem: type,
value: *const Elem, value: *const Elem,
) void { ) void {
CFArrayAppendValue(self, @constCast(@ptrCast(value))); CFArrayAppendValue(self, @ptrCast(@constCast(value)));
} }
pub fn removeValue(self: *MutableArray, idx: usize) void { pub fn removeValue(self: *MutableArray, idx: usize) void {

View File

@@ -10,7 +10,7 @@ pub const AttributedString = opaque {
str: *foundation.String, str: *foundation.String,
attributes: *foundation.Dictionary, attributes: *foundation.Dictionary,
) Allocator.Error!*AttributedString { ) Allocator.Error!*AttributedString {
return @constCast(@ptrCast(c.CFAttributedStringCreate( return @ptrCast(@constCast(c.CFAttributedStringCreate(
null, null,
@ptrCast(str), @ptrCast(str),
@ptrCast(attributes), @ptrCast(attributes),

View File

@@ -17,8 +17,8 @@ pub const Dictionary = opaque {
return @as(?*Dictionary, @ptrFromInt(@intFromPtr(c.CFDictionaryCreate( return @as(?*Dictionary, @ptrFromInt(@intFromPtr(c.CFDictionaryCreate(
null, null,
@constCast(@ptrCast(if (keys) |slice| slice.ptr else null)), @ptrCast(@constCast(if (keys) |slice| slice.ptr else null)),
@constCast(@ptrCast(if (values) |slice| slice.ptr else null)), @ptrCast(@constCast(if (values) |slice| slice.ptr else null)),
@intCast(if (keys) |slice| slice.len else 0), @intCast(if (keys) |slice| slice.len else 0),
&c.kCFTypeDictionaryKeyCallBacks, &c.kCFTypeDictionaryKeyCallBacks,
&c.kCFTypeDictionaryValueCallBacks, &c.kCFTypeDictionaryValueCallBacks,

View File

@@ -32,10 +32,11 @@ pub const Log = opaque {
comptime format: []const u8, comptime format: []const u8,
args: anytype, args: anytype,
) void { ) void {
const str = nosuspend std.fmt.allocPrintZ( const str = nosuspend std.fmt.allocPrintSentinel(
alloc, alloc,
format, format,
args, args,
0,
) catch return; ) catch return;
defer alloc.free(str); defer alloc.free(str);
zig_os_log_with_type(self, typ, str.ptr); zig_os_log_with_type(self, typ, str.ptr);

View File

@@ -68,7 +68,7 @@ pub const Font = opaque {
} }
pub fn copyTable(self: *Font, tag: FontTableTag) ?*foundation.Data { pub fn copyTable(self: *Font, tag: FontTableTag) ?*foundation.Data {
return @constCast(@ptrCast(c.CTFontCopyTable( return @ptrCast(@constCast(c.CTFontCopyTable(
@ptrCast(self), @ptrCast(self),
@intFromEnum(tag), @intFromEnum(tag),
c.kCTFontTableOptionNoOptions, c.kCTFontTableOptionNoOptions,
@@ -90,7 +90,7 @@ pub const Font = opaque {
} }
pub fn createPathForGlyph(self: *Font, glyph: graphics.Glyph) ?*graphics.Path { pub fn createPathForGlyph(self: *Font, glyph: graphics.Glyph) ?*graphics.Path {
return @constCast(@ptrCast(c.CTFontCreatePathForGlyph( return @ptrCast(@constCast(c.CTFontCreatePathForGlyph(
@ptrCast(self), @ptrCast(self),
glyph, glyph,
null, null,

View File

@@ -51,7 +51,7 @@ pub const Line = opaque {
} }
pub fn getGlyphRuns(self: *Line) *foundation.Array { pub fn getGlyphRuns(self: *Line) *foundation.Array {
return @constCast(@ptrCast(c.CTLineGetGlyphRuns(@ptrCast(self)))); return @ptrCast(@constCast(c.CTLineGetGlyphRuns(@ptrCast(self))));
} }
}; };

View File

@@ -74,7 +74,7 @@ pub const DisplayLink = opaque {
callbackFn( callbackFn(
displayLink, displayLink,
@alignCast(@ptrCast(inner_userinfo)), @ptrCast(@alignCast(inner_userinfo)),
); );
return c.kCVReturnSuccess; return c.kCVReturnSuccess;
} }

View File

@@ -100,9 +100,8 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
.SIZEOF_VOIDP = t.ptrBitWidth() / t.cTypeBitSize(.char), .SIZEOF_VOIDP = t.ptrBitWidth() / t.cTypeBitSize(.char),
})); }));
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{});
lib.addCSourceFiles(.{ lib.addCSourceFiles(.{
.root = upstream.path(""), .root = upstream.path(""),
.flags = flags.items, .flags = flags.items,

View File

@@ -6,7 +6,7 @@ const errors = @import("errors.zig");
/// the encodings that the program will use. /// the encodings that the program will use.
pub fn init(encs: []const *Encoding) !void { pub fn init(encs: []const *Encoding) !void {
_ = try errors.convertError(c.onig_initialize( _ = try errors.convertError(c.onig_initialize(
@constCast(@ptrCast(@alignCast(encs.ptr))), @ptrCast(@alignCast(@constCast(encs.ptr))),
@intCast(encs.len), @intCast(encs.len),
)); ));
} }

View File

@@ -26,22 +26,21 @@ pub fn build(b: *std.Build) !void {
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{});
if (target.result.os.tag == .windows) { if (target.result.os.tag == .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DSENTRY_WITH_UNWINDER_DBGHELP", "-DSENTRY_WITH_UNWINDER_DBGHELP",
}); });
} else { } else {
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DSENTRY_WITH_UNWINDER_LIBBACKTRACE", "-DSENTRY_WITH_UNWINDER_LIBBACKTRACE",
}); });
} }
switch (backend) { switch (backend) {
.crashpad => try flags.append("-DSENTRY_BACKEND_CRASHPAD"), .crashpad => try flags.append(b.allocator, "-DSENTRY_BACKEND_CRASHPAD"),
.breakpad => try flags.append("-DSENTRY_BACKEND_BREAKPAD"), .breakpad => try flags.append(b.allocator, "-DSENTRY_BACKEND_BREAKPAD"),
.inproc => try flags.append("-DSENTRY_BACKEND_INPROC"), .inproc => try flags.append(b.allocator, "-DSENTRY_BACKEND_INPROC"),
.none => {}, .none => {},
} }

View File

@@ -20,11 +20,11 @@ pub fn build(b: *std.Build) !void {
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414 // Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// (See root Ghostty build.zig on why we do this) // (See root Ghostty build.zig on why we do this)
try flags.appendSlice(&.{"-DSIMDUTF_IMPLEMENTATION_ICELAKE=0"}); try flags.appendSlice(b.allocator, &.{"-DSIMDUTF_IMPLEMENTATION_ICELAKE=0"});
lib.addCSourceFiles(.{ lib.addCSourceFiles(.{
.flags = flags.items, .flags = flags.items,

View File

@@ -64,9 +64,9 @@ fn buildSpirvCross(
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DSPIRV_CROSS_C_API_GLSL=1", "-DSPIRV_CROSS_C_API_GLSL=1",
"-DSPIRV_CROSS_C_API_MSL=1", "-DSPIRV_CROSS_C_API_MSL=1",

View File

@@ -19,9 +19,8 @@ pub fn build(b: *std.Build) !void {
try apple_sdk.addPaths(b, lib); try apple_sdk.addPaths(b, lib);
} }
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{});
lib.addCSourceFiles(.{ lib.addCSourceFiles(.{
.flags = flags.items, .flags = flags.items,

View File

@@ -17,11 +17,11 @@ pub fn build(b: *std.Build) !void {
}); });
unit_tests.linkLibC(); unit_tests.linkLibC();
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.append("-DWUFFS_IMPLEMENTATION"); try flags.append(b.allocator, "-DWUFFS_IMPLEMENTATION");
inline for (@import("src/c.zig").defines) |key| { inline for (@import("src/c.zig").defines) |key| {
try flags.append("-D" ++ key); try flags.append(b.allocator, "-D" ++ key);
} }
if (b.lazyDependency("wuffs", .{})) |wuffs_dep| { if (b.lazyDependency("wuffs", .{})) |wuffs_dep| {

View File

@@ -31,7 +31,7 @@ pub fn decode(alloc: Allocator, data: []const u8) Error!ImageData {
} }
var source_buffer: c.wuffs_base__io_buffer = .{ var source_buffer: c.wuffs_base__io_buffer = .{
.data = .{ .ptr = @constCast(@ptrCast(data.ptr)), .len = data.len }, .data = .{ .ptr = @ptrCast(@constCast(data.ptr)), .len = data.len },
.meta = .{ .meta = .{
.wi = data.len, .wi = data.len,
.ri = 0, .ri = 0,

View File

@@ -31,7 +31,7 @@ pub fn decode(alloc: Allocator, data: []const u8) Error!ImageData {
} }
var source_buffer: c.wuffs_base__io_buffer = .{ var source_buffer: c.wuffs_base__io_buffer = .{
.data = .{ .ptr = @constCast(@ptrCast(data.ptr)), .len = data.len }, .data = .{ .ptr = @ptrCast(@constCast(data.ptr)), .len = data.len },
.meta = .{ .meta = .{
.wi = data.len, .wi = data.len,
.ri = 0, .ri = 0,

View File

@@ -26,9 +26,9 @@ pub fn build(b: *std.Build) !void {
.{ .include_extensions = &.{".h"} }, .{ .include_extensions = &.{".h"} },
); );
var flags = std.ArrayList([]const u8).init(b.allocator); var flags: std.ArrayList([]const u8) = .empty;
defer flags.deinit(); defer flags.deinit(b.allocator);
try flags.appendSlice(&.{ try flags.appendSlice(b.allocator, &.{
"-DHAVE_SYS_TYPES_H", "-DHAVE_SYS_TYPES_H",
"-DHAVE_STDINT_H", "-DHAVE_STDINT_H",
"-DHAVE_STDDEF_H", "-DHAVE_STDDEF_H",

View File

@@ -52,7 +52,7 @@ parts:
rm -rf $CRAFT_PART_SRC/* rm -rf $CRAFT_PART_SRC/*
if [[ -n $arch ]]; then if [[ -n $arch ]]; then
curl -LO --retry-connrefused --retry 10 https://ziglang.org/download/0.14.0/zig-linux-$arch-0.14.0.tar.xz curl -LO --retry-connrefused --retry 10 https://ziglang.org/download/0.15.1/zig-$arch-linux-0.15.1.tar.xz
else else
echo "Unsupported arch" echo "Unsupported arch"
exit 1 exit 1

View File

@@ -194,7 +194,9 @@ fn startPosix(self: *Command, arena: Allocator) !void {
// child process so there isn't much we can do. We try to output // child process so there isn't much we can do. We try to output
// something reasonable. Its important to note we MUST NOT return // something reasonable. Its important to note we MUST NOT return
// any other error condition from here on out. // any other error condition from here on out.
const stderr = std.io.getStdErr().writer(); var stderr_buf: [1024]u8 = undefined;
var stderr_writer = std.fs.File.stderr().writer(&stderr_buf);
const stderr = &stderr_writer.interface;
switch (err) { switch (err) {
error.FileNotFound => stderr.print( error.FileNotFound => stderr.print(
\\Requested executable not found. Please verify the command is on \\Requested executable not found. Please verify the command is on
@@ -211,6 +213,7 @@ fn startPosix(self: *Command, arena: Allocator) !void {
.{err}, .{err},
) catch {}, ) catch {},
} }
stderr.flush() catch {};
// We return a very specific error that can be detected to determine // We return a very specific error that can be detected to determine
// we're in the child. // we're in the child.
@@ -464,34 +467,35 @@ fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) ![]u1
/// Copied from Zig. This function could be made public in child_process.zig instead. /// Copied from Zig. This function could be made public in child_process.zig instead.
fn windowsCreateCommandLine(allocator: mem.Allocator, argv: []const []const u8) ![:0]u8 { fn windowsCreateCommandLine(allocator: mem.Allocator, argv: []const []const u8) ![:0]u8 {
var buf = std.ArrayList(u8).init(allocator); var buf: std.Io.Writer.Allocating = .init(allocator);
defer buf.deinit(); defer buf.deinit();
const writer = &buf.writer;
for (argv, 0..) |arg, arg_i| { for (argv, 0..) |arg, arg_i| {
if (arg_i != 0) try buf.append(' '); if (arg_i != 0) try writer.writeByte(' ');
if (mem.indexOfAny(u8, arg, " \t\n\"") == null) { if (mem.indexOfAny(u8, arg, " \t\n\"") == null) {
try buf.appendSlice(arg); try writer.writeAll(arg);
continue; continue;
} }
try buf.append('"'); try writer.writeByte('"');
var backslash_count: usize = 0; var backslash_count: usize = 0;
for (arg) |byte| { for (arg) |byte| {
switch (byte) { switch (byte) {
'\\' => backslash_count += 1, '\\' => backslash_count += 1,
'"' => { '"' => {
try buf.appendNTimes('\\', backslash_count * 2 + 1); try writer.splatByteAll('\\', backslash_count * 2 + 1);
try buf.append('"'); try writer.writeByte('"');
backslash_count = 0; backslash_count = 0;
}, },
else => { else => {
try buf.appendNTimes('\\', backslash_count); try writer.splatByteAll('\\', backslash_count);
try buf.append(byte); try writer.writeByte(byte);
backslash_count = 0; backslash_count = 0;
}, },
} }
} }
try buf.appendNTimes('\\', backslash_count * 2); try writer.splatByteAll('\\', backslash_count * 2);
try buf.append('"'); try writer.writeByte('"');
} }
return buf.toOwnedSliceSentinel(0); return buf.toOwnedSliceSentinel(0);

View File

@@ -305,19 +305,19 @@ const DerivedConfig = struct {
// Build all of our links // Build all of our links
const links = links: { const links = links: {
var links = std.ArrayList(Link).init(alloc); var links: std.ArrayList(Link) = .empty;
defer links.deinit(); defer links.deinit(alloc);
for (config.link.links.items) |link| { for (config.link.links.items) |link| {
var regex = try link.oniRegex(); var regex = try link.oniRegex();
errdefer regex.deinit(); errdefer regex.deinit();
try links.append(.{ try links.append(alloc, .{
.regex = regex, .regex = regex,
.action = link.action, .action = link.action,
.highlight = link.highlight, .highlight = link.highlight,
}); });
} }
break :links try links.toOwnedSlice(); break :links try links.toOwnedSlice(alloc);
}; };
errdefer { errdefer {
for (links) |*link| link.regex.deinit(); for (links) |*link| link.regex.deinit();
@@ -1009,7 +1009,7 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
self.command_timer = null; self.command_timer = null;
const duration: Duration = .{ .duration = end.since(start) }; const duration: Duration = .{ .duration = end.since(start) };
log.debug("command took {}", .{duration}); log.debug("command took {f}", .{duration});
_ = self.rt_app.performAction( _ = self.rt_app.performAction(
.{ .surface = self }, .{ .surface = self },
@@ -2493,7 +2493,7 @@ fn maybeHandleBinding(
self.keyboard.bindings = null; self.keyboard.bindings = null;
// Attempt to perform the action // Attempt to perform the action
log.debug("key event binding flags={} action={}", .{ log.debug("key event binding flags={} action={f}", .{
leaf.flags, leaf.flags,
action, action,
}); });
@@ -5119,7 +5119,9 @@ fn writeScreenFile(
defer file.close(); defer file.close();
// Screen.dumpString writes byte-by-byte, so buffer it // Screen.dumpString writes byte-by-byte, so buffer it
var buf_writer = std.io.bufferedWriter(file.writer()); var buf: [4096]u8 = undefined;
var file_writer = file.writer(&buf);
var buf_writer = &file_writer.interface;
// Write the scrollback contents. This requires a lock. // Write the scrollback contents. This requires a lock.
{ {
@@ -5169,7 +5171,7 @@ fn writeScreenFile(
const br = sel.bottomRight(&self.io.terminal.screen); const br = sel.bottomRight(&self.io.terminal.screen);
try self.io.terminal.screen.dumpString( try self.io.terminal.screen.dumpString(
buf_writer.writer(), buf_writer,
.{ .{
.tl = tl, .tl = tl,
.br = br, .br = br,

View File

@@ -578,7 +578,7 @@ pub const SetTitle = struct {
value: @This(), value: @This(),
comptime _: []const u8, comptime _: []const u8,
_: std.fmt.FormatOptions, _: std.fmt.FormatOptions,
writer: anytype, writer: *std.Io.Writer,
) !void { ) !void {
try writer.print("{s}{{ {s} }}", .{ @typeName(@This()), value.title }); try writer.print("{s}{{ {s} }}", .{ @typeName(@This()), value.title });
} }
@@ -602,7 +602,7 @@ pub const Pwd = struct {
value: @This(), value: @This(),
comptime _: []const u8, comptime _: []const u8,
_: std.fmt.FormatOptions, _: std.fmt.FormatOptions,
writer: anytype, writer: *std.Io.Writer,
) !void { ) !void {
try writer.print("{s}{{ {s} }}", .{ @typeName(@This()), value.pwd }); try writer.print("{s}{{ {s} }}", .{ @typeName(@This()), value.pwd });
} }
@@ -630,7 +630,7 @@ pub const DesktopNotification = struct {
value: @This(), value: @This(),
comptime _: []const u8, comptime _: []const u8,
_: std.fmt.FormatOptions, _: std.fmt.FormatOptions,
writer: anytype, writer: *std.Io.Writer,
) !void { ) !void {
try writer.print("{s}{{ title: {s}, body: {s} }}", .{ try writer.print("{s}{{ title: {s}, body: {s} }}", .{
@typeName(@This()), @typeName(@This()),

View File

@@ -266,8 +266,8 @@ pub const App = struct {
// embedded apprt. // embedded apprt.
self.performPreAction(target, action, value); self.performPreAction(target, action, value);
log.debug("dispatching action target={s} action={} value={}", .{ log.debug("dispatching action target={t} action={} value={any}", .{
@tagName(target), target,
action, action,
value, value,
}); });
@@ -1910,7 +1910,7 @@ pub const CAPI = struct {
}; };
return ptr.core_surface.performBindingAction(action) catch |err| { return ptr.core_surface.performBindingAction(action) catch |err| {
log.err("error performing binding action action={} err={}", .{ action, err }); log.err("error performing binding action action={f} err={}", .{ action, err });
return false; return false;
}; };
} }

View File

@@ -27,7 +27,7 @@ pub fn getRuntimeVersion() std.SemanticVersion {
} }
pub fn logVersion() void { pub fn logVersion() void {
log.info("libadwaita version build={} runtime={}", .{ log.info("libadwaita version build={f} runtime={f}", .{
comptime_version, comptime_version,
getRuntimeVersion(), getRuntimeVersion(),
}); });

View File

@@ -45,7 +45,7 @@ pub fn main() !void {
std.debug.print( std.debug.print(
\\`libadwaita` is too old. \\`libadwaita` is too old.
\\ \\
\\Ghostty requires a version {} or newer of `libadwaita` to \\Ghostty requires a version {f} or newer of `libadwaita` to
\\compile this blueprint. Please install it, ensure that it is \\compile this blueprint. Please install it, ensure that it is
\\available on your PATH, and then retry building Ghostty. \\available on your PATH, and then retry building Ghostty.
, .{required_adwaita_version}); , .{required_adwaita_version});
@@ -80,7 +80,7 @@ pub fn main() !void {
std.debug.print( std.debug.print(
\\`blueprint-compiler` not found. \\`blueprint-compiler` not found.
\\ \\
\\Ghostty requires version {} or newer of \\Ghostty requires version {f} or newer of
\\`blueprint-compiler` as a build-time dependency starting \\`blueprint-compiler` as a build-time dependency starting
\\from version 1.2. Please install it, ensure that it is \\from version 1.2. Please install it, ensure that it is
\\available on your PATH, and then retry building Ghostty. \\available on your PATH, and then retry building Ghostty.
@@ -104,7 +104,7 @@ pub fn main() !void {
std.debug.print( std.debug.print(
\\`blueprint-compiler` is the wrong version. \\`blueprint-compiler` is the wrong version.
\\ \\
\\Ghostty requires version {} or newer of \\Ghostty requires version {f} or newer of
\\`blueprint-compiler` as a build-time dependency starting \\`blueprint-compiler` as a build-time dependency starting
\\from version 1.2. Please install it, ensure that it is \\from version 1.2. Please install it, ensure that it is
\\available on your PATH, and then retry building Ghostty. \\available on your PATH, and then retry building Ghostty.
@@ -145,7 +145,7 @@ pub fn main() !void {
std.debug.print( std.debug.print(
\\`blueprint-compiler` not found. \\`blueprint-compiler` not found.
\\ \\
\\Ghostty requires version {} or newer of \\Ghostty requires version {f} or newer of
\\`blueprint-compiler` as a build-time dependency starting \\`blueprint-compiler` as a build-time dependency starting
\\from version 1.2. Please install it, ensure that it is \\from version 1.2. Please install it, ensure that it is
\\available on your PATH, and then retry building Ghostty. \\available on your PATH, and then retry building Ghostty.

View File

@@ -142,7 +142,9 @@ pub fn main() !void {
); );
} }
const writer = std.io.getStdOut().writer(); var buf: [4096]u8 = undefined;
var stdout = std.fs.File.stdout().writer(&buf);
const writer = &stdout.interface;
try writer.writeAll( try writer.writeAll(
\\<?xml version="1.0" encoding="UTF-8"?> \\<?xml version="1.0" encoding="UTF-8"?>
\\<gresources> \\<gresources>
@@ -157,12 +159,14 @@ pub fn main() !void {
\\</gresources> \\</gresources>
\\ \\
); );
try stdout.end();
} }
/// Generate the icon resources. This works by looking up all the icons /// Generate the icon resources. This works by looking up all the icons
/// specified by `icon_sizes` in `images/icons/`. They are asserted to exist /// specified by `icon_sizes` in `images/icons/`. They are asserted to exist
/// by trying to access the file. /// by trying to access the file.
fn genIcons(writer: anytype) !void { fn genIcons(writer: *std.Io.Writer) !void {
try writer.print( try writer.print(
\\ <gresource prefix="{s}/icons"> \\ <gresource prefix="{s}/icons">
\\ \\
@@ -204,7 +208,7 @@ fn genIcons(writer: anytype) !void {
} }
/// Generate the resources at the root prefix. /// Generate the resources at the root prefix.
fn genRoot(writer: anytype) !void { fn genRoot(writer: *std.Io.Writer) !void {
try writer.print( try writer.print(
\\ <gresource prefix="{s}"> \\ <gresource prefix="{s}">
\\ \\
@@ -236,7 +240,7 @@ fn genRoot(writer: anytype) !void {
/// assuming these will be /// assuming these will be
fn genUi( fn genUi(
alloc: Allocator, alloc: Allocator,
writer: anytype, writer: *std.Io.Writer,
files: *const std.ArrayListUnmanaged([]const u8), files: *const std.ArrayListUnmanaged([]const u8),
) !void { ) !void {
try writer.print( try writer.print(

View File

@@ -50,7 +50,7 @@ pub fn init(
) orelse ""; ) orelse "";
if (!std.mem.eql(u8, original, current)) break :transient current; if (!std.mem.eql(u8, original, current)) break :transient current;
alloc.free(current); alloc.free(current);
std.time.sleep(25 * std.time.ns_per_ms); std.Thread.sleep(25 * std.time.ns_per_ms);
}; };
errdefer alloc.free(transient); errdefer alloc.free(transient);
log.info("transient scope created cgroup={s}", .{transient}); log.info("transient scope created cgroup={s}", .{transient});
@@ -101,21 +101,21 @@ fn enableControllers(alloc: Allocator, cgroup: []const u8) !void {
defer alloc.free(raw); defer alloc.free(raw);
// Build our string builder for enabling all controllers // Build our string builder for enabling all controllers
var builder = std.ArrayList(u8).init(alloc); var builder: std.Io.Writer.Allocating = .init(alloc);
defer builder.deinit(); defer builder.deinit();
// Controllers are space-separated // Controllers are space-separated
var it = std.mem.splitScalar(u8, raw, ' '); var it = std.mem.splitScalar(u8, raw, ' ');
while (it.next()) |controller| { while (it.next()) |controller| {
try builder.append('+'); try builder.writer.writeByte('+');
try builder.appendSlice(controller); try builder.writer.writeAll(controller);
if (it.rest().len > 0) try builder.append(' '); if (it.rest().len > 0) try builder.writer.writeByte(' ');
} }
// Enable them all // Enable them all
try internal_os.cgroup.configureControllers( try internal_os.cgroup.configureControllers(
cgroup, cgroup,
builder.items, builder.written(),
); );
} }

View File

@@ -282,7 +282,7 @@ pub fn Common(
fn setter(self: *Self, value: ?[:0]const u8) void { fn setter(self: *Self, value: ?[:0]const u8) void {
const priv = private(self); const priv = private(self);
if (@field(priv, name)) |v| { if (@field(priv, name)) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
} }
// We don't need to copy this because it was already // We don't need to copy this because it was already

View File

@@ -1044,7 +1044,9 @@ pub const Application = extern struct {
defer file.close(); defer file.close();
log.info("loading gtk-custom-css path={s}", .{path}); log.info("loading gtk-custom-css path={s}", .{path});
const contents = try file.reader().readAllAlloc( var buf: [4096]u8 = undefined;
var reader = file.reader(&buf);
const contents = try reader.interface.readAlloc(
alloc, alloc,
5 * 1024 * 1024, // 5MB, 5 * 1024 * 1024, // 5MB,
); );
@@ -1115,8 +1117,8 @@ pub const Application = extern struct {
// This should really never, never happen. Its not critical enough // This should really never, never happen. Its not critical enough
// to actually crash, but this is a bug somewhere. An accelerator // to actually crash, but this is a bug somewhere. An accelerator
// for a trigger can't possibly be more than 1024 bytes. // for a trigger can't possibly be more than 1024 bytes.
error.NoSpaceLeft => { error.WriteFailed => {
log.warn("accelerator somehow longer than 1024 bytes: {}", .{trigger}); log.warn("accelerator somehow longer than 1024 bytes: {f}", .{trigger});
return; return;
}, },
}; };

View File

@@ -485,10 +485,11 @@ const Command = extern struct {
const command = priv.command orelse return null; const command = priv.command orelse return null;
priv.action_key = std.fmt.allocPrintZ( priv.action_key = std.fmt.allocPrintSentinel(
priv.arena.allocator(), priv.arena.allocator(),
"{}", "{f}",
.{command.action}, .{command.action},
0,
) catch null; ) catch null;
return priv.action_key; return priv.action_key;

View File

@@ -117,10 +117,10 @@ pub const Config = extern struct {
errdefer text_buf.unref(); errdefer text_buf.unref();
var buf: [4095:0]u8 = undefined; var buf: [4095:0]u8 = undefined;
var fbs = std.io.fixedBufferStream(&buf); var writer: std.Io.Writer = .fixed(&buf);
for (config._diagnostics.items()) |diag| { for (config._diagnostics.items()) |diag| {
fbs.reset(); writer.end = 0;
diag.write(fbs.writer()) catch |err| { diag.format(&writer) catch |err| {
log.warn( log.warn(
"error writing diagnostic to buffer err={}", "error writing diagnostic to buffer err={}",
.{err}, .{err},
@@ -128,7 +128,7 @@ pub const Config = extern struct {
continue; continue;
}; };
text_buf.insertAtCursor(&buf, @intCast(fbs.pos)); text_buf.insertAtCursor(&buf, @intCast(writer.end));
text_buf.insertAtCursor("\n", 1); text_buf.insertAtCursor("\n", 1);
} }

View File

@@ -188,9 +188,9 @@ pub const GlobalShortcuts = extern struct {
// If there isn't space to translate the trigger, then our // If there isn't space to translate the trigger, then our
// buffer might be too small (but 1024 is insane!). In any case // buffer might be too small (but 1024 is insane!). In any case
// we don't want to stop registering globals. // we don't want to stop registering globals.
error.NoSpaceLeft => { error.WriteFailed => {
log.warn( log.warn(
"buffer too small to translate trigger, ignoring={}", "buffer too small to translate trigger, ignoring={f}",
.{entry.key_ptr.*}, .{entry.key_ptr.*},
); );
continue; continue;
@@ -257,7 +257,7 @@ pub const GlobalShortcuts = extern struct {
const trigger = entry.key_ptr.*.ptr; const trigger = entry.key_ptr.*.ptr;
const action = std.fmt.bufPrintZ( const action = std.fmt.bufPrintZ(
&action_buf, &action_buf,
"{}", "{f}",
.{entry.value_ptr.*}, .{entry.value_ptr.*},
) catch continue; ) catch continue;

View File

@@ -172,7 +172,7 @@ pub const ResizeOverlay = extern struct {
/// overlay if it is currently hidden; you must call schedule. /// overlay if it is currently hidden; you must call schedule.
pub fn setLabel(self: *Self, label: ?[:0]const u8) void { pub fn setLabel(self: *Self, label: ?[:0]const u8) void {
const priv = self.private(); const priv = self.private();
if (priv.label_text) |v| glib.free(@constCast(@ptrCast(v))); if (priv.label_text) |v| glib.free(@ptrCast(@constCast(v)));
priv.label_text = null; priv.label_text = null;
if (label) |v| priv.label_text = glib.ext.dupeZ(u8, v); if (label) |v| priv.label_text = glib.ext.dupeZ(u8, v);
self.as(gobject.Object).notifyByPspec(properties.label.impl.param_spec); self.as(gobject.Object).notifyByPspec(properties.label.impl.param_spec);
@@ -285,7 +285,7 @@ pub const ResizeOverlay = extern struct {
fn finalize(self: *Self) callconv(.c) void { fn finalize(self: *Self) callconv(.c) void {
const priv = self.private(); const priv = self.private();
if (priv.label_text) |v| { if (priv.label_text) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.label_text = null; priv.label_text = null;
} }

View File

@@ -268,7 +268,7 @@ pub const SplitTree = extern struct {
); );
defer new_tree.deinit(); defer new_tree.deinit();
log.debug( log.debug(
"new split at={} direction={} old_tree={} new_tree={}", "new split at={} direction={} old_tree={f} new_tree={f}",
.{ handle, direction, old_tree, &new_tree }, .{ handle, direction, old_tree, &new_tree },
); );

View File

@@ -1375,11 +1375,11 @@ pub const Surface = extern struct {
defer arena.deinit(); defer arena.deinit();
const alloc = arena.allocator(); const alloc = arena.allocator();
var env_to_remove = std.ArrayList([]const u8).init(alloc); var env_to_remove: std.ArrayList([]const u8) = .empty;
var env_to_update = std.ArrayList(struct { var env_to_update: std.ArrayList(struct {
key: []const u8, key: []const u8,
value: []const u8, value: []const u8,
}).init(alloc); }) = .empty;
var it = env_map.iterator(); var it = env_map.iterator();
while (it.next()) |entry| { while (it.next()) |entry| {
@@ -1392,13 +1392,11 @@ pub const Surface = extern struct {
// Any env var starting with SNAP must be removed // Any env var starting with SNAP must be removed
if (std.mem.startsWith(u8, key, "SNAP_")) { if (std.mem.startsWith(u8, key, "SNAP_")) {
try env_to_remove.append(key); try env_to_remove.append(alloc, key);
continue; continue;
} }
var filtered_paths = std.ArrayList([]const u8).init(alloc); var filtered_paths: std.ArrayList([]const u8) = .empty;
defer filtered_paths.deinit();
var modified = false; var modified = false;
var paths = std.mem.splitAny(u8, value, ":"); var paths = std.mem.splitAny(u8, value, ":");
while (paths.next()) |path| { while (paths.next()) |path| {
@@ -1411,15 +1409,15 @@ pub const Surface = extern struct {
break; break;
} }
}; };
if (include) try filtered_paths.append(path); if (include) try filtered_paths.append(alloc, path);
} }
if (modified) { if (modified) {
if (filtered_paths.items.len > 0) { if (filtered_paths.items.len > 0) {
const new_value = try std.mem.join(alloc, ":", filtered_paths.items); const new_value = try std.mem.join(alloc, ":", filtered_paths.items);
try env_to_update.append(.{ .key = key, .value = new_value }); try env_to_update.append(alloc, .{ .key = key, .value = new_value });
} else { } else {
try env_to_remove.append(key); try env_to_remove.append(alloc, key);
} }
} }
} }
@@ -1626,7 +1624,7 @@ pub const Surface = extern struct {
priv.core_surface = null; priv.core_surface = null;
} }
if (priv.mouse_hover_url) |v| { if (priv.mouse_hover_url) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.mouse_hover_url = null; priv.mouse_hover_url = null;
} }
if (priv.default_size) |v| { if (priv.default_size) |v| {
@@ -1642,15 +1640,15 @@ pub const Surface = extern struct {
priv.min_size = null; priv.min_size = null;
} }
if (priv.pwd) |v| { if (priv.pwd) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.pwd = null; priv.pwd = null;
} }
if (priv.title) |v| { if (priv.title) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.title = null; priv.title = null;
} }
if (priv.title_override) |v| { if (priv.title_override) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.title_override = null; priv.title_override = null;
} }
self.clearCgroup(); self.clearCgroup();
@@ -1674,7 +1672,7 @@ pub const Surface = extern struct {
/// title. For manually set titles see `setTitleOverride`. /// title. For manually set titles see `setTitleOverride`.
pub fn setTitle(self: *Self, title: ?[:0]const u8) void { pub fn setTitle(self: *Self, title: ?[:0]const u8) void {
const priv = self.private(); const priv = self.private();
if (priv.title) |v| glib.free(@constCast(@ptrCast(v))); if (priv.title) |v| glib.free(@ptrCast(@constCast(v)));
priv.title = null; priv.title = null;
if (title) |v| priv.title = glib.ext.dupeZ(u8, v); if (title) |v| priv.title = glib.ext.dupeZ(u8, v);
self.as(gobject.Object).notifyByPspec(properties.title.impl.param_spec); self.as(gobject.Object).notifyByPspec(properties.title.impl.param_spec);
@@ -1684,7 +1682,7 @@ pub const Surface = extern struct {
/// unless this is unset (null). /// unless this is unset (null).
pub fn setTitleOverride(self: *Self, title: ?[:0]const u8) void { pub fn setTitleOverride(self: *Self, title: ?[:0]const u8) void {
const priv = self.private(); const priv = self.private();
if (priv.title_override) |v| glib.free(@constCast(@ptrCast(v))); if (priv.title_override) |v| glib.free(@ptrCast(@constCast(v)));
priv.title_override = null; priv.title_override = null;
if (title) |v| priv.title_override = glib.ext.dupeZ(u8, v); if (title) |v| priv.title_override = glib.ext.dupeZ(u8, v);
self.as(gobject.Object).notifyByPspec(properties.@"title-override".impl.param_spec); self.as(gobject.Object).notifyByPspec(properties.@"title-override".impl.param_spec);
@@ -1698,7 +1696,7 @@ pub const Surface = extern struct {
/// Set the pwd for this surface, copies the value. /// Set the pwd for this surface, copies the value.
pub fn setPwd(self: *Self, pwd: ?[:0]const u8) void { pub fn setPwd(self: *Self, pwd: ?[:0]const u8) void {
const priv = self.private(); const priv = self.private();
if (priv.pwd) |v| glib.free(@constCast(@ptrCast(v))); if (priv.pwd) |v| glib.free(@ptrCast(@constCast(v)));
priv.pwd = null; priv.pwd = null;
if (pwd) |v| priv.pwd = glib.ext.dupeZ(u8, v); if (pwd) |v| priv.pwd = glib.ext.dupeZ(u8, v);
self.as(gobject.Object).notifyByPspec(properties.pwd.impl.param_spec); self.as(gobject.Object).notifyByPspec(properties.pwd.impl.param_spec);
@@ -1783,7 +1781,7 @@ pub const Surface = extern struct {
pub fn setMouseHoverUrl(self: *Self, url: ?[:0]const u8) void { pub fn setMouseHoverUrl(self: *Self, url: ?[:0]const u8) void {
const priv = self.private(); const priv = self.private();
if (priv.mouse_hover_url) |v| glib.free(@constCast(@ptrCast(v))); if (priv.mouse_hover_url) |v| glib.free(@ptrCast(@constCast(v)));
priv.mouse_hover_url = null; priv.mouse_hover_url = null;
if (url) |v| priv.mouse_hover_url = glib.ext.dupeZ(u8, v); if (url) |v| priv.mouse_hover_url = glib.ext.dupeZ(u8, v);
self.as(gobject.Object).notifyByPspec(properties.@"mouse-hover-url".impl.param_spec); self.as(gobject.Object).notifyByPspec(properties.@"mouse-hover-url".impl.param_spec);
@@ -2117,13 +2115,11 @@ pub const Surface = extern struct {
const alloc = Application.default().allocator(); const alloc = Application.default().allocator();
if (ext.gValueHolds(value, gdk.FileList.getGObjectType())) { if (ext.gValueHolds(value, gdk.FileList.getGObjectType())) {
var data = std.ArrayList(u8).init(alloc); var stream: std.Io.Writer.Allocating = .init(alloc);
defer data.deinit(); defer stream.deinit();
var shell_escape_writer: internal_os.ShellEscapeWriter(std.ArrayList(u8).Writer) = .{ var shell_escape_writer: internal_os.ShellEscapeWriter = .init(&stream.writer);
.child_writer = data.writer(), const writer = &shell_escape_writer.writer;
};
const writer = shell_escape_writer.writer();
const list: ?*glib.SList = list: { const list: ?*glib.SList = list: {
const unboxed = value.getBoxed() orelse return 0; const unboxed = value.getBoxed() orelse return 0;
@@ -2151,7 +2147,7 @@ pub const Surface = extern struct {
} }
} }
const string = data.toOwnedSliceSentinel(0) catch |err| { const string = stream.toOwnedSliceSentinel(0) catch |err| {
log.err("unable to convert to a slice: {}", .{err}); log.err("unable to convert to a slice: {}", .{err});
return 0; return 0;
}; };
@@ -2164,13 +2160,11 @@ pub const Surface = extern struct {
const object = value.getObject() orelse return 0; const object = value.getObject() orelse return 0;
const file = gobject.ext.cast(gio.File, object) orelse return 0; const file = gobject.ext.cast(gio.File, object) orelse return 0;
const path = file.getPath() orelse return 0; const path = file.getPath() orelse return 0;
var data = std.ArrayList(u8).init(alloc); var stream: std.Io.Writer.Allocating = .init(alloc);
defer data.deinit(); defer stream.deinit();
var shell_escape_writer: internal_os.ShellEscapeWriter(std.ArrayList(u8).Writer) = .{ var shell_escape_writer: internal_os.ShellEscapeWriter = .init(&stream.writer);
.child_writer = data.writer(), const writer = &shell_escape_writer.writer;
};
const writer = shell_escape_writer.writer();
writer.writeAll(std.mem.span(path)) catch |err| { writer.writeAll(std.mem.span(path)) catch |err| {
log.err("unable to write path to buffer: {}", .{err}); log.err("unable to write path to buffer: {}", .{err});
return 0; return 0;
@@ -2180,7 +2174,7 @@ pub const Surface = extern struct {
return 0; return 0;
}; };
const string = data.toOwnedSliceSentinel(0) catch |err| { const string = stream.toOwnedSliceSentinel(0) catch |err| {
log.err("unable to convert to a slice: {}", .{err}); log.err("unable to convert to a slice: {}", .{err});
return 0; return 0;
}; };

View File

@@ -136,7 +136,7 @@ pub const SurfaceTitleDialog = extern struct {
fn finalize(self: *Self) callconv(.c) void { fn finalize(self: *Self) callconv(.c) void {
const priv = self.private(); const priv = self.private();
if (priv.initial_value) |v| { if (priv.initial_value) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.initial_value = null; priv.initial_value = null;
} }

View File

@@ -270,11 +270,11 @@ pub const Tab = extern struct {
fn finalize(self: *Self) callconv(.c) void { fn finalize(self: *Self) callconv(.c) void {
const priv = self.private(); const priv = self.private();
if (priv.tooltip) |v| { if (priv.tooltip) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.tooltip = null; priv.tooltip = null;
} }
if (priv.title) |v| { if (priv.title) |v| {
glib.free(@constCast(@ptrCast(v))); glib.free(@ptrCast(@constCast(v)));
priv.title = null; priv.title = null;
} }
@@ -405,22 +405,21 @@ pub const Tab = extern struct {
}; };
// Use an allocator to build up our string as we write it. // Use an allocator to build up our string as we write it.
var buf: std.ArrayList(u8) = .init(Application.default().allocator()); var buf: std.Io.Writer.Allocating = .init(Application.default().allocator());
defer buf.deinit(); defer buf.deinit();
const writer = buf.writer();
// If our bell is ringing, then we prefix the bell icon to the title. // If our bell is ringing, then we prefix the bell icon to the title.
if (bell_ringing and config.@"bell-features".title) { if (bell_ringing and config.@"bell-features".title) {
writer.writeAll("🔔 ") catch {}; buf.writer.writeAll("🔔 ") catch {};
} }
// If we're zoomed, prefix with the magnifying glass emoji. // If we're zoomed, prefix with the magnifying glass emoji.
if (zoomed) { if (zoomed) {
writer.writeAll("🔍 ") catch {}; buf.writer.writeAll("🔍 ") catch {};
} }
writer.writeAll(plain) catch return glib.ext.dupeZ(u8, plain); buf.writer.writeAll(plain) catch return glib.ext.dupeZ(u8, plain);
return glib.ext.dupeZ(u8, buf.items); return glib.ext.dupeZ(u8, buf.written());
} }
const C = Common(Self, Private); const C = Common(Self, Private);

View File

@@ -26,7 +26,7 @@ pub fn getRuntimeVersion() std.SemanticVersion {
} }
pub fn logVersion() void { pub fn logVersion() void {
log.info("GTK version build={} runtime={}", .{ log.info("GTK version build={f} runtime={f}", .{
comptime_version, comptime_version,
getRuntimeVersion(), getRuntimeVersion(),
}); });

View File

@@ -29,7 +29,10 @@ payload_builder: *glib.VariantBuilder,
parameters_builder: *glib.VariantBuilder, parameters_builder: *glib.VariantBuilder,
/// Initialize the helper. /// Initialize the helper.
pub fn init(alloc: Allocator, target: apprt.ipc.Target, action: [:0]const u8) (Allocator.Error || std.posix.WriteError || apprt.ipc.Errors)!Self { pub fn init(alloc: Allocator, target: apprt.ipc.Target, action: [:0]const u8) (Allocator.Error || std.Io.Writer.Error || apprt.ipc.Errors)!Self {
var buf: [256]u8 = undefined;
var stderr_writer = std.fs.File.stderr().writer(&buf);
const stderr = &stderr_writer.interface;
// Get the appropriate bus name and object path for contacting the // Get the appropriate bus name and object path for contacting the
// Ghostty instance we're interested in. // Ghostty instance we're interested in.
@@ -37,7 +40,7 @@ pub fn init(alloc: Allocator, target: apprt.ipc.Target, action: [:0]const u8) (A
.class => |class| result: { .class => |class| result: {
// Force the usage of the class specified on the CLI to determine the // Force the usage of the class specified on the CLI to determine the
// bus name and object path. // bus name and object path.
const object_path = try std.fmt.allocPrintZ(alloc, "/{s}", .{class}); const object_path = try std.fmt.allocPrintSentinel(alloc, "/{s}", .{class}, 0);
std.mem.replaceScalar(u8, object_path, '.', '/'); std.mem.replaceScalar(u8, object_path, '.', '/');
std.mem.replaceScalar(u8, object_path, '-', '_'); std.mem.replaceScalar(u8, object_path, '-', '_');
@@ -54,14 +57,14 @@ pub fn init(alloc: Allocator, target: apprt.ipc.Target, action: [:0]const u8) (A
} }
if (gio.Application.idIsValid(bus_name.ptr) == 0) { if (gio.Application.idIsValid(bus_name.ptr) == 0) {
const stderr = std.io.getStdErr().writer();
try stderr.print("D-Bus bus name is not valid: {s}\n", .{bus_name}); try stderr.print("D-Bus bus name is not valid: {s}\n", .{bus_name});
try stderr.flush();
return error.IPCFailed; return error.IPCFailed;
} }
if (glib.Variant.isObjectPath(object_path.ptr) == 0) { if (glib.Variant.isObjectPath(object_path.ptr) == 0) {
const stderr = std.io.getStdErr().writer();
try stderr.print("D-Bus object path is not valid: {s}\n", .{object_path}); try stderr.print("D-Bus object path is not valid: {s}\n", .{object_path});
try stderr.flush();
return error.IPCFailed; return error.IPCFailed;
} }
@@ -72,17 +75,17 @@ pub fn init(alloc: Allocator, target: apprt.ipc.Target, action: [:0]const u8) (A
const dbus_ = gio.busGetSync(.session, null, &err_); const dbus_ = gio.busGetSync(.session, null, &err_);
if (err_) |err| { if (err_) |err| {
const stderr = std.io.getStdErr().writer();
try stderr.print( try stderr.print(
"Unable to establish connection to D-Bus session bus: {s}\n", "Unable to establish connection to D-Bus session bus: {s}\n",
.{err.f_message orelse "(unknown)"}, .{err.f_message orelse "(unknown)"},
); );
try stderr.flush();
return error.IPCFailed; return error.IPCFailed;
} }
break :dbus dbus_ orelse { break :dbus dbus_ orelse {
const stderr = std.io.getStdErr().writer();
try stderr.print("gio.busGetSync returned null\n", .{}); try stderr.print("gio.busGetSync returned null\n", .{});
try stderr.flush();
return error.IPCFailed; return error.IPCFailed;
}; };
}; };
@@ -128,7 +131,11 @@ pub fn addParameter(self: *Self, variant: *glib.Variant) void {
/// Send the IPC to the remote Ghostty. Once it completes, nothing further /// Send the IPC to the remote Ghostty. Once it completes, nothing further
/// should be done with this object other than call `deinit`. /// should be done with this object other than call `deinit`.
pub fn send(self: *Self) (std.posix.WriteError || apprt.ipc.Errors)!void { pub fn send(self: *Self) (std.Io.Writer.Error || apprt.ipc.Errors)!void {
var buf: [256]u8 = undefined;
var stderr_writer = std.fs.File.stderr().writer(&buf);
const stderr = &stderr_writer.interface;
// finish building the parameters // finish building the parameters
const parameters = self.parameters_builder.end(); const parameters = self.parameters_builder.end();
@@ -167,11 +174,11 @@ pub fn send(self: *Self) (std.posix.WriteError || apprt.ipc.Errors)!void {
defer if (result_) |result| result.unref(); defer if (result_) |result| result.unref();
if (err_) |err| { if (err_) |err| {
const stderr = std.io.getStdErr().writer();
try stderr.print( try stderr.print(
"D-Bus method call returned an error err={s}\n", "D-Bus method call returned an error err={s}\n",
.{err.f_message orelse "(unknown)"}, .{err.f_message orelse "(unknown)"},
); );
try stderr.flush();
return error.IPCFailed; return error.IPCFailed;
} }
} }

View File

@@ -20,7 +20,7 @@ const DBus = @import("DBus.zig");
// ``` // ```
// gdbus call --session --dest com.mitchellh.ghostty --object-path /com/mitchellh/ghostty --method org.gtk.Actions.Activate new-window-command '[<@as ["echo" "hello"]>]' [] // gdbus call --session --dest com.mitchellh.ghostty --object-path /com/mitchellh/ghostty --method org.gtk.Actions.Activate new-window-command '[<@as ["echo" "hello"]>]' []
// ``` // ```
pub fn newWindow(alloc: Allocator, target: apprt.ipc.Target, value: apprt.ipc.Action.NewWindow) (Allocator.Error || std.posix.WriteError || apprt.ipc.Errors)!bool { pub fn newWindow(alloc: Allocator, target: apprt.ipc.Target, value: apprt.ipc.Action.NewWindow) (Allocator.Error || std.Io.Writer.Error || apprt.ipc.Errors)!bool {
var dbus = try DBus.init( var dbus = try DBus.init(
alloc, alloc,
target, target,

View File

@@ -12,9 +12,8 @@ const winproto = @import("winproto.zig");
pub fn accelFromTrigger( pub fn accelFromTrigger(
buf: []u8, buf: []u8,
trigger: input.Binding.Trigger, trigger: input.Binding.Trigger,
) error{NoSpaceLeft}!?[:0]const u8 { ) error{WriteFailed}!?[:0]const u8 {
var buf_stream = std.io.fixedBufferStream(buf); var writer: std.Io.Writer = .fixed(buf);
const writer = buf_stream.writer();
// Modifiers // Modifiers
if (trigger.mods.shift) try writer.writeAll("<Shift>"); if (trigger.mods.shift) try writer.writeAll("<Shift>");
@@ -23,11 +22,11 @@ pub fn accelFromTrigger(
if (trigger.mods.super) try writer.writeAll("<Super>"); if (trigger.mods.super) try writer.writeAll("<Super>");
// Write our key // Write our key
if (!try writeTriggerKey(writer, trigger)) return null; if (!try writeTriggerKey(&writer, trigger)) return null;
// We need to make the string null terminated. // We need to make the string null terminated.
try writer.writeByte(0); try writer.writeByte(0);
const slice = buf_stream.getWritten(); const slice = writer.buffered();
return slice[0 .. slice.len - 1 :0]; return slice[0 .. slice.len - 1 :0];
} }
@@ -36,9 +35,8 @@ pub fn accelFromTrigger(
pub fn xdgShortcutFromTrigger( pub fn xdgShortcutFromTrigger(
buf: []u8, buf: []u8,
trigger: input.Binding.Trigger, trigger: input.Binding.Trigger,
) error{NoSpaceLeft}!?[:0]const u8 { ) error{WriteFailed}!?[:0]const u8 {
var buf_stream = std.io.fixedBufferStream(buf); var writer: std.Io.Writer = .fixed(buf);
const writer = buf_stream.writer();
// Modifiers // Modifiers
if (trigger.mods.shift) try writer.writeAll("SHIFT+"); if (trigger.mods.shift) try writer.writeAll("SHIFT+");
@@ -52,15 +50,18 @@ pub fn xdgShortcutFromTrigger(
// to *X11's* keysyms (which I assume is a subset of libxkbcommon's). // to *X11's* keysyms (which I assume is a subset of libxkbcommon's).
// I haven't been able to any evidence to back up that assumption but // I haven't been able to any evidence to back up that assumption but
// this works for now // this works for now
if (!try writeTriggerKey(writer, trigger)) return null; if (!try writeTriggerKey(&writer, trigger)) return null;
// We need to make the string null terminated. // We need to make the string null terminated.
try writer.writeByte(0); try writer.writeByte(0);
const slice = buf_stream.getWritten(); const slice = writer.buffered();
return slice[0 .. slice.len - 1 :0]; return slice[0 .. slice.len - 1 :0];
} }
fn writeTriggerKey(writer: anytype, trigger: input.Binding.Trigger) error{NoSpaceLeft}!bool { fn writeTriggerKey(
writer: *std.Io.Writer,
trigger: input.Binding.Trigger,
) error{WriteFailed}!bool {
switch (trigger.key) { switch (trigger.key) {
.physical => |k| { .physical => |k| {
const keyval = keyvalFromKey(k) orelse return false; const keyval = keyvalFromKey(k) orelse return false;

View File

@@ -10,7 +10,6 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const Benchmark = @import("Benchmark.zig"); const Benchmark = @import("Benchmark.zig");
const options = @import("options.zig"); const options = @import("options.zig");
const uucode = @import("uucode");
const UTF8Decoder = @import("../terminal/UTF8Decoder.zig"); const UTF8Decoder = @import("../terminal/UTF8Decoder.zig");
const simd = @import("../simd/main.zig"); const simd = @import("../simd/main.zig");
const table = @import("../unicode/main.zig").table; const table = @import("../unicode/main.zig").table;
@@ -48,9 +47,6 @@ pub const Mode = enum {
/// Test our lookup table implementation. /// Test our lookup table implementation.
table, table,
/// Using uucode, with custom `width` extension based on `wcwidth`.
uucode,
}; };
/// Create a new terminal stream handler for the given arguments. /// Create a new terminal stream handler for the given arguments.
@@ -75,7 +71,6 @@ pub fn benchmark(self: *CodepointWidth) Benchmark {
.wcwidth => stepWcwidth, .wcwidth => stepWcwidth,
.table => stepTable, .table => stepTable,
.simd => stepSimd, .simd => stepSimd,
.uucode => stepUucode,
}, },
.setupFn = setup, .setupFn = setup,
.teardownFn = teardown, .teardownFn = teardown,
@@ -112,12 +107,15 @@ fn stepWcwidth(ptr: *anyopaque) Benchmark.Error!void {
const self: *CodepointWidth = @ptrCast(@alignCast(ptr)); const self: *CodepointWidth = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
var r = &f_reader.interface;
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached
@@ -136,12 +134,15 @@ fn stepTable(ptr: *anyopaque) Benchmark.Error!void {
const self: *CodepointWidth = @ptrCast(@alignCast(ptr)); const self: *CodepointWidth = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
var r = &f_reader.interface;
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached
@@ -165,12 +166,15 @@ fn stepSimd(ptr: *anyopaque) Benchmark.Error!void {
const self: *CodepointWidth = @ptrCast(@alignCast(ptr)); const self: *CodepointWidth = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
var r = &f_reader.interface;
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached
@@ -185,35 +189,6 @@ fn stepSimd(ptr: *anyopaque) Benchmark.Error!void {
} }
} }
fn stepUucode(ptr: *anyopaque) Benchmark.Error!void {
const self: *CodepointWidth = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader());
var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) {
const n = r.read(&buf) catch |err| {
log.warn("error reading data file err={}", .{err});
return error.BenchmarkFailed;
};
if (n == 0) break; // EOF reached
for (buf[0..n]) |c| {
const cp_, const consumed = d.next(c);
assert(consumed);
if (cp_) |cp| {
// This is the same trick we do in terminal.zig so we
// keep it here.
std.mem.doNotOptimizeAway(if (cp <= 0xFF)
1
else
uucode.get(.width, @intCast(cp)));
}
}
}
}
test CodepointWidth { test CodepointWidth {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;

View File

@@ -8,7 +8,6 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const Benchmark = @import("Benchmark.zig"); const Benchmark = @import("Benchmark.zig");
const options = @import("options.zig"); const options = @import("options.zig");
const uucode = @import("uucode");
const UTF8Decoder = @import("../terminal/UTF8Decoder.zig"); const UTF8Decoder = @import("../terminal/UTF8Decoder.zig");
const unicode = @import("../unicode/main.zig"); const unicode = @import("../unicode/main.zig");
@@ -39,9 +38,6 @@ pub const Mode = enum {
/// Ghostty's table-based approach. /// Ghostty's table-based approach.
table, table,
/// uucode implementation
uucode,
}; };
/// Create a new terminal stream handler for the given arguments. /// Create a new terminal stream handler for the given arguments.
@@ -64,7 +60,6 @@ pub fn benchmark(self: *GraphemeBreak) Benchmark {
.stepFn = switch (self.opts.mode) { .stepFn = switch (self.opts.mode) {
.noop => stepNoop, .noop => stepNoop,
.table => stepTable, .table => stepTable,
.uucode => stepUucode,
}, },
.setupFn = setup, .setupFn = setup,
.teardownFn = teardown, .teardownFn = teardown,
@@ -95,12 +90,15 @@ fn stepNoop(ptr: *anyopaque) Benchmark.Error!void {
const self: *GraphemeBreak = @ptrCast(@alignCast(ptr)); const self: *GraphemeBreak = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
var r = &f_reader.interface;
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached
@@ -115,14 +113,17 @@ fn stepTable(ptr: *anyopaque) Benchmark.Error!void {
const self: *GraphemeBreak = @ptrCast(@alignCast(ptr)); const self: *GraphemeBreak = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
var r = &f_reader.interface;
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var state: unicode.GraphemeBreakState = .{}; var state: unicode.GraphemeBreakState = .{};
var cp1: u21 = 0; var cp1: u21 = 0;
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached
@@ -138,33 +139,6 @@ fn stepTable(ptr: *anyopaque) Benchmark.Error!void {
} }
} }
fn stepUucode(ptr: *anyopaque) Benchmark.Error!void {
const self: *GraphemeBreak = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader());
var d: UTF8Decoder = .{};
var state: uucode.grapheme.BreakState = .default;
var cp1: u21 = 0;
var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) {
const n = r.read(&buf) catch |err| {
log.warn("error reading data file err={}", .{err});
return error.BenchmarkFailed;
};
if (n == 0) break; // EOF reached
for (buf[0..n]) |c| {
const cp_, const consumed = d.next(c);
assert(consumed);
if (cp_) |cp2| {
std.mem.doNotOptimizeAway(uucode.grapheme.isBreak(cp1, @intCast(cp2), &state));
cp1 = cp2;
}
}
}
}
test GraphemeBreak { test GraphemeBreak {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;

View File

@@ -90,7 +90,8 @@ fn stepUucode(ptr: *anyopaque) Benchmark.Error!void {
const self: *IsSymbol = @ptrCast(@alignCast(ptr)); const self: *IsSymbol = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var r = f.reader(&read_buf);
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {
@@ -114,7 +115,8 @@ fn stepTable(ptr: *anyopaque) Benchmark.Error!void {
const self: *IsSymbol = @ptrCast(@alignCast(ptr)); const self: *IsSymbol = @ptrCast(@alignCast(ptr));
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var r = f.reader(&read_buf);
var d: UTF8Decoder = .{}; var d: UTF8Decoder = .{};
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 align(std.atomic.cache_line) = undefined;
while (true) { while (true) {

View File

@@ -75,14 +75,16 @@ fn step(ptr: *anyopaque) Benchmark.Error!void {
// the benchmark results and... I know writing this that we // the benchmark results and... I know writing this that we
// aren't currently IO bound. // aren't currently IO bound.
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader()); var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
var r = &f_reader.interface;
var p: terminalpkg.Parser = .init(); var p: terminalpkg.Parser = .init();
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var buf: [4096]u8 = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached

View File

@@ -113,17 +113,19 @@ fn step(ptr: *anyopaque) Benchmark.Error!void {
// the benchmark results and... I know writing this that we // the benchmark results and... I know writing this that we
// aren't currently IO bound. // aren't currently IO bound.
const f = self.data_f orelse return; const f = self.data_f orelse return;
var r = std.io.bufferedReader(f.reader());
var buf: [4096]u8 align(std.atomic.cache_line) = undefined; var read_buf: [4096]u8 = undefined;
var f_reader = f.reader(&read_buf);
const r = &f_reader.interface;
var buf: [4096]u8 = undefined;
while (true) { while (true) {
const n = r.read(&buf) catch |err| { const n = r.readSliceShort(&buf) catch {
log.warn("error reading data file err={}", .{err}); log.warn("error reading data file err={?}", .{f_reader.err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };
if (n == 0) break; // EOF reached if (n == 0) break; // EOF reached
const chunk = buf[0..n]; self.stream.nextSlice(buf[0..n]) catch |err| {
self.stream.nextSlice(chunk) catch |err| {
log.warn("error processing data file chunk err={}", .{err}); log.warn("error processing data file chunk err={}", .{err});
return error.BenchmarkFailed; return error.BenchmarkFailed;
}; };

View File

@@ -10,7 +10,7 @@ pub fn dataFile(path_: ?[]const u8) !?std.fs.File {
const path = path_ orelse return null; const path = path_ orelse return null;
// Stdin // Stdin
if (std.mem.eql(u8, path, "-")) return std.io.getStdIn(); if (std.mem.eql(u8, path, "-")) return .stdin();
// Normal file // Normal file
const file = try std.fs.cwd().openFile(path, .{}); const file = try std.fs.cwd().openFile(path, .{});

View File

@@ -477,7 +477,7 @@ pub fn addOptions(self: *const Config, step: *std.Build.Step.Options) !void {
step.addOption(std.SemanticVersion, "app_version", self.version); step.addOption(std.SemanticVersion, "app_version", self.version);
step.addOption([:0]const u8, "app_version_string", try std.fmt.bufPrintZ( step.addOption([:0]const u8, "app_version_string", try std.fmt.bufPrintZ(
&buf, &buf,
"{}", "{f}",
.{self.version}, .{self.version},
)); ));
step.addOption( step.addOption(

View File

@@ -11,8 +11,8 @@ pub fn init(
b: *std.Build, b: *std.Build,
deps: *const SharedDeps, deps: *const SharedDeps,
) !GhosttyBench { ) !GhosttyBench {
var steps = std.ArrayList(*std.Build.Step.Compile).init(b.allocator); var steps: std.ArrayList(*std.Build.Step.Compile) = .empty;
errdefer steps.deinit(); errdefer steps.deinit(b.allocator);
// Our synthetic data generator // Our synthetic data generator
{ {
@@ -28,7 +28,7 @@ pub fn init(
}); });
exe.linkLibC(); exe.linkLibC();
_ = try deps.add(exe); _ = try deps.add(exe);
try steps.append(exe); try steps.append(b.allocator, exe);
} }
// Our benchmarking application. // Our benchmarking application.
@@ -44,7 +44,7 @@ pub fn init(
}); });
exe.linkLibC(); exe.linkLibC();
_ = try deps.add(exe); _ = try deps.add(exe);
try steps.append(exe); try steps.append(b.allocator, exe);
} }
return .{ .steps = steps.items }; return .{ .steps = steps.items };

View File

@@ -43,10 +43,10 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyDist {
// embed the Ghostty version in the tarball // embed the Ghostty version in the tarball
{ {
const version = b.addWriteFiles().add("VERSION", b.fmt("{}", .{cfg.version})); const version = b.addWriteFiles().add("VERSION", b.fmt("{f}", .{cfg.version}));
// --add-file uses the most recent --prefix to determine the path // --add-file uses the most recent --prefix to determine the path
// in the archive to copy the file (the directory only). // in the archive to copy the file (the directory only).
git_archive.addArg(b.fmt("--prefix=ghostty-{}/", .{ git_archive.addArg(b.fmt("--prefix=ghostty-{f}/", .{
cfg.version, cfg.version,
})); }));
git_archive.addPrefixedFileArg("--add-file=", version); git_archive.addPrefixedFileArg("--add-file=", version);
@@ -65,7 +65,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyDist {
// --add-file uses the most recent --prefix to determine the path // --add-file uses the most recent --prefix to determine the path
// in the archive to copy the file (the directory only). // in the archive to copy the file (the directory only).
git_archive.addArg(b.fmt("--prefix=ghostty-{}/{s}/", .{ git_archive.addArg(b.fmt("--prefix=ghostty-{f}/{s}/", .{
cfg.version, cfg.version,
std.fs.path.dirname(resource.dist).?, std.fs.path.dirname(resource.dist).?,
})); }));
@@ -77,11 +77,11 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyDist {
// This is important. Standard source tarballs extract into // This is important. Standard source tarballs extract into
// a directory named `project-version`. This is expected by // a directory named `project-version`. This is expected by
// standard tooling such as debhelper and rpmbuild. // standard tooling such as debhelper and rpmbuild.
b.fmt("--prefix=ghostty-{}/", .{cfg.version}), b.fmt("--prefix=ghostty-{f}/", .{cfg.version}),
"-o", "-o",
}); });
const output = git_archive.addOutputFileArg(b.fmt( const output = git_archive.addOutputFileArg(b.fmt(
"ghostty-{}.tar.gz", "ghostty-{f}.tar.gz",
.{cfg.version}, .{cfg.version},
)); ));
git_archive.addArg("HEAD"); git_archive.addArg("HEAD");
@@ -89,7 +89,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyDist {
// The install step to put the dist into the build directory. // The install step to put the dist into the build directory.
const install = b.addInstallFile( const install = b.addInstallFile(
output, output,
b.fmt("dist/ghostty-{}.tar.gz", .{cfg.version}), b.fmt("dist/ghostty-{f}.tar.gz", .{cfg.version}),
); );
// The check step to ensure the archive works. // The check step to ensure the archive works.
@@ -101,7 +101,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyDist {
// i.e. this is way `build.zig` is. // i.e. this is way `build.zig` is.
const extract_dir = check const extract_dir = check
.addOutputDirectoryArg("ghostty") .addOutputDirectoryArg("ghostty")
.path(b, b.fmt("ghostty-{}", .{cfg.version})); .path(b, b.fmt("ghostty-{f}", .{cfg.version}));
// Check that tests pass within the extracted directory. This isn't // Check that tests pass within the extracted directory. This isn't
// a fully hermetic test because we're sharing the Zig cache. In // a fully hermetic test because we're sharing the Zig cache. In

View File

@@ -12,8 +12,8 @@ pub fn init(
b: *std.Build, b: *std.Build,
deps: *const SharedDeps, deps: *const SharedDeps,
) !GhosttyDocs { ) !GhosttyDocs {
var steps = std.ArrayList(*std.Build.Step).init(b.allocator); var steps: std.ArrayList(*std.Build.Step) = .empty;
errdefer steps.deinit(); errdefer steps.deinit(b.allocator);
const manpages = [_]struct { const manpages = [_]struct {
name: []const u8, name: []const u8,
@@ -52,7 +52,7 @@ pub fn init(
const generate_markdown_step = b.addRunArtifact(generate_markdown); const generate_markdown_step = b.addRunArtifact(generate_markdown);
const markdown_output = generate_markdown_step.captureStdOut(); const markdown_output = generate_markdown_step.captureStdOut();
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
markdown_output, markdown_output,
"share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".md", "share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".md",
).step); ).step);
@@ -67,7 +67,7 @@ pub fn init(
}); });
generate_html.addFileArg(markdown_output); generate_html.addFileArg(markdown_output);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
generate_html.captureStdOut(), generate_html.captureStdOut(),
"share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".html", "share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".html",
).step); ).step);
@@ -82,7 +82,7 @@ pub fn init(
}); });
generate_manpage.addFileArg(markdown_output); generate_manpage.addFileArg(markdown_output);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
generate_manpage.captureStdOut(), generate_manpage.captureStdOut(),
"share/man/man" ++ manpage.section ++ "/" ++ manpage.name ++ "." ++ manpage.section, "share/man/man" ++ manpage.section ++ "/" ++ manpage.name ++ "." ++ manpage.section,
).step); ).step);

View File

@@ -21,6 +21,8 @@ pub fn init(b: *std.Build, cfg: *const Config, deps: *const SharedDeps) !Ghostty
.omit_frame_pointer = cfg.strip, .omit_frame_pointer = cfg.strip,
.unwind_tables = if (cfg.strip) .none else .sync, .unwind_tables = if (cfg.strip) .none else .sync,
}), }),
// Crashes on x86_64 self-hosted on 0.15.1
.use_llvm = true,
}); });
const install_step = b.addInstallArtifact(exe, .{}); const install_step = b.addInstallArtifact(exe, .{});

View File

@@ -40,7 +40,10 @@ pub fn distResources(b: *std.Build) struct {
} { } {
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "framegen", .name = "framegen",
.target = b.graph.host, .root_module = b.createModule(.{
.target = b.graph.host,
}),
.use_llvm = true,
}); });
exe.addCSourceFile(.{ exe.addCSourceFile(.{
.file = b.path("src/build/framegen/main.c"), .file = b.path("src/build/framegen/main.c"),

View File

@@ -18,8 +18,8 @@ update_step: *std.Build.Step,
pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n { pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
_ = cfg; _ = cfg;
var steps = std.ArrayList(*std.Build.Step).init(b.allocator); var steps: std.ArrayList(*std.Build.Step) = .empty;
defer steps.deinit(); defer steps.deinit(b.allocator);
inline for (locales) |locale| { inline for (locales) |locale| {
// There is no encoding suffix in the LC_MESSAGES path on FreeBSD, // There is no encoding suffix in the LC_MESSAGES path on FreeBSD,
@@ -33,7 +33,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
const msgfmt = b.addSystemCommand(&.{ "msgfmt", "-o", "-" }); const msgfmt = b.addSystemCommand(&.{ "msgfmt", "-o", "-" });
msgfmt.addFileArg(b.path("po/" ++ locale ++ ".po")); msgfmt.addFileArg(b.path("po/" ++ locale ++ ".po"));
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
msgfmt.captureStdOut(), msgfmt.captureStdOut(),
std.fmt.comptimePrint( std.fmt.comptimePrint(
"share/locale/{s}/LC_MESSAGES/{s}.mo", "share/locale/{s}/LC_MESSAGES/{s}.mo",
@@ -45,7 +45,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
return .{ return .{
.owner = b, .owner = b,
.update_step = try createUpdateStep(b), .update_step = try createUpdateStep(b),
.steps = try steps.toOwnedSlice(), .steps = try steps.toOwnedSlice(b.allocator),
}; };
} }

View File

@@ -28,7 +28,9 @@ pub fn initStatic(
.omit_frame_pointer = deps.config.strip, .omit_frame_pointer = deps.config.strip,
.unwind_tables = if (deps.config.strip) .none else .sync, .unwind_tables = if (deps.config.strip) .none else .sync,
}), }),
.linkage = .static,
// Fails on self-hosted x86_64 on macOS
.use_llvm = true,
}); });
lib.linkLibC(); lib.linkLibC();
@@ -40,7 +42,7 @@ pub fn initStatic(
// Add our dependencies. Get the list of all static deps so we can // Add our dependencies. Get the list of all static deps so we can
// build a combined archive if necessary. // build a combined archive if necessary.
var lib_list = try deps.add(lib); var lib_list = try deps.add(lib);
try lib_list.append(lib.getEmittedBin()); try lib_list.append(b.allocator, lib.getEmittedBin());
if (!deps.config.target.result.os.tag.isDarwin()) return .{ if (!deps.config.target.result.os.tag.isDarwin()) return .{
.step = &lib.step, .step = &lib.step,
@@ -69,8 +71,9 @@ pub fn initShared(
b: *std.Build, b: *std.Build,
deps: *const SharedDeps, deps: *const SharedDeps,
) !GhosttyLib { ) !GhosttyLib {
const lib = b.addSharedLibrary(.{ const lib = b.addLibrary(.{
.name = "ghostty", .name = "ghostty",
.linkage = .dynamic,
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path("src/main_c.zig"), .root_source_file = b.path("src/main_c.zig"),
.target = deps.config.target, .target = deps.config.target,
@@ -79,6 +82,9 @@ pub fn initShared(
.omit_frame_pointer = deps.config.strip, .omit_frame_pointer = deps.config.strip,
.unwind_tables = if (deps.config.strip) .none else .sync, .unwind_tables = if (deps.config.strip) .none else .sync,
}), }),
// Fails on self-hosted x86_64
.use_llvm = true,
}); });
_ = try deps.add(lib); _ = try deps.add(lib);

View File

@@ -24,8 +24,9 @@ pub fn initShared(
zig: *const GhosttyZig, zig: *const GhosttyZig,
) !GhosttyLibVt { ) !GhosttyLibVt {
const target = zig.vt.resolved_target.?; const target = zig.vt.resolved_target.?;
const lib = b.addSharedLibrary(.{ const lib = b.addLibrary(.{
.name = "ghostty-vt", .name = "ghostty-vt",
.linkage = .dynamic,
.root_module = zig.vt_c, .root_module = zig.vt_c,
.version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 0 }, .version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 0 },
}); });

View File

@@ -10,8 +10,8 @@ const RunStep = std.Build.Step.Run;
steps: []*std.Build.Step, steps: []*std.Build.Step,
pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources { pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
var steps = std.ArrayList(*std.Build.Step).init(b.allocator); var steps: std.ArrayList(*std.Build.Step) = .empty;
errdefer steps.deinit(); errdefer steps.deinit(b.allocator);
// This is the exe used to generate some build data. // This is the exe used to generate some build data.
const build_data_exe = b.addExecutable(.{ const build_data_exe = b.addExecutable(.{
@@ -49,7 +49,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
"share/terminfo/ghostty.terminfo", "share/terminfo/ghostty.terminfo",
); );
try steps.append(&source_install.step); try steps.append(b.allocator, &source_install.step);
} }
// Windows doesn't have the binaries below. // Windows doesn't have the binaries below.
@@ -73,7 +73,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
"share/terminfo/ghostty.termcap", "share/terminfo/ghostty.termcap",
); );
try steps.append(&cap_install.step); try steps.append(b.allocator, &cap_install.step);
} }
// Compile the terminfo source into a terminfo database // Compile the terminfo source into a terminfo database
@@ -99,7 +99,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.{ b.install_path, terminfo_share_dir }, .{ b.install_path, terminfo_share_dir },
)); ));
try steps.append(&mkdir_step.step); try steps.append(b.allocator, &mkdir_step.step);
// Use cp -R instead of Step.InstallDir because we need to preserve // Use cp -R instead of Step.InstallDir because we need to preserve
// symlinks in the terminfo database. Zig's InstallDir step doesn't // symlinks in the terminfo database. Zig's InstallDir step doesn't
@@ -109,7 +109,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
copy_step.addFileArg(path); copy_step.addFileArg(path);
copy_step.addArg(b.fmt("{s}/share", .{b.install_path})); copy_step.addArg(b.fmt("{s}/share", .{b.install_path}));
copy_step.step.dependOn(&mkdir_step.step); copy_step.step.dependOn(&mkdir_step.step);
try steps.append(&copy_step.step); try steps.append(b.allocator, &copy_step.step);
} }
} }
@@ -121,7 +121,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_subdir = b.pathJoin(&.{ "ghostty", "shell-integration" }), .install_subdir = b.pathJoin(&.{ "ghostty", "shell-integration" }),
.exclude_extensions = &.{".md"}, .exclude_extensions = &.{".md"},
}); });
try steps.append(&install_step.step); try steps.append(b.allocator, &install_step.step);
} }
// Themes // Themes
@@ -132,7 +132,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_subdir = b.pathJoin(&.{ "ghostty", "themes" }), .install_subdir = b.pathJoin(&.{ "ghostty", "themes" }),
.exclude_extensions = &.{".md"}, .exclude_extensions = &.{".md"},
}); });
try steps.append(&install_step.step); try steps.append(b.allocator, &install_step.step);
} }
// Fish shell completions // Fish shell completions
@@ -147,7 +147,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_dir = .prefix, .install_dir = .prefix,
.install_subdir = "share/fish/vendor_completions.d", .install_subdir = "share/fish/vendor_completions.d",
}); });
try steps.append(&install_step.step); try steps.append(b.allocator, &install_step.step);
} }
// zsh shell completions // zsh shell completions
@@ -162,7 +162,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_dir = .prefix, .install_dir = .prefix,
.install_subdir = "share/zsh/site-functions", .install_subdir = "share/zsh/site-functions",
}); });
try steps.append(&install_step.step); try steps.append(b.allocator, &install_step.step);
} }
// bash shell completions // bash shell completions
@@ -177,7 +177,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_dir = .prefix, .install_dir = .prefix,
.install_subdir = "share/bash-completion/completions", .install_subdir = "share/bash-completion/completions",
}); });
try steps.append(&install_step.step); try steps.append(b.allocator, &install_step.step);
} }
// Vim and Neovim plugin // Vim and Neovim plugin
@@ -210,14 +210,14 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_dir = .prefix, .install_dir = .prefix,
.install_subdir = "share/vim/vimfiles", .install_subdir = "share/vim/vimfiles",
}); });
try steps.append(&vim_step.step); try steps.append(b.allocator, &vim_step.step);
const neovim_step = b.addInstallDirectory(.{ const neovim_step = b.addInstallDirectory(.{
.source_dir = wf.getDirectory(), .source_dir = wf.getDirectory(),
.install_dir = .prefix, .install_dir = .prefix,
.install_subdir = "share/nvim/site", .install_subdir = "share/nvim/site",
}); });
try steps.append(&neovim_step.step); try steps.append(b.allocator, &neovim_step.step);
} }
// Sublime syntax highlighting for bat cli tool // Sublime syntax highlighting for bat cli tool
@@ -237,7 +237,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
.install_dir = .prefix, .install_dir = .prefix,
.install_subdir = "share/bat/syntaxes", .install_subdir = "share/bat/syntaxes",
}); });
try steps.append(&install_step.step); try steps.append(b.allocator, &install_step.step);
} }
// App (Linux) // App (Linux)
@@ -286,16 +286,17 @@ fn addLinuxAppResources(
// second element of the tuple. // second element of the tuple.
const Template = struct { std.Build.LazyPath, []const u8 }; const Template = struct { std.Build.LazyPath, []const u8 };
const templates: []const Template = templates: { const templates: []const Template = templates: {
var ts: std.ArrayList(Template) = .init(b.allocator); var ts: std.ArrayList(Template) = .empty;
defer ts.deinit(b.allocator);
// Desktop file so that we have an icon and other metadata // Desktop file so that we have an icon and other metadata
try ts.append(.{ try ts.append(b.allocator, .{
b.path("dist/linux/app.desktop.in"), b.path("dist/linux/app.desktop.in"),
b.fmt("share/applications/{s}.desktop", .{app_id}), b.fmt("share/applications/{s}.desktop", .{app_id}),
}); });
// Service for DBus activation. // Service for DBus activation.
try ts.append(.{ try ts.append(b.allocator, .{
if (cfg.flatpak) if (cfg.flatpak)
b.path("dist/linux/dbus.service.flatpak.in") b.path("dist/linux/dbus.service.flatpak.in")
else else
@@ -320,7 +321,7 @@ fn addLinuxAppResources(
// See the following code: // See the following code:
// //
// https://github.com/flatpak/xdg-desktop-portal/blob/7d4d48cf079147c8887da17ec6c3954acd5a285c/src/xdp-utils.c#L152-L220 // https://github.com/flatpak/xdg-desktop-portal/blob/7d4d48cf079147c8887da17ec6c3954acd5a285c/src/xdp-utils.c#L152-L220
if (!cfg.flatpak) try ts.append(.{ if (!cfg.flatpak) try ts.append(b.allocator, .{
b.path("dist/linux/systemd.service.in"), b.path("dist/linux/systemd.service.in"),
b.fmt( b.fmt(
"{s}/systemd/user/app-{s}.service", "{s}/systemd/user/app-{s}.service",
@@ -333,12 +334,12 @@ fn addLinuxAppResources(
// AppStream metainfo so that application has rich metadata // AppStream metainfo so that application has rich metadata
// within app stores // within app stores
try ts.append(.{ try ts.append(b.allocator, .{
b.path("dist/linux/com.mitchellh.ghostty.metainfo.xml.in"), b.path("dist/linux/com.mitchellh.ghostty.metainfo.xml.in"),
b.fmt("share/metainfo/{s}.metainfo.xml", .{app_id}), b.fmt("share/metainfo/{s}.metainfo.xml", .{app_id}),
}); });
break :templates ts.items; break :templates try ts.toOwnedSlice(b.allocator);
}; };
// Process all our templates // Process all our templates
@@ -361,65 +362,65 @@ fn addLinuxAppResources(
template[1], template[1],
); );
try steps.append(&copy.step); try steps.append(b.allocator, &copy.step);
} }
// Right click menu action for Plasma desktop // Right click menu action for Plasma desktop
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("dist/linux/ghostty_dolphin.desktop"), b.path("dist/linux/ghostty_dolphin.desktop"),
"share/kio/servicemenus/com.mitchellh.ghostty.desktop", "share/kio/servicemenus/com.mitchellh.ghostty.desktop",
).step); ).step);
// Right click menu action for Nautilus. Note that this _must_ be named // Right click menu action for Nautilus. Note that this _must_ be named
// `ghostty.py`. Using the full app id causes problems (see #5468). // `ghostty.py`. Using the full app id causes problems (see #5468).
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("dist/linux/ghostty_nautilus.py"), b.path("dist/linux/ghostty_nautilus.py"),
"share/nautilus-python/extensions/ghostty.py", "share/nautilus-python/extensions/ghostty.py",
).step); ).step);
// Various icons that our application can use, including the icon // Various icons that our application can use, including the icon
// that will be used for the desktop. // that will be used for the desktop.
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/16.png"), b.path("images/gnome/16.png"),
"share/icons/hicolor/16x16/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/16x16/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/32.png"), b.path("images/gnome/32.png"),
"share/icons/hicolor/32x32/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/32x32/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/128.png"), b.path("images/gnome/128.png"),
"share/icons/hicolor/128x128/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/128x128/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/256.png"), b.path("images/gnome/256.png"),
"share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/512.png"), b.path("images/gnome/512.png"),
"share/icons/hicolor/512x512/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/512x512/apps/com.mitchellh.ghostty.png",
).step); ).step);
// Flatpaks only support icons up to 512x512. // Flatpaks only support icons up to 512x512.
if (!cfg.flatpak) { if (!cfg.flatpak) {
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/1024.png"), b.path("images/gnome/1024.png"),
"share/icons/hicolor/1024x1024/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/1024x1024/apps/com.mitchellh.ghostty.png",
).step); ).step);
} }
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/32.png"), b.path("images/gnome/32.png"),
"share/icons/hicolor/16x16@2/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/16x16@2/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/64.png"), b.path("images/gnome/64.png"),
"share/icons/hicolor/32x32@2/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/32x32@2/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/256.png"), b.path("images/gnome/256.png"),
"share/icons/hicolor/128x128@2/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/128x128@2/apps/com.mitchellh.ghostty.png",
).step); ).step);
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
b.path("images/gnome/512.png"), b.path("images/gnome/512.png"),
"share/icons/hicolor/256x256@2/apps/com.mitchellh.ghostty.png", "share/icons/hicolor/256x256@2/apps/com.mitchellh.ghostty.png",
).step); ).step);

View File

@@ -12,8 +12,8 @@ pub fn init(
b: *std.Build, b: *std.Build,
deps: *const SharedDeps, deps: *const SharedDeps,
) !GhosttyWebdata { ) !GhosttyWebdata {
var steps = std.ArrayList(*std.Build.Step).init(b.allocator); var steps: std.ArrayList(*std.Build.Step) = .empty;
errdefer steps.deinit(); errdefer steps.deinit(b.allocator);
{ {
const webgen_config = b.addExecutable(.{ const webgen_config = b.addExecutable(.{
@@ -43,7 +43,7 @@ pub fn init(
const webgen_config_step = b.addRunArtifact(webgen_config); const webgen_config_step = b.addRunArtifact(webgen_config);
const webgen_config_out = webgen_config_step.captureStdOut(); const webgen_config_out = webgen_config_step.captureStdOut();
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
webgen_config_out, webgen_config_out,
"share/ghostty/webdata/config.mdx", "share/ghostty/webdata/config.mdx",
).step); ).step);
@@ -52,8 +52,10 @@ pub fn init(
{ {
const webgen_actions = b.addExecutable(.{ const webgen_actions = b.addExecutable(.{
.name = "webgen_actions", .name = "webgen_actions",
.root_source_file = b.path("src/main.zig"), .root_module = b.createModule(.{
.target = b.graph.host, .root_source_file = b.path("src/main.zig"),
.target = b.graph.host,
}),
}); });
deps.help_strings.addImport(webgen_actions); deps.help_strings.addImport(webgen_actions);
@@ -72,7 +74,7 @@ pub fn init(
const webgen_actions_step = b.addRunArtifact(webgen_actions); const webgen_actions_step = b.addRunArtifact(webgen_actions);
const webgen_actions_out = webgen_actions_step.captureStdOut(); const webgen_actions_out = webgen_actions_step.captureStdOut();
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
webgen_actions_out, webgen_actions_out,
"share/ghostty/webdata/actions.mdx", "share/ghostty/webdata/actions.mdx",
).step); ).step);
@@ -81,8 +83,10 @@ pub fn init(
{ {
const webgen_commands = b.addExecutable(.{ const webgen_commands = b.addExecutable(.{
.name = "webgen_commands", .name = "webgen_commands",
.root_source_file = b.path("src/main.zig"), .root_module = b.createModule(.{
.target = b.graph.host, .root_source_file = b.path("src/main.zig"),
.target = b.graph.host,
}),
}); });
deps.help_strings.addImport(webgen_commands); deps.help_strings.addImport(webgen_commands);
@@ -101,7 +105,7 @@ pub fn init(
const webgen_commands_step = b.addRunArtifact(webgen_commands); const webgen_commands_step = b.addRunArtifact(webgen_commands);
const webgen_commands_out = webgen_commands_step.captureStdOut(); const webgen_commands_out = webgen_commands_step.captureStdOut();
try steps.append(&b.addInstallFile( try steps.append(b.allocator, &b.addInstallFile(
webgen_commands_out, webgen_commands_out,
"share/ghostty/webdata/commands.mdx", "share/ghostty/webdata/commands.mdx",
).step); ).step);

View File

@@ -44,7 +44,7 @@ pub fn create(b: *std.Build, opts: Options) ?*MetallibStep {
const self = b.allocator.create(MetallibStep) catch @panic("OOM"); const self = b.allocator.create(MetallibStep) catch @panic("OOM");
const min_version = if (opts.target.query.os_version_min) |v| const min_version = if (opts.target.query.os_version_min) |v|
b.fmt("{}", .{v.semver}) b.fmt("{f}", .{v.semver})
else switch (opts.target.result.os.tag) { else switch (opts.target.result.os.tag) {
.macos => "10.14", .macos => "10.14",
.ios => "11.0", .ios => "11.0",

View File

@@ -113,8 +113,8 @@ pub fn add(
// We maintain a list of our static libraries and return it so that // We maintain a list of our static libraries and return it so that
// we can build a single fat static library for the final app. // we can build a single fat static library for the final app.
var static_libs = LazyPathList.init(b.allocator); var static_libs: LazyPathList = .empty;
errdefer static_libs.deinit(); errdefer static_libs.deinit(b.allocator);
// WARNING: This is a hack! // WARNING: This is a hack!
// If we're cross-compiling to Darwin then we don't add any deps. // If we're cross-compiling to Darwin then we don't add any deps.
@@ -154,6 +154,7 @@ pub fn add(
} else { } else {
step.linkLibrary(freetype_dep.artifact("freetype")); step.linkLibrary(freetype_dep.artifact("freetype"));
try static_libs.append( try static_libs.append(
b.allocator,
freetype_dep.artifact("freetype").getEmittedBin(), freetype_dep.artifact("freetype").getEmittedBin(),
); );
} }
@@ -178,6 +179,7 @@ pub fn add(
} else { } else {
step.linkLibrary(harfbuzz_dep.artifact("harfbuzz")); step.linkLibrary(harfbuzz_dep.artifact("harfbuzz"));
try static_libs.append( try static_libs.append(
b.allocator,
harfbuzz_dep.artifact("harfbuzz").getEmittedBin(), harfbuzz_dep.artifact("harfbuzz").getEmittedBin(),
); );
} }
@@ -201,6 +203,7 @@ pub fn add(
} else { } else {
step.linkLibrary(fontconfig_dep.artifact("fontconfig")); step.linkLibrary(fontconfig_dep.artifact("fontconfig"));
try static_libs.append( try static_libs.append(
b.allocator,
fontconfig_dep.artifact("fontconfig").getEmittedBin(), fontconfig_dep.artifact("fontconfig").getEmittedBin(),
); );
} }
@@ -218,6 +221,7 @@ pub fn add(
})) |libpng_dep| { })) |libpng_dep| {
step.linkLibrary(libpng_dep.artifact("png")); step.linkLibrary(libpng_dep.artifact("png"));
try static_libs.append( try static_libs.append(
b.allocator,
libpng_dep.artifact("png").getEmittedBin(), libpng_dep.artifact("png").getEmittedBin(),
); );
} }
@@ -231,6 +235,7 @@ pub fn add(
})) |zlib_dep| { })) |zlib_dep| {
step.linkLibrary(zlib_dep.artifact("z")); step.linkLibrary(zlib_dep.artifact("z"));
try static_libs.append( try static_libs.append(
b.allocator,
zlib_dep.artifact("z").getEmittedBin(), zlib_dep.artifact("z").getEmittedBin(),
); );
} }
@@ -250,6 +255,7 @@ pub fn add(
} else { } else {
step.linkLibrary(oniguruma_dep.artifact("oniguruma")); step.linkLibrary(oniguruma_dep.artifact("oniguruma"));
try static_libs.append( try static_libs.append(
b.allocator,
oniguruma_dep.artifact("oniguruma").getEmittedBin(), oniguruma_dep.artifact("oniguruma").getEmittedBin(),
); );
} }
@@ -270,6 +276,7 @@ pub fn add(
} else { } else {
step.linkLibrary(glslang_dep.artifact("glslang")); step.linkLibrary(glslang_dep.artifact("glslang"));
try static_libs.append( try static_libs.append(
b.allocator,
glslang_dep.artifact("glslang").getEmittedBin(), glslang_dep.artifact("glslang").getEmittedBin(),
); );
} }
@@ -289,6 +296,7 @@ pub fn add(
} else { } else {
step.linkLibrary(spirv_cross_dep.artifact("spirv_cross")); step.linkLibrary(spirv_cross_dep.artifact("spirv_cross"));
try static_libs.append( try static_libs.append(
b.allocator,
spirv_cross_dep.artifact("spirv_cross").getEmittedBin(), spirv_cross_dep.artifact("spirv_cross").getEmittedBin(),
); );
} }
@@ -307,6 +315,7 @@ pub fn add(
); );
step.linkLibrary(sentry_dep.artifact("sentry")); step.linkLibrary(sentry_dep.artifact("sentry"));
try static_libs.append( try static_libs.append(
b.allocator,
sentry_dep.artifact("sentry").getEmittedBin(), sentry_dep.artifact("sentry").getEmittedBin(),
); );
@@ -316,6 +325,7 @@ pub fn add(
.optimize = optimize, .optimize = optimize,
})) |breakpad_dep| { })) |breakpad_dep| {
try static_libs.append( try static_libs.append(
b.allocator,
breakpad_dep.artifact("breakpad").getEmittedBin(), breakpad_dep.artifact("breakpad").getEmittedBin(),
); );
} }
@@ -443,6 +453,7 @@ pub fn add(
macos_dep.artifact("macos"), macos_dep.artifact("macos"),
); );
try static_libs.append( try static_libs.append(
b.allocator,
macos_dep.artifact("macos").getEmittedBin(), macos_dep.artifact("macos").getEmittedBin(),
); );
} }
@@ -461,6 +472,7 @@ pub fn add(
})) |libintl_dep| { })) |libintl_dep| {
step.linkLibrary(libintl_dep.artifact("intl")); step.linkLibrary(libintl_dep.artifact("intl"));
try static_libs.append( try static_libs.append(
b.allocator,
libintl_dep.artifact("intl").getEmittedBin(), libintl_dep.artifact("intl").getEmittedBin(),
); );
} }
@@ -473,7 +485,10 @@ pub fn add(
})) |cimgui_dep| { })) |cimgui_dep| {
step.root_module.addImport("cimgui", cimgui_dep.module("cimgui")); step.root_module.addImport("cimgui", cimgui_dep.module("cimgui"));
step.linkLibrary(cimgui_dep.artifact("cimgui")); step.linkLibrary(cimgui_dep.artifact("cimgui"));
try static_libs.append(cimgui_dep.artifact("cimgui").getEmittedBin()); try static_libs.append(
b.allocator,
cimgui_dep.artifact("cimgui").getEmittedBin(),
);
} }
// Fonts // Fonts
@@ -697,6 +712,7 @@ pub fn addSimd(
})) |simdutf_dep| { })) |simdutf_dep| {
m.linkLibrary(simdutf_dep.artifact("simdutf")); m.linkLibrary(simdutf_dep.artifact("simdutf"));
if (static_libs) |v| try v.append( if (static_libs) |v| try v.append(
b.allocator,
simdutf_dep.artifact("simdutf").getEmittedBin(), simdutf_dep.artifact("simdutf").getEmittedBin(),
); );
} }
@@ -708,7 +724,10 @@ pub fn addSimd(
.optimize = optimize, .optimize = optimize,
})) |highway_dep| { })) |highway_dep| {
m.linkLibrary(highway_dep.artifact("highway")); m.linkLibrary(highway_dep.artifact("highway"));
if (static_libs) |v| try v.append(highway_dep.artifact("highway").getEmittedBin()); if (static_libs) |v| try v.append(
b.allocator,
highway_dep.artifact("highway").getEmittedBin(),
);
} }
// utfcpp - This is used as a dependency on our hand-written C++ code // utfcpp - This is used as a dependency on our hand-written C++ code
@@ -717,7 +736,10 @@ pub fn addSimd(
.optimize = optimize, .optimize = optimize,
})) |utfcpp_dep| { })) |utfcpp_dep| {
m.linkLibrary(utfcpp_dep.artifact("utfcpp")); m.linkLibrary(utfcpp_dep.artifact("utfcpp"));
if (static_libs) |v| try v.append(utfcpp_dep.artifact("utfcpp").getEmittedBin()); if (static_libs) |v| try v.append(
b.allocator,
utfcpp_dep.artifact("utfcpp").getEmittedBin(),
);
} }
// SIMD C++ files // SIMD C++ files
@@ -761,16 +783,20 @@ pub fn gtkNgDistResources(
const gresource_xml = gresource_xml: { const gresource_xml = gresource_xml: {
const xml_exe = b.addExecutable(.{ const xml_exe = b.addExecutable(.{
.name = "generate_gresource_xml", .name = "generate_gresource_xml",
.root_source_file = b.path("src/apprt/gtk/build/gresource.zig"), .root_module = b.createModule(.{
.target = b.graph.host, .root_source_file = b.path("src/apprt/gtk/build/gresource.zig"),
.target = b.graph.host,
}),
}); });
const xml_run = b.addRunArtifact(xml_exe); const xml_run = b.addRunArtifact(xml_exe);
// Run our blueprint compiler across all of our blueprint files. // Run our blueprint compiler across all of our blueprint files.
const blueprint_exe = b.addExecutable(.{ const blueprint_exe = b.addExecutable(.{
.name = "gtk_blueprint_compiler", .name = "gtk_blueprint_compiler",
.root_source_file = b.path("src/apprt/gtk/build/blueprint.zig"), .root_module = b.createModule(.{
.target = b.graph.host, .root_source_file = b.path("src/apprt/gtk/build/blueprint.zig"),
.target = b.graph.host,
}),
}); });
blueprint_exe.linkLibC(); blueprint_exe.linkLibC();
blueprint_exe.linkSystemLibrary2("gtk4", dynamic_link_opts); blueprint_exe.linkSystemLibrary2("gtk4", dynamic_link_opts);

View File

@@ -21,6 +21,9 @@ pub fn init(b: *std.Build, uucode_tables: std.Build.LazyPath) !UnicodeTables {
.omit_frame_pointer = false, .omit_frame_pointer = false,
.unwind_tables = .sync, .unwind_tables = .sync,
}), }),
// TODO: x86_64 self-hosted crashes
.use_llvm = true,
}); });
const symbols_exe = b.addExecutable(.{ const symbols_exe = b.addExecutable(.{
@@ -32,6 +35,9 @@ pub fn init(b: *std.Build, uucode_tables: std.Build.LazyPath) !UnicodeTables {
.omit_frame_pointer = false, .omit_frame_pointer = false,
.unwind_tables = .sync, .unwind_tables = .sync,
}), }),
// TODO: x86_64 self-hosted crashes
.use_llvm = true,
}); });
if (b.lazyDependency("uucode", .{ if (b.lazyDependency("uucode", .{

View File

@@ -29,10 +29,10 @@ COPY ./build.zig /src
# Install zig # Install zig
# https://ziglang.org/download/ # https://ziglang.org/download/
RUN export ZIG_VERSION=$(sed -n -e 's/^.*requireZig("\(.*\)").*$/\1/p' build.zig) && curl -L -o /tmp/zig.tar.xz "https://ziglang.org/download/$ZIG_VERSION/zig-linux-$(uname -m)-$ZIG_VERSION.tar.xz" && \ RUN export ZIG_VERSION=$(sed -n -e 's/^.*requireZig("\(.*\)").*$/\1/p' build.zig) && curl -L -o /tmp/zig.tar.xz "https://ziglang.org/download/$ZIG_VERSION/zig-$(uname -m)-linux-$ZIG_VERSION.tar.xz" && \
tar -xf /tmp/zig.tar.xz -C /opt && \ tar -xf /tmp/zig.tar.xz -C /opt && \
rm /tmp/zig.tar.xz && \ rm /tmp/zig.tar.xz && \
ln -s "/opt/zig-linux-$(uname -m)-$ZIG_VERSION/zig" /usr/local/bin/zig ln -s "/opt/zig-$(uname -m)-linux-$ZIG_VERSION/zig" /usr/local/bin/zig
COPY . /src COPY . /src

View File

@@ -2,12 +2,15 @@ const std = @import("std");
const gen = @import("mdgen.zig"); const gen = @import("mdgen.zig");
pub fn main() !void { pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
const alloc = gpa.allocator(); const alloc = gpa.allocator();
const writer = std.io.getStdOut().writer(); var buffer: [1024]u8 = undefined;
var stdout_writer = std.fs.File.stdout().writer(&buffer);
const writer = &stdout_writer.interface;
try gen.substitute(alloc, @embedFile("ghostty_1_header.md"), writer); try gen.substitute(alloc, @embedFile("ghostty_1_header.md"), writer);
try gen.genActions(writer); try gen.genActions(writer);
try gen.genConfig(writer, true); try gen.genConfig(writer, true);
try gen.substitute(alloc, @embedFile("ghostty_1_footer.md"), writer); try gen.substitute(alloc, @embedFile("ghostty_1_footer.md"), writer);
try writer.flush();
} }

View File

@@ -2,12 +2,15 @@ const std = @import("std");
const gen = @import("mdgen.zig"); const gen = @import("mdgen.zig");
pub fn main() !void { pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
const alloc = gpa.allocator(); const alloc = gpa.allocator();
const output = std.io.getStdOut().writer(); var buffer: [1024]u8 = undefined;
try gen.substitute(alloc, @embedFile("ghostty_5_header.md"), output); var stdout_writer = std.fs.File.stdout().writer(&buffer);
try gen.genConfig(output, false); const writer = &stdout_writer.interface;
try gen.genKeybindActions(output); try gen.substitute(alloc, @embedFile("ghostty_5_header.md"), writer);
try gen.substitute(alloc, @embedFile("ghostty_5_footer.md"), output); try gen.genConfig(writer, false);
try gen.genKeybindActions(writer);
try gen.substitute(alloc, @embedFile("ghostty_5_footer.md"), writer);
try writer.flush();
} }

View File

@@ -5,7 +5,7 @@ const Config = @import("../../config/Config.zig");
const Action = @import("../../cli/ghostty.zig").Action; const Action = @import("../../cli/ghostty.zig").Action;
const KeybindAction = @import("../../input/Binding.zig").Action; const KeybindAction = @import("../../input/Binding.zig").Action;
pub fn substitute(alloc: std.mem.Allocator, input: []const u8, writer: anytype) !void { pub fn substitute(alloc: std.mem.Allocator, input: []const u8, writer: *std.Io.Writer) !void {
const output = try alloc.alloc(u8, std.mem.replacementSize( const output = try alloc.alloc(u8, std.mem.replacementSize(
u8, u8,
input, input,
@@ -18,7 +18,7 @@ pub fn substitute(alloc: std.mem.Allocator, input: []const u8, writer: anytype)
try writer.writeAll(output); try writer.writeAll(output);
} }
pub fn genConfig(writer: anytype, cli: bool) !void { pub fn genConfig(writer: *std.Io.Writer, cli: bool) !void {
try writer.writeAll( try writer.writeAll(
\\ \\
\\# CONFIGURATION OPTIONS \\# CONFIGURATION OPTIONS
@@ -48,7 +48,7 @@ pub fn genConfig(writer: anytype, cli: bool) !void {
} }
} }
pub fn genActions(writer: anytype) !void { pub fn genActions(writer: *std.Io.Writer) !void {
try writer.writeAll( try writer.writeAll(
\\ \\
\\# COMMAND LINE ACTIONS \\# COMMAND LINE ACTIONS
@@ -83,7 +83,7 @@ pub fn genActions(writer: anytype) !void {
} }
} }
pub fn genKeybindActions(writer: anytype) !void { pub fn genKeybindActions(writer: *std.Io.Writer) !void {
try writer.writeAll( try writer.writeAll(
\\ \\
\\# KEYBIND ACTIONS \\# KEYBIND ACTIONS

View File

@@ -3,6 +3,8 @@ const help_strings = @import("help_strings");
const helpgen_actions = @import("../../input/helpgen_actions.zig"); const helpgen_actions = @import("../../input/helpgen_actions.zig");
pub fn main() !void { pub fn main() !void {
const output = std.io.getStdOut().writer(); var buffer: [2048]u8 = undefined;
try helpgen_actions.generate(output, .markdown, true, std.heap.page_allocator); var stdout_writer = std.fs.File.stdout().writer(&buffer);
const stdout = &stdout_writer.interface;
try helpgen_actions.generate(stdout, .markdown, true, std.heap.page_allocator);
} }

View File

@@ -3,14 +3,16 @@ const Action = @import("../../cli/ghostty.zig").Action;
const help_strings = @import("help_strings"); const help_strings = @import("help_strings");
pub fn main() !void { pub fn main() !void {
const output = std.io.getStdOut().writer(); var buffer: [2048]u8 = undefined;
try genActions(output); var stdout_writer = std.fs.File.stdout().writer(&buffer);
const stdout = &stdout_writer.interface;
try genActions(stdout);
} }
// Note: as a shortcut for defining inline editOnGithubLinks per cli action the user // Note: as a shortcut for defining inline editOnGithubLinks per cli action the user
// is directed to the folder view on Github. This includes a README pointing them to // is directed to the folder view on Github. This includes a README pointing them to
// the files to edit. // the files to edit.
pub fn genActions(writer: anytype) !void { pub fn genActions(writer: *std.Io.Writer) !void {
// Write the header // Write the header
try writer.writeAll( try writer.writeAll(
\\--- \\---

View File

@@ -3,11 +3,13 @@ const Config = @import("../../config/Config.zig");
const help_strings = @import("help_strings"); const help_strings = @import("help_strings");
pub fn main() !void { pub fn main() !void {
const output = std.io.getStdOut().writer(); var buffer: [2048]u8 = undefined;
try genConfig(output); var stdout_writer = std.fs.File.stdout().writer(&buffer);
const stdout = &stdout_writer.interface;
try genConfig(stdout);
} }
pub fn genConfig(writer: anytype) !void { pub fn genConfig(writer: *std.Io.Writer) !void {
// Write the header // Write the header
try writer.writeAll( try writer.writeAll(
\\--- \\---
@@ -122,7 +124,7 @@ pub fn genConfig(writer: anytype) !void {
} }
} }
fn endBlock(writer: anytype, block: anytype) !void { fn endBlock(writer: *std.Io.Writer, block: anytype) !void {
if (block) |v| switch (v) { if (block) |v| switch (v) {
.text => {}, .text => {},
.code => try writer.writeAll("```\n"), .code => try writer.writeAll("```\n"),

View File

@@ -162,10 +162,11 @@ pub fn parse(
error.InvalidField => "unknown field", error.InvalidField => "unknown field",
error.ValueRequired => formatValueRequired(T, arena_alloc, key) catch "value required", error.ValueRequired => formatValueRequired(T, arena_alloc, key) catch "value required",
error.InvalidValue => formatInvalidValue(T, arena_alloc, key, value) catch "invalid value", error.InvalidValue => formatInvalidValue(T, arena_alloc, key, value) catch "invalid value",
else => try std.fmt.allocPrintZ( else => try std.fmt.allocPrintSentinel(
arena_alloc, arena_alloc,
"unknown error {}", "unknown error {}",
.{err}, .{err},
0,
), ),
}; };
@@ -235,14 +236,16 @@ fn formatValueRequired(
comptime T: type, comptime T: type,
arena_alloc: std.mem.Allocator, arena_alloc: std.mem.Allocator,
key: []const u8, key: []const u8,
) std.mem.Allocator.Error![:0]const u8 { ) std.Io.Writer.Error![:0]const u8 {
var buf = std.ArrayList(u8).init(arena_alloc); var stream: std.Io.Writer.Allocating = .init(arena_alloc);
errdefer buf.deinit(); const writer = &stream.writer;
const writer = buf.writer();
try writer.print("value required", .{}); try writer.print("value required", .{});
try formatValues(T, key, writer); try formatValues(T, key, writer);
try writer.writeByte(0); try writer.writeByte(0);
return buf.items[0 .. buf.items.len - 1 :0];
const written = stream.written();
return written[0 .. written.len - 1 :0];
} }
fn formatInvalidValue( fn formatInvalidValue(
@@ -250,17 +253,23 @@ fn formatInvalidValue(
arena_alloc: std.mem.Allocator, arena_alloc: std.mem.Allocator,
key: []const u8, key: []const u8,
value: ?[]const u8, value: ?[]const u8,
) std.mem.Allocator.Error![:0]const u8 { ) std.Io.Writer.Error![:0]const u8 {
var buf = std.ArrayList(u8).init(arena_alloc); var stream: std.Io.Writer.Allocating = .init(arena_alloc);
errdefer buf.deinit(); const writer = &stream.writer;
const writer = buf.writer();
try writer.print("invalid value \"{?s}\"", .{value}); try writer.print("invalid value \"{?s}\"", .{value});
try formatValues(T, key, writer); try formatValues(T, key, writer);
try writer.writeByte(0); try writer.writeByte(0);
return buf.items[0 .. buf.items.len - 1 :0];
const written = stream.written();
return written[0 .. written.len - 1 :0];
} }
fn formatValues(comptime T: type, key: []const u8, writer: anytype) std.mem.Allocator.Error!void { fn formatValues(
comptime T: type,
key: []const u8,
writer: *std.Io.Writer,
) std.Io.Writer.Error!void {
@setEvalBranchQuota(2000); @setEvalBranchQuota(2000);
const typeinfo = @typeInfo(T); const typeinfo = @typeInfo(T);
inline for (typeinfo.@"struct".fields) |f| { inline for (typeinfo.@"struct".fields) |f| {
@@ -324,7 +333,7 @@ pub fn parseIntoField(
return; return;
} }
const raw = field.default_value_ptr orelse break :default; const raw = field.default_value_ptr orelse break :default;
const ptr: *const field.type = @alignCast(@ptrCast(raw)); const ptr: *const field.type = @ptrCast(@alignCast(raw));
@field(dst, field.name) = ptr.*; @field(dst, field.name) = ptr.*;
return; return;
} }
@@ -542,8 +551,8 @@ pub fn parseAutoStruct(
const key = std.mem.trim(u8, entry[0..idx], whitespace); const key = std.mem.trim(u8, entry[0..idx], whitespace);
// used if we need to decode a double-quoted string. // used if we need to decode a double-quoted string.
var buf: std.ArrayListUnmanaged(u8) = .empty; var buf: std.Io.Writer.Allocating = .init(alloc);
defer buf.deinit(alloc); defer buf.deinit();
const value = value: { const value = value: {
const value = std.mem.trim(u8, entry[idx + 1 ..], whitespace); const value = std.mem.trim(u8, entry[idx + 1 ..], whitespace);
@@ -554,10 +563,9 @@ pub fn parseAutoStruct(
value[value.len - 1] == '"') value[value.len - 1] == '"')
{ {
// Decode a double-quoted string as a Zig string literal. // Decode a double-quoted string as a Zig string literal.
const writer = buf.writer(alloc); const parsed = try std.zig.string_literal.parseWrite(&buf.writer, value);
const parsed = try std.zig.string_literal.parseWrite(writer, value);
if (parsed == .failure) return error.InvalidValue; if (parsed == .failure) return error.InvalidValue;
break :value buf.items; break :value buf.written();
} }
break :value value; break :value value;
@@ -586,7 +594,7 @@ pub fn parseAutoStruct(
break :default @field(default, field.name); break :default @field(default, field.name);
} else { } else {
const default_ptr = field.default_value_ptr orelse return error.InvalidValue; const default_ptr = field.default_value_ptr orelse return error.InvalidValue;
const typed_ptr: *const field.type = @alignCast(@ptrCast(default_ptr)); const typed_ptr: *const field.type = @ptrCast(@alignCast(default_ptr));
break :default typed_ptr.*; break :default typed_ptr.*;
} }
}; };
@@ -795,15 +803,13 @@ test "parse: diagnostic location" {
} = .{}; } = .{};
defer if (data._arena) |arena| arena.deinit(); defer if (data._arena) |arena| arena.deinit();
var fbs = std.io.fixedBufferStream( var r: std.Io.Reader = .fixed(
\\a=42 \\a=42
\\what \\what
\\b=two \\b=two
); );
const r = fbs.reader();
const Iter = LineIterator(@TypeOf(r)); var iter: LineIterator = .{ .r = &r, .filepath = "test" };
var iter: Iter = .{ .r = r, .filepath = "test" };
try parse(@TypeOf(data), testing.allocator, &data, &iter); try parse(@TypeOf(data), testing.allocator, &data, &iter);
try testing.expect(data._arena != null); try testing.expect(data._arena != null);
try testing.expectEqualStrings("42", data.a); try testing.expectEqualStrings("42", data.a);
@@ -1208,18 +1214,7 @@ test "parseIntoField: struct with basic fields" {
try testing.expectEqual(84, data.value.b); try testing.expectEqual(84, data.value.b);
try testing.expectEqual(24, data.value.c); try testing.expectEqual(24, data.value.c);
// Set with explicit default // Missing require dfield
data.value = try parseAutoStruct(
@TypeOf(data.value),
alloc,
"a:hello",
.{ .a = "oh no", .b = 42 },
);
try testing.expectEqualStrings("hello", data.value.a);
try testing.expectEqual(42, data.value.b);
try testing.expectEqual(12, data.value.c);
// Missing required field
try testing.expectError( try testing.expectError(
error.InvalidValue, error.InvalidValue,
parseIntoField(@TypeOf(data), alloc, &data, "value", "a:hello"), parseIntoField(@TypeOf(data), alloc, &data, "value", "a:hello"),
@@ -1395,115 +1390,119 @@ test "ArgsIterator" {
/// Returns an iterator (implements "next") that reads CLI args by line. /// Returns an iterator (implements "next") that reads CLI args by line.
/// Each CLI arg is expected to be a single line. This is used to implement /// Each CLI arg is expected to be a single line. This is used to implement
/// configuration files. /// configuration files.
pub fn LineIterator(comptime ReaderType: type) type { pub const LineIterator = struct {
return struct { const Self = @This();
const Self = @This();
/// The maximum size a single line can be. We don't expect any /// The maximum size a single line can be. We don't expect any
/// CLI arg to exceed this size. Can't wait to git blame this in /// CLI arg to exceed this size. Can't wait to git blame this in
/// like 4 years and be wrong about this. /// like 4 years and be wrong about this.
pub const MAX_LINE_SIZE = 4096; pub const MAX_LINE_SIZE = 4096;
/// Our stateful reader. /// Our stateful reader.
r: ReaderType, r: *std.Io.Reader,
/// Filepath that is used for diagnostics. This is only used for /// Filepath that is used for diagnostics. This is only used for
/// diagnostic messages so it can be formatted however you want. /// diagnostic messages so it can be formatted however you want.
/// It is prefixed to the messages followed by the line number. /// It is prefixed to the messages followed by the line number.
filepath: []const u8 = "", filepath: []const u8 = "",
/// The current line that we're on. This is 1-indexed because /// The current line that we're on. This is 1-indexed because
/// lines are generally 1-indexed in the real world. The value /// lines are generally 1-indexed in the real world. The value
/// can be zero if we haven't read any lines yet. /// can be zero if we haven't read any lines yet.
line: usize = 0, line: usize = 0,
/// This is the buffer where we store the current entry that /// This is the buffer where we store the current entry that
/// is formatted to be compatible with the parse function. /// is formatted to be compatible with the parse function.
entry: [MAX_LINE_SIZE]u8 = [_]u8{ '-', '-' } ++ ([_]u8{0} ** (MAX_LINE_SIZE - 2)), entry: [MAX_LINE_SIZE]u8 = [_]u8{ '-', '-' } ++ ([_]u8{0} ** (MAX_LINE_SIZE - 2)),
pub fn next(self: *Self) ?[]const u8 { pub fn init(reader: *std.Io.Reader) Self {
// TODO: detect "--" prefixed lines and give a friendlier error return .{ .r = reader };
const buf = buf: { }
while (true) {
// Read the full line
var entry = self.r.readUntilDelimiterOrEof(self.entry[2..], '\n') catch |err| switch (err) {
inline else => |e| {
log.warn("cannot read from \"{s}\": {}", .{ self.filepath, e });
return null;
},
} orelse return null;
// Increment our line counter pub fn next(self: *Self) ?[]const u8 {
self.line += 1; // First prime the reader.
// File readers at least are initialized with a size of 0,
// and this will actually prompt the reader to get the actual
// size of the file, which will be used in the EOF check below.
//
// This will also optimize reads down the line as we're
// more likely to beworking with buffered data.
self.r.fillMore() catch {};
// Trim any whitespace (including CR) around it var writer: std.Io.Writer = .fixed(self.entry[2..]);
const trim = std.mem.trim(u8, entry, whitespace ++ "\r");
if (trim.len != entry.len) {
std.mem.copyForwards(u8, entry, trim);
entry = entry[0..trim.len];
}
// Ignore blank lines and comments var entry = while (self.r.seek != self.r.end) {
if (entry.len == 0 or entry[0] == '#') continue; // Reset write head
writer.end = 0;
// Trim spaces around '=' _ = self.r.streamDelimiterEnding(&writer, '\n') catch |e| {
if (mem.indexOf(u8, entry, "=")) |idx| { log.warn("cannot read from \"{s}\": {}", .{ self.filepath, e });
const key = std.mem.trim(u8, entry[0..idx], whitespace); return null;
const value = value: { };
var value = std.mem.trim(u8, entry[idx + 1 ..], whitespace); _ = self.r.discardDelimiterInclusive('\n') catch {};
// Detect a quoted string. var entry = writer.buffered();
if (value.len >= 2 and self.line += 1;
value[0] == '"' and
value[value.len - 1] == '"')
{
// Trim quotes since our CLI args processor expects
// quotes to already be gone.
value = value[1 .. value.len - 1];
}
break :value value; // Trim any whitespace (including CR) around it
}; const trim = std.mem.trim(u8, entry, whitespace ++ "\r");
if (trim.len != entry.len) {
std.mem.copyForwards(u8, entry, trim);
entry = entry[0..trim.len];
}
const len = key.len + value.len + 1; // Ignore blank lines and comments
if (entry.len != len) { if (entry.len == 0 or entry[0] == '#') continue;
std.mem.copyForwards(u8, entry, key); break entry;
entry[key.len] = '='; } else return null;
std.mem.copyForwards(u8, entry[key.len + 1 ..], value);
entry = entry[0..len];
}
}
break :buf entry; if (mem.indexOf(u8, entry, "=")) |idx| {
const key = std.mem.trim(u8, entry[0..idx], whitespace);
const value = value: {
var value = std.mem.trim(u8, entry[idx + 1 ..], whitespace);
// Detect a quoted string.
if (value.len >= 2 and
value[0] == '"' and
value[value.len - 1] == '"')
{
// Trim quotes since our CLI args processor expects
// quotes to already be gone.
value = value[1 .. value.len - 1];
} }
break :value value;
}; };
// We need to reslice so that we include our '--' at the beginning const len = key.len + value.len + 1;
// of our buffer so that we can trick the CLI parser to treat it if (entry.len != len) {
// as CLI args. std.mem.copyForwards(u8, entry, key);
return self.entry[0 .. buf.len + 2]; entry[key.len] = '=';
std.mem.copyForwards(u8, entry[key.len + 1 ..], value);
entry = entry[0..len];
}
} }
/// Returns a location for a diagnostic message. // We need to reslice so that we include our '--' at the beginning
pub fn location( // of our buffer so that we can trick the CLI parser to treat it
self: *const Self, // as CLI args.
alloc: Allocator, return self.entry[0 .. entry.len + 2];
) Allocator.Error!?diags.Location { }
// If we have no filepath then we have no location.
if (self.filepath.len == 0) return null;
return .{ .file = .{ /// Returns a location for a diagnostic message.
.path = try alloc.dupe(u8, self.filepath), pub fn location(
.line = self.line, self: *const Self,
} }; alloc: Allocator,
} ) Allocator.Error!?diags.Location {
}; // If we have no filepath then we have no location.
} if (self.filepath.len == 0) return null;
// Constructs a LineIterator (see docs for that). return .{ .file = .{
fn lineIterator(reader: anytype) LineIterator(@TypeOf(reader)) { .path = try alloc.dupe(u8, self.filepath),
return .{ .r = reader }; .line = self.line,
} } };
}
};
/// An iterator valid for arg parsing from a slice. /// An iterator valid for arg parsing from a slice.
pub const SliceIterator = struct { pub const SliceIterator = struct {
@@ -1526,7 +1525,7 @@ pub fn sliceIterator(slice: []const []const u8) SliceIterator {
test "LineIterator" { test "LineIterator" {
const testing = std.testing; const testing = std.testing;
var fbs = std.io.fixedBufferStream( var reader: std.Io.Reader = .fixed(
\\A \\A
\\B=42 \\B=42
\\C \\C
@@ -1541,7 +1540,7 @@ test "LineIterator" {
\\F= "value " \\F= "value "
); );
var iter = lineIterator(fbs.reader()); var iter: LineIterator = .init(&reader);
try testing.expectEqualStrings("--A", iter.next().?); try testing.expectEqualStrings("--A", iter.next().?);
try testing.expectEqualStrings("--B=42", iter.next().?); try testing.expectEqualStrings("--B=42", iter.next().?);
try testing.expectEqualStrings("--C", iter.next().?); try testing.expectEqualStrings("--C", iter.next().?);
@@ -1554,9 +1553,9 @@ test "LineIterator" {
test "LineIterator end in newline" { test "LineIterator end in newline" {
const testing = std.testing; const testing = std.testing;
var fbs = std.io.fixedBufferStream("A\n\n"); var reader: std.Io.Reader = .fixed("A\n\n");
var iter = lineIterator(fbs.reader()); var iter: LineIterator = .init(&reader);
try testing.expectEqualStrings("--A", iter.next().?); try testing.expectEqualStrings("--A", iter.next().?);
try testing.expectEqual(@as(?[]const u8, null), iter.next()); try testing.expectEqual(@as(?[]const u8, null), iter.next());
try testing.expectEqual(@as(?[]const u8, null), iter.next()); try testing.expectEqual(@as(?[]const u8, null), iter.next());
@@ -1564,9 +1563,9 @@ test "LineIterator end in newline" {
test "LineIterator spaces around '='" { test "LineIterator spaces around '='" {
const testing = std.testing; const testing = std.testing;
var fbs = std.io.fixedBufferStream("A = B\n\n"); var reader: std.Io.Reader = .fixed("A = B\n\n");
var iter = lineIterator(fbs.reader()); var iter: LineIterator = .init(&reader);
try testing.expectEqualStrings("--A=B", iter.next().?); try testing.expectEqualStrings("--A=B", iter.next().?);
try testing.expectEqual(@as(?[]const u8, null), iter.next()); try testing.expectEqual(@as(?[]const u8, null), iter.next());
try testing.expectEqual(@as(?[]const u8, null), iter.next()); try testing.expectEqual(@as(?[]const u8, null), iter.next());
@@ -1574,18 +1573,18 @@ test "LineIterator spaces around '='" {
test "LineIterator no value" { test "LineIterator no value" {
const testing = std.testing; const testing = std.testing;
var fbs = std.io.fixedBufferStream("A = \n\n"); var reader: std.Io.Reader = .fixed("A = \n\n");
var iter = lineIterator(fbs.reader()); var iter: LineIterator = .init(&reader);
try testing.expectEqualStrings("--A=", iter.next().?); try testing.expectEqualStrings("--A=", iter.next().?);
try testing.expectEqual(@as(?[]const u8, null), iter.next()); try testing.expectEqual(@as(?[]const u8, null), iter.next());
} }
test "LineIterator with CRLF line endings" { test "LineIterator with CRLF line endings" {
const testing = std.testing; const testing = std.testing;
var fbs = std.io.fixedBufferStream("A\r\nB = C\r\n"); var reader: std.Io.Reader = .fixed("A\r\nB = C\r\n");
var iter = lineIterator(fbs.reader()); var iter: LineIterator = .init(&reader);
try testing.expectEqualStrings("--A", iter.next().?); try testing.expectEqualStrings("--A", iter.next().?);
try testing.expectEqualStrings("--B=C", iter.next().?); try testing.expectEqualStrings("--B=C", iter.next().?);
try testing.expectEqual(@as(?[]const u8, null), iter.next()); try testing.expectEqual(@as(?[]const u8, null), iter.next());

View File

@@ -6,7 +6,7 @@ const Allocator = std.mem.Allocator;
const help_strings = @import("help_strings"); const help_strings = @import("help_strings");
const vaxis = @import("vaxis"); const vaxis = @import("vaxis");
const framedata = @import("framedata"); const framedata = @embedFile("framedata");
const vxfw = vaxis.vxfw; const vxfw = vaxis.vxfw;
@@ -218,17 +218,20 @@ var frames: []const []const u8 = undefined;
/// Decompress the frames into a slice of individual frames /// Decompress the frames into a slice of individual frames
fn decompressFrames(gpa: Allocator) !void { fn decompressFrames(gpa: Allocator) !void {
var fbs = std.io.fixedBufferStream(framedata.compressed); var src: std.Io.Reader = .fixed(framedata);
var list = std.ArrayList(u8).init(gpa);
try std.compress.flate.decompress(fbs.reader(), list.writer()); // var buf: [std.compress.flate.max_window_len]u8 = undefined;
decompressed_data = try list.toOwnedSlice(); var decompress: std.compress.flate.Decompress = .init(&src, .raw, &.{});
var frame_list = try std.ArrayList([]const u8).initCapacity(gpa, 235); var out: std.Io.Writer.Allocating = .init(gpa);
_ = try decompress.reader.streamRemaining(&out.writer);
decompressed_data = try out.toOwnedSlice();
var frame_list: std.ArrayList([]const u8) = try .initCapacity(gpa, 235);
var frame_iter = std.mem.splitScalar(u8, decompressed_data, '\x01'); var frame_iter = std.mem.splitScalar(u8, decompressed_data, '\x01');
while (frame_iter.next()) |frame| { while (frame_iter.next()) |frame| {
try frame_list.append(frame); try frame_list.append(gpa, frame);
} }
frames = try frame_list.toOwnedSlice(); frames = try frame_list.toOwnedSlice(gpa);
} }

View File

@@ -38,21 +38,35 @@ pub fn run(alloc_gpa: Allocator) !u8 {
try args.parse(Options, alloc_gpa, &opts, &iter); try args.parse(Options, alloc_gpa, &opts, &iter);
} }
var buffer: [1024]u8 = undefined;
var stdout_file: std.fs.File = .stdout();
var stdout_writer = stdout_file.writer(&buffer);
const stdout = &stdout_writer.interface;
const result = runInner(alloc, &stdout_file, stdout);
stdout.flush() catch {};
return result;
}
fn runInner(
alloc: Allocator,
stdout_file: *std.fs.File,
stdout: *std.Io.Writer,
) !u8 {
const crash_dir = try crash.defaultDir(alloc); const crash_dir = try crash.defaultDir(alloc);
var reports = std.ArrayList(crash.Report).init(alloc); var reports: std.ArrayList(crash.Report) = .empty;
errdefer reports.deinit(alloc);
var it = try crash_dir.iterator(); var it = try crash_dir.iterator();
while (try it.next()) |report| try reports.append(.{ while (try it.next()) |report| try reports.append(alloc, .{
.name = try alloc.dupe(u8, report.name), .name = try alloc.dupe(u8, report.name),
.mtime = report.mtime, .mtime = report.mtime,
}); });
const stdout = std.io.getStdOut();
// If we have no reports, then we're done. If we have a tty then we // If we have no reports, then we're done. If we have a tty then we
// print a message, otherwise we do nothing. // print a message, otherwise we do nothing.
if (reports.items.len == 0) { if (reports.items.len == 0) {
if (std.posix.isatty(stdout.handle)) { if (std.posix.isatty(stdout_file.handle)) {
try stdout.writeAll("No crash reports! 👻\n"); try stdout.writeAll("No crash reports! 👻\n");
} }
return 0; return 0;
@@ -60,16 +74,15 @@ pub fn run(alloc_gpa: Allocator) !u8 {
std.mem.sort(crash.Report, reports.items, {}, lt); std.mem.sort(crash.Report, reports.items, {}, lt);
const writer = stdout.writer();
for (reports.items) |report| { for (reports.items) |report| {
var buf: [128]u8 = undefined; var buf: [128]u8 = undefined;
const now = std.time.nanoTimestamp(); const now = std.time.nanoTimestamp();
const diff = now - report.mtime; const diff = now - report.mtime;
const since = if (diff <= 0) "now" else s: { const since = if (diff <= 0) "now" else s: {
const d = Config.Duration{ .duration = @intCast(diff) }; const d = Config.Duration{ .duration = @intCast(diff) };
break :s try std.fmt.bufPrint(&buf, "{s} ago", .{d.round(std.time.ns_per_s)}); break :s try std.fmt.bufPrint(&buf, "{f} ago", .{d.round(std.time.ns_per_s)});
}; };
try writer.print("{s} ({s})\n", .{ report.name, since }); try stdout.print("{s} ({s})\n", .{ report.name, since });
} }
return 0; return 0;

View File

@@ -16,7 +16,7 @@ pub const Diagnostic = struct {
message: [:0]const u8, message: [:0]const u8,
/// Write the full user-friendly diagnostic message to the writer. /// Write the full user-friendly diagnostic message to the writer.
pub fn write(self: *const Diagnostic, writer: anytype) !void { pub fn format(self: *const Diagnostic, writer: *std.Io.Writer) !void {
switch (self.location) { switch (self.location) {
.none => {}, .none => {},
.cli => |index| try writer.print("cli:{}:", .{index}), .cli => |index| try writer.print("cli:{}:", .{index}),
@@ -157,11 +157,14 @@ pub const DiagnosticList = struct {
errdefer _ = self.list.pop(); errdefer _ = self.list.pop();
if (comptime precompute_enabled) { if (comptime precompute_enabled) {
var buf = std.ArrayList(u8).init(alloc); var stream: std.Io.Writer.Allocating = .init(alloc);
defer buf.deinit(); defer stream.deinit();
try diag.write(buf.writer()); diag.format(&stream.writer) catch |err| switch (err) {
// WriteFailed in this instance can only mean an OOM
error.WriteFailed => return error.OutOfMemory,
};
const owned: [:0]const u8 = try buf.toOwnedSliceSentinel(0); const owned: [:0]const u8 = try stream.toOwnedSliceSentinel(0);
errdefer alloc.free(owned); errdefer alloc.free(owned);
try self.precompute.messages.append(alloc, owned); try self.precompute.messages.append(alloc, owned);

View File

@@ -47,7 +47,9 @@ pub fn run(alloc: Allocator) !u8 {
// not using `exec` anymore and because this command isn't performance // not using `exec` anymore and because this command isn't performance
// critical where setting up the defer cleanup is a problem. // critical where setting up the defer cleanup is a problem.
const stderr = std.io.getStdErr().writer(); var buffer: [1024]u8 = undefined;
var stderr_writer = std.fs.File.stderr().writer(&buffer);
const stderr = &stderr_writer.interface;
var opts: Options = .{}; var opts: Options = .{};
defer opts.deinit(); defer opts.deinit();
@@ -58,6 +60,13 @@ pub fn run(alloc: Allocator) !u8 {
try args.parse(Options, alloc, &opts, &iter); try args.parse(Options, alloc, &opts, &iter);
} }
const result = runInner(alloc, stderr);
// Flushing *shouldn't* fail but...
stderr.flush() catch {};
return result;
}
fn runInner(alloc: Allocator, stderr: *std.Io.Writer) !u8 {
// We load the configuration once because that will write our // We load the configuration once because that will write our
// default configuration files to disk. We don't use the config. // default configuration files to disk. We don't use the config.
var config = try Config.load(alloc); var config = try Config.load(alloc);
@@ -133,23 +142,13 @@ pub fn run(alloc: Allocator) !u8 {
// so this is not a big deal. // so this is not a big deal.
comptime assert(builtin.link_libc); comptime assert(builtin.link_libc);
var buf: std.ArrayListUnmanaged(u8) = .empty; const editorZ = try alloc.dupeZ(u8, editor);
errdefer buf.deinit(alloc); defer alloc.free(editorZ);
const pathZ = try alloc.dupeZ(u8, path);
const writer = buf.writer(alloc); defer alloc.free(pathZ);
var shellescape: internal_os.ShellEscapeWriter(std.ArrayListUnmanaged(u8).Writer) = .init(writer);
var shellescapewriter = shellescape.writer();
try writer.writeAll(editor);
try writer.writeByte(' ');
try shellescapewriter.writeAll(path);
const command = try buf.toOwnedSliceSentinel(alloc, 0);
defer alloc.free(command);
const err = std.posix.execvpeZ( const err = std.posix.execvpeZ(
"sh", editorZ,
&.{ "sh", "-c", command }, &.{ editorZ, pathZ },
std.c.environ, std.c.environ,
); );

View File

@@ -107,12 +107,18 @@ pub const Action = enum {
// for all commands by just changing this one place. // for all commands by just changing this one place.
if (std.mem.eql(u8, field.name, @tagName(self))) { if (std.mem.eql(u8, field.name, @tagName(self))) {
const stdout = std.io.getStdOut().writer(); var buffer: [1024]u8 = undefined;
var stdout_writer = std.fs.File.stdout().writer(&buffer);
const stdout = &stdout_writer.interface;
const text = @field(help_strings.Action, field.name) ++ "\n"; const text = @field(help_strings.Action, field.name) ++ "\n";
stdout.writeAll(text) catch |write_err| { stdout.writeAll(text) catch |write_err| {
std.log.warn("failed to write help text: {}\n", .{write_err}); std.log.warn("failed to write help text: {}\n", .{write_err});
break :err 1; break :err 1;
}; };
stdout.flush() catch |flush_err| {
std.log.warn("failed to flush help text: {}\n", .{flush_err});
break :err 1;
};
break :err 0; break :err 0;
} }

View File

@@ -30,7 +30,9 @@ pub fn run(alloc: Allocator) !u8 {
try args.parse(Options, alloc, &opts, &iter); try args.parse(Options, alloc, &opts, &iter);
} }
const stdout = std.io.getStdOut().writer(); var buffer: [2048]u8 = undefined;
var stdout_writer = std.fs.File.stdout().writer(&buffer);
const stdout = &stdout_writer.interface;
try stdout.writeAll( try stdout.writeAll(
\\Usage: ghostty [+action] [options] \\Usage: ghostty [+action] [options]
\\ \\
@@ -70,6 +72,7 @@ pub fn run(alloc: Allocator) !u8 {
\\where `<action>` is one of actions listed above. \\where `<action>` is one of actions listed above.
\\ \\
); );
try stdout.flush();
return 0; return 0;
} }

Some files were not shown because too many files have changed in this diff Show More