summaryrefslogtreecommitdiff
path: root/build/core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 14:07:18 -0300
committerGabriel Schneider <[email protected]>2026-11-17 14:25:10 -0300
commit73e324a8dc89837b5de35b5cedee3a112fad5ec4 (patch)
tree04ba2c85a092fe4d01721013a3b4245b0bf093e6 /build/core.zig
parent20f75e147d720a6a4c98c4c3b4db067bbf55ee32 (diff)
downloadpardes-73e324a8dc89837b5de35b5cedee3a112fad5ec4.tar.gz
pardes-73e324a8dc89837b5de35b5cedee3a112fad5ec4.zip
build: the upstream patches as data, applied at make time by tools/patch.zig
Each of the four upstream patches (vaxis's parser, render and queue, zstbi, ghostty's kitty loader, mvzr) is a table of edits in build/patches.zig: the text to find, how many times it occurs, its replacement. tools/patch.zig (39 lines, the shape of sketchbook's reload_edit) applies one file's table at make time, and appends what the patch adds as a real Zig file of build/patches/ (vaxis_parser.zig, vaxis_render.zig, ghostty_kitty.zig, mvzr_budget.zig); an edit whose text moved or doubled writes nothing and fails that file's step. The configure no longer reads or carries ~300 KB of patched sources: the binary configuration halves (tui 607,524 -> 302,049 bytes, gui 643,248 -> 337,769). build/patches.zig 386 -> 338 lines, plus 57 in its four appended files. Gates: zig build -l and -h byte-identical, whole matrix and test/lib. The patched files byte-identical to the base's (Parser.zig, Vaxis.zig, queue.zig, graphics_image.zig, mvzr.zig, zstbi.c), and the four module directories the compiles read (vaxis 53 files, ghostty 1,009, mvzr, zstbi) identical file for file (sha256). The warm rebuild cannot be all cached: a module root in another directory is another compile, though its bytes are the same (a 10-line experiment shows it), so this was built from a wiped cache: install addons, core-test shell-test unit-test process-test on tui and gui give the base's counts (tui 2339/2486, gui 2398/2545, the same failures). pardes and pardes-gui differ from the base's in layout only: section sizes equal, every named symbol the same name, size and kind (tui 37,228; gui 79,507 against the base tree relinked cold), anonymous symbols the same sizes; image.so and pdf.so identical once their debug info is stripped. (A cold relink of the base tree itself takes operator new from libc++abi.a rather than libc++.a, as this one does: the base's binary was linked in another order.) A second build is all cached, the patch runs too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build/core.zig')
-rw-r--r--build/core.zig27
1 files changed, 12 insertions, 15 deletions
diff --git a/build/core.zig b/build/core.zig
index 8fced4ce..6656481a 100644
--- a/build/core.zig
+++ b/build/core.zig
@@ -403,8 +403,8 @@ pub fn assemble(b: *std.Build, c: struct {
const target = c.target;
const optimize = c.optimize;
const c_optimize = c.c_optimize;
- // build-time IO: slurps the grammars' highlights.scm queries, and reads
- // vendor/themes to find the theme sources
+ // build-time IO: slurps the grammars' highlights.scm queries, reads
+ // vendor/themes to find the theme sources, and walks MuPDF's tree
var threaded: std.Io.Threaded = .init(b.allocator, .{});
defer threaded.deinit();
const io = threaded.io();
@@ -431,14 +431,11 @@ pub fn assemble(b: *std.Build, c: struct {
const zstbi_dep = b.dependency("zstbi", .{ .target = target, .optimize = c_optimize });
const zstbi_mod = zstbi_dep.module("root");
- // mvzr backtracks with no bound on its work (its own test "do not make
- // this test any longer": `a?` n times is 2^n steps), and pardes searches
- // with it holding the editor. Its matcher gets a step budget, patched into
- // the fetched source here at build time so that a fresh fetch keeps it:
- // each entry to matchPattern, which its backtracking recurses through,
- // spends a step, and with none left the match fails and says so
- // (src/regexp.zig). A bump that moves the anchor stops the build.
- const mvzr_mod = patches.mvzr(b, io, b.dependency("mvzr", .{ .target = target, .optimize = optimize }), target, optimize);
+ // vaxis, ghostty, mvzr and zstbi are patched as they are fetched
+ // (build/patches.zig), by one tool made once.
+ const patch = patches.tool(b);
+ // mvzr with a step budget, its group backtracking and `$` before `|`.
+ const mvzr_mod = patches.mvzr(b, patch, b.dependency("mvzr", .{ .target = target, .optimize = optimize }), target, optimize);
// The C heap every C library with an allocator hook is handed: the core's
// tree-sitter and fonts, and pdf.zig's MuPDF, which is a module of its own.
@@ -488,7 +485,7 @@ pub fn assemble(b: *std.Build, c: struct {
.external_uucode = true,
});
const vaxis_mod = vaxis_dep.module("vaxis");
- patches.vaxis(b, io, vaxis_dep, vaxis_mod);
+ patches.vaxis(b, patch, vaxis_dep, vaxis_mod);
var ghostty_vt_for_tests: ?*std.Build.Module = null;
const ghostty_simd = !target.result.os.tag.isDarwin() or b.graph.host.result.os.tag.isDarwin();
@@ -498,7 +495,7 @@ pub fn assemble(b: *std.Build, c: struct {
const ghostty_vt = dep.module("ghostty-vt");
ghostty_vt_for_tests = ghostty_vt;
ghostty_vt.addImport("uucode", uucode_mod);
- patches.ghosttyKitty(b, io, dep, ghostty_vt);
+ patches.ghosttyKitty(b, patch, dep, ghostty_vt);
}
// override uucode on vaxis LAST so it wins over ghostty's build() wiring.
vaxis_mod.addImport("uucode", uucode_mod);
@@ -507,10 +504,10 @@ pub fn assemble(b: *std.Build, c: struct {
// ghostty-vt links for kitty graphics whatever pardes does; a terminal's
// PNG is decoded through it (TerminalImages.zig), and of zstbi only its
// resize is left, for the PNG's downscale: stb_image and its writer
- // (with the deflate it carries) are patched out, here at build time so
- // a fresh fetch keeps it. The image addon has its own (addons/image).
+ // (with the deflate it carries) are patched out (build/patches.zig).
+ // The image addon has its own (addons/image).
const wuffs_mod: ?*std.Build.Module = if (ghostty_vt_for_tests) |vt| vt.import_table.get("wuffs") else null;
- patches.zstbi(b, io, zstbi_dep, zstbi_mod);
+ patches.zstbi(b, patch, zstbi_dep, zstbi_mod);
// One zstd (docs/shared-libs.md): a far replica's stream, compressed by
// its session and read by its client (src/replica.zig). The library's