diff options
| -rw-r--r-- | abi/wire.zig | 10 | ||||
| -rw-r--r-- | build/core.zig | 33 |
2 files changed, 35 insertions, 8 deletions
diff --git a/abi/wire.zig b/abi/wire.zig index 46e51645..55a08909 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -74,8 +74,10 @@ const family = switch (config.platform) { /// its own, and one of another build is refused. The protocol, the release /// and commit, the platform and build options, every dependency's content /// hash (grammars, the terminal emulator, Unicode), the walker codec's assumptions -/// (pointer width, byte order) and the tape's shape (tape.shape: what each -/// input and each answer of the host's is laid out as). Not the OS: a Linux +/// (pointer width, byte order), the tape's shape (tape.shape: what each +/// input and each answer of the host's is laid out as) and what pardes +/// changes in its dependencies (build_info.patches: the patches' text, the +/// Unicode tables' configuration). Not the OS: a Linux /// client of a FreeBSD session is the main case, and what differs there is /// the host's, taped, in a shape every OS shares (an error by its name, a /// stat as fs.OsStat). Nor the build mode: a Debug build steps as a @@ -96,12 +98,12 @@ pub const semantics: u64 = blk: { // 11 KB) joined on, not formatted: formatting them at comptime was 5 % // of a compile of the core. break :blk std.hash.Wyhash.hash(0, std.fmt.comptimePrint( - "wire {d}\npardes {s} {s}\n{s} grammars true {} {} {} workspace_tag {} sources {}\nusize {d} {t}\n", + "wire {d}\npardes {s} {s}\n{s} grammars true {} {} {} workspace_tag {} sources {}\nusize {d} {t}\npatches {x}\n", .{ version, build_info.version, build_info.commit orelse "unstamped", family, g != .none, g != .none, g == .full, config.workspace_tag, config.embed_sources, - @sizeOf(usize), builtin.cpu.arch.endian(), + @sizeOf(usize), builtin.cpu.arch.endian(), build_info.patches, }, ) ++ build_info.deps ++ "\n" ++ pardes.tape.shape); }; diff --git a/build/core.zig b/build/core.zig index 63b4a5e9..e8150843 100644 --- a/build/core.zig +++ b/build/core.zig @@ -94,18 +94,43 @@ pub fn options(b: *std.Build, cfg: ShellConfig, c: Core, pdf: bool) *std.Build.S } /// `build_info`: the version, and the commit, change and time a stamped -/// build was made from (see `stamp_commit`, read at configure time), and -/// every dependency's hash. -pub fn buildInfo(b: *std.Build, cfg: ShellConfig) *std.Build.Step.Options { +/// build was made from (see `stamp_commit`, read at configure time), every +/// dependency's hash, and what pardes changes in them (`patchesHash`). +pub fn buildInfo(b: *std.Build, io: std.Io, cfg: ShellConfig) *std.Build.Step.Options { const o = b.addOptions(); o.addOption([]const u8, "version", display_version); o.addOption(?[]const u8, "commit", cfg.commit); o.addOption(?[]const u8, "change", cfg.change); o.addOption(?[]const u8, "built", cfg.built); o.addOption([]const u8, "deps", deps_text); + o.addOption(u64, "patches", patchesHash(b, io)); return o; } +/// The text of every edit pardes makes to a fetched dependency +/// (build/patches.zig's tables and the files they append, build/patches/) +/// and of the Unicode tables' configuration (uucode_config.zig), hashed: a +/// dependency's pin is in `deps`, but what pardes changes in it is this +/// tree's, which an unstamped build has no commit to stand for, and it +/// changes how a core steps (ghostty's page size: how many rows its +/// history drops at once; a kitty medium's read; a regex's budget), so it +/// is a replica's semantics too (abi/wire.zig `semantics`). +fn patchesHash(b: *std.Build, io: std.Io) u64 { + var h: u64 = 0; + for ([_][]const u8{ "build/patches.zig", "uucode_config.zig" }) |sub| + h ^= std.hash.Wyhash.hash(0, configureRead(b, io, b.root, sub, 1 << 20) catch @panic(sub)); + var dir = b.root.root_dir.handle.openDir(io, "build/patches", .{ .iterate = true }) catch @panic("open build/patches"); + defer dir.close(io); + var it = dir.iterate(); + // Each file by its name and text, in whatever order the directory + // lists them: an xor of each one's hash. + while (it.next(io) catch @panic("read build/patches")) |e| { + const sub = b.pathJoin(&.{ "build/patches", e.name }); + h ^= std.hash.Wyhash.hash(std.hash.Wyhash.hash(0, e.name), configureRead(b, io, b.root, sub, 1 << 20) catch @panic(sub)); + } + return h; +} + fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 { var names: std.ArrayList([]const u8) = .empty; var dir = b.root.root_dir.handle.openDir(io, "vendor/themes", .{ .iterate = true }) catch @panic("open vendor/themes"); @@ -593,7 +618,7 @@ pub fn assemble(b: *std.Build, c: struct { .optimize = optimize, .cloud9 = cloud9, .cfg = c.shell_cfg, - .info = buildInfo(b, c.shell_cfg), + .info = buildInfo(b, io, c.shell_cfg), .zstd = zstd, .image = image_addon.root_module, .pdf = pdf_built.module, |
