diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 12 |
1 files changed, 3 insertions, 9 deletions
| @@ -3,21 +3,15 @@ const std = @import("std"); | |||
| 3 | 3 | ||
| 4 | const Build = std.Build; | 4 | const Build = std.Build; |
| 5 | const SemanticVersion = std.SemanticVersion; | 5 | const SemanticVersion = std.SemanticVersion; |
| 6 | const Version = std.builtin.Version; | ||
| 7 | 6 | ||
| 8 | pub fn build(b: *Build) void { | 7 | pub fn build(b: *Build) void { |
| 9 | const target = b.standardTargetOptions(.{}); | 8 | const target = b.standardTargetOptions(.{}); |
| 10 | const optimize = b.standardOptimizeOption(.{}); | 9 | const optimize = b.standardOptimizeOption(.{}); |
| 11 | 10 | ||
| 12 | const semanticVersion = getSemanticVersion(b); | 11 | const version = getVersion(b); |
| 13 | const version = Version{ | ||
| 14 | .major = @intCast(u32, semanticVersion.major), | ||
| 15 | .minor = @intCast(u32, semanticVersion.minor), | ||
| 16 | .patch = @intCast(u32, semanticVersion.patch), | ||
| 17 | }; | ||
| 18 | 12 | ||
| 19 | const config = b.addOptions(); | 13 | const config = b.addOptions(); |
| 20 | config.addOption(SemanticVersion, "version", semanticVersion); | 14 | config.addOption(SemanticVersion, "version", version); |
| 21 | 15 | ||
| 22 | const exe = b.addExecutable(.{ | 16 | const exe = b.addExecutable(.{ |
| 23 | .name = "zup", | 17 | .name = "zup", |
| @@ -59,7 +53,7 @@ pub fn build(b: *Build) void { | |||
| 59 | 53 | ||
| 60 | const default_version = SemanticVersion.parse("0.2.1") catch unreachable; | 54 | const default_version = SemanticVersion.parse("0.2.1") catch unreachable; |
| 61 | 55 | ||
| 62 | fn getSemanticVersion(b: *Build) SemanticVersion { | 56 | fn getVersion(b: *Build) SemanticVersion { |
| 63 | var out_code: u8 = undefined; | 57 | var out_code: u8 = undefined; |
| 64 | const untrimmed = b.execAllowFail( | 58 | const untrimmed = b.execAllowFail( |
| 65 | &.{ "git", "-C", b.build_root.path.?, "describe", "--tags" }, | 59 | &.{ "git", "-C", b.build_root.path.?, "describe", "--tags" }, |