From 60f954c2b076a4670432167c51f43d2cdd361e7d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 10 Mar 2025 08:17:17 +0100 Subject: [PATCH] build: eliminate duplicate version string There is now a single source of truth for river's version. It is no longer possible for the versions in build.zig and build.zig.zon to get out of sync as build.zig now parses the version from build.zig.zon. --- build.zig | 34 ++++++++++++++++++++++++++++------ build.zig.zon | 5 +++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/build.zig b/build.zig index 585d7f5..8bdd5ce 100644 --- a/build.zig +++ b/build.zig @@ -6,12 +6,6 @@ const mem = std.mem; const Scanner = @import("wayland").Scanner; -/// While a river release is in development, this string should contain the version in development -/// with the "-dev" suffix. -/// When a release is tagged, the "-dev" suffix should be removed for the commit that gets tagged. -/// Directly after the tagged commit, the version should be bumped and the "-dev" suffix added. -const version = "0.3.8-dev"; - pub fn build(b: *Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); @@ -291,3 +285,31 @@ pub fn build(b: *Build) !void { test_step.dependOn(&run_globber_test.step); } } + +const version = manifest.version; +/// Getting rid of this wart requires upstream zig improvements. +/// See: https://github.com/ziglang/zig/issues/22775 +const manifest: struct { + name: @Type(.enum_literal), + version: []const u8, + paths: []const []const u8, + dependencies: struct { + pixman: struct { + url: []const u8, + hash: []const u8, + }, + wayland: struct { + url: []const u8, + hash: []const u8, + }, + wlroots: struct { + url: []const u8, + hash: []const u8, + }, + xkbcommon: struct { + url: []const u8, + hash: []const u8, + }, + }, + fingerprint: u64, +} = @import("build.zig.zon"); diff --git a/build.zig.zon b/build.zig.zon index e2ccaf0..6d5cf21 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,10 @@ .{ .name = .river, + // While a river release is in development, this string should contain + // the version in development with the "-dev" suffix. + // When a release is tagged, the "-dev" suffix should be removed for the + // commit that gets tagged. Directly after the tagged commit, the version + // should be bumped and the "-dev" suffix added. .version = "0.3.9-dev", .paths = .{""}, .dependencies = .{