11const std = @import ("std" );
2+ const zon = @import ("build.zig.zon" );
23
34pub fn build (b : * std.Build ) ! void {
45 const target = b .standardTargetOptions (.{});
56 const optimize = b .standardOptimizeOption (.{});
6-
7- const version = getVersion (b );
87 const enable_tracy = b .option (bool , "tracy" , "Enable Tracy profiling" ) orelse false ;
8+ const version = b .option ([]const u8 , "version" , "Override the version of SuperHTML" ) orelse zon .version ;
99
1010 const tracy = b .dependency ("tracy" , .{ .enable = enable_tracy });
1111 const scripty = b .dependency ("scripty" , .{
@@ -59,8 +59,7 @@ pub fn build(b: *std.Build) !void {
5959 const scopes = b .option ([]const []const u8 , "scope" , "Enable this scope (all scopes are enabled when none is specified through this option), can be used multiple times" ) orelse &[0 ][]const u8 {};
6060 options .addOption (bool , "verbose_logging" , verbose_logging );
6161 options .addOption ([]const []const u8 , "enabled_scopes" , scopes );
62- options .addOption ([]const u8 , "version" , version .string ());
63- options .addOption (Version .Kind , "version_kind" , version );
62+ options .addOption ([]const u8 , "version" , version );
6463
6564 const folders = b .dependency ("known_folders" , .{});
6665 const lsp = b .dependency ("lsp_kit" , .{});
@@ -72,9 +71,9 @@ pub fn build(b: *std.Build) !void {
7271 setupFetchLanguageSubtagRegistryStep (b , target );
7372
7473 const release = b .step ("release" , "Create release builds of Zine" );
75- if ( version == .tag ) {
76- const zon = @import ( "build.zig.zon" );
77- if (std .mem .eql (u8 , zon . version , version .tag [1.. ])) {
74+ const git_version = getGitVersion ( b );
75+ if ( git_version == .tag ) {
76+ if (std .mem .eql (u8 , version , git_version .tag [1.. ])) {
7877 setupReleaseStep (
7978 b ,
8079 options ,
@@ -86,7 +85,7 @@ pub fn build(b: *std.Build) !void {
8685 } else {
8786 release .dependOn (& b .addFail (b .fmt (
8887 "error: git tag does not match zon package version (zon: '{s}', git: '{s}')" ,
89- .{ zon . version , version .tag [1.. ] },
88+ .{ version , git_version .tag [1.. ] },
9089 )).step );
9190 }
9291 } else {
@@ -386,7 +385,7 @@ const Version = union(Kind) {
386385 };
387386 }
388387};
389- fn getVersion (b : * std.Build ) Version {
388+ fn getGitVersion (b : * std.Build ) Version {
390389 const git_path = b .findProgram (&.{"git" }, &.{}) catch return .unknown ;
391390 var out : u8 = undefined ;
392391 const git_describe = std .mem .trim (
0 commit comments