summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 23:19:01 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitf33e4bfc32de821df5fa15fbae3da73b341d5890 (patch)
tree6be2b5d7d16f982a5be19e730a33dfd08d7de907
parent4c30f231a6dc57adde8ae7390cd656ddc6210c8a (diff)
downloadpardes-f33e4bfc32de821df5fa15fbae3da73b341d5890.tar.gz
pardes-f33e4bfc32de821df5fa15fbae3da73b341d5890.zip
Only kept builds carry the commit, so a jj new rebuilds nothing
The git commit sat in the options module every binary imports, so each HEAD move (jj new, jj commit) recompiled every test and snapshot binary: measured 24.4 s and +0.6 GB of .zig-cache for test-build -Dplatform=tty after one no-op HEAD move. Now -Dstamp-commit decides, defaulting to on for release builds and the bare zig build that installs into ~/.local; every other Debug build prints `pardes <version>` alone. After: 0.21 s, +0 bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--build.zig19
1 files changed, 15 insertions, 4 deletions
diff --git a/build.zig b/build.zig
index a78cd442..3c1447eb 100644
--- a/build.zig
+++ b/build.zig
@@ -60,7 +60,8 @@ pub fn build(b: *std.Build) void {
const requested_platform = b.option(Platform, "platform", "which shell to build (tty, gui, web, macos, esp32p4); absent builds the tty cli and the SDL gui together");
const platform = requested_platform orelse .tty;
const also_gui = requested_platform == null;
- if (also_gui and prefixIsUntouched(b)) {
+ const home_install = also_gui and prefixIsUntouched(b);
+ if (home_install) {
if (b.graph.environ_map.get("HOME")) |home| {
b.resolveInstallPrefix(b.pathJoin(&.{ home, ".local" }), .{});
std.debug.print("pardes: installing into {s} (override with --prefix)\n", .{b.install_prefix});
@@ -311,6 +312,16 @@ pub fn build(b: *std.Build) void {
// The macOS shell carries the workspace tag row's commands in its native
// menu bar; the row itself goes away. `-Dworkspace-tag=true` puts it back.
const workspace_tag = b.option(bool, "workspace-tag", "draw the workspace tag row (default: on except on macOS, whose menu bar carries its commands)");
+ // The commit is a build input: every `jj new` or `jj commit` moves HEAD,
+ // changes the options module and so recompiles every binary that imports
+ // it, which is all of them (~0.6 GB of fresh test objects per move). Only
+ // builds someone keeps are stamped: release builds and the bare
+ // `zig build` that installs into ~/.local. Every other Debug build (any
+ // -Dplatform or --prefix, so every test and snapshot run) prints
+ // `pardes <version>` alone, like a tarball build; -Dstamp-commit=true
+ // stamps one anyway.
+ const stamp_commit = b.option(bool, "stamp-commit", "embed the git commit in --version and crash records (default: release builds and the ~/.local install)") orelse
+ (optimize != .Debug or home_install);
const shell_cfg: ShellConfig = .{
.tree_sitter_grammars = tree_sitter_grammars,
.tracy = tracy != null,
@@ -323,7 +334,7 @@ pub fn build(b: *std.Build) void {
.prebuilt_shaders = prebuilt_shaders,
.embed_sources = embed_sources,
.zig_lib_dir = b.graph.zig_lib_directory.path orelse "",
- .commit = gitCommit(b),
+ .commit = if (stamp_commit) gitCommit(b) else null,
};
const opts = shellOptions(b, shell_cfg, platform);
const gui_opts: ?*std.Build.Step.Options = if (also_gui) shellOptions(b, shell_cfg, .gui) else null;
@@ -1607,8 +1618,8 @@ fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build.
o.addOption([]const u8, "zls_version", if (cfg.zls_backend) zls_version else "none");
o.addOption(bool, "embed_sources", cfg.embed_sources);
o.addOption([]const u8, "version", zon.version);
- // ...and the commit it was built from, when there is one. See `gitCommit`
- // for why this is optional and why it is read at configure time.
+ // ...and the commit it was built from, when there is one and the build
+ // is stamped at all (see `stamp_commit`). Read at configure time.
o.addOption(?[]const u8, "commit", cfg.commit);
o.addOption([]const u8, "zig_lib_dir", cfg.zig_lib_dir);
return o;