summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig16
1 files changed, 13 insertions, 3 deletions
diff --git a/build.zig b/build.zig
index c6f9dc2a..620eb19b 100644
--- a/build.zig
+++ b/build.zig
@@ -6,6 +6,12 @@ const grammar_manifest = @import("src/grammar_manifest.zig");
/// The package manifest, imported UNTYPED on purpose — see the `version`
/// option in `shellOptions` for why that word is load-bearing.
const zon = @import("build.zig.zon");
+/// Releases are numbered 0.N; the zon holds "0.N.0" because it must be semver,
+/// and what a user sees drops that ".0".
+const display_version = if (std.mem.endsWith(u8, zon.version, ".0") and std.mem.count(u8, zon.version, ".") == 2)
+ zon.version[0 .. zon.version.len - 2]
+else
+ zon.version;
pub const Platform = enum { tty, gui, web, macos, esp32p4 };
@@ -179,7 +185,11 @@ pub fn build(b: *std.Build) void {
if (!is_web and (is_web_target or target.result.os.tag == .emscripten)) return failBuild(b, web_step, "wasm browser targets require -Dplatform=web");
if (platform == .web and dump_path == null) return failBuild(b, web_step, "-Dplatform=web requires -Ddump=<dump.zon> (the browser has no ptys; state replays from an embedded dump)");
if (enable_mupdf and is_web) return failBuild(b, web_step, "-Dmupdf=true is supported only by the native tty/Kitty and gui/SDL backends");
- if (is_esp32p4 and !is_esp32p4_target) return failBuild(b, web_step, "-Dplatform=esp32p4 requires -Dtarget=riscv32-freestanding (ESP32-P4 firmware)");
+ // The board's target is pinned (`target` above), so what is asked of
+ // -Dtarget is checked, not what was resolved: another arch is refused,
+ // not silently built for the board anyway.
+ const requested_board = requested_target.result.cpu.arch == .riscv32 and requested_target.result.os.tag == .freestanding;
+ if (is_esp32p4 and !requested_board) return failBuild(b, web_step, "-Dplatform=esp32p4 requires -Dtarget=riscv32-freestanding (ESP32-P4 firmware)");
if (enable_mupdf and is_esp32p4) return failBuild(b, web_step, "-Dmupdf=true is supported only by the native tty/Kitty and gui/SDL backends");
if (is_esp32p4 and requested_grammars != null and requested_grammars.? != .disabled) return failBuild(b, web_step, "-Dplatform=esp32p4 has no tree-sitter: the grammars' parse tables are megabytes and the flash partition is 1.5 MiB (-Dtree-sitter=disabled)");
@@ -1146,7 +1156,7 @@ pub fn build(b: *std.Build) void {
plist.addFileArg(b.path("src/macos/Info.plist"));
const version_plist = b.addSystemCommand(&.{
- "plutil", "-replace", "CFBundleShortVersionString", "-string", zon.version, "-o",
+ "plutil", "-replace", "CFBundleShortVersionString", "-string", display_version, "-o",
});
const version_plist_out = version_plist.addOutputFileArg("Info.plist");
version_plist.addFileArg(plist_out);
@@ -1873,7 +1883,7 @@ fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build.
o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (platform != .macos));
o.addOption(bool, "theme_animation", cfg.theme_animation orelse (platform != .esp32p4));
o.addOption(bool, "embed_sources", cfg.embed_sources);
- o.addOption([]const u8, "version", zon.version);
+ o.addOption([]const u8, "version", display_version);
// ...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);