Skip to content

Commit

Permalink
fix: BuildOptions.version is hardcoded std.SemanticVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed May 14, 2024
1 parent 1354888 commit cb93e69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
21 changes: 2 additions & 19 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const BuzzGCOptions = struct {
};

const BuzzBuildOptions = struct {
version: []const u8,
version: std.SemanticVersion,
sha: []const u8,
mimalloc: bool,
debug: BuzzDebugOptions,
Expand Down Expand Up @@ -111,24 +111,7 @@ pub fn build(b: *Build) !void {
var build_options = BuzzBuildOptions{
.target = target,
// Version is latest tag or empty string
.version = std.mem.trim(
u8,
(std.ChildProcess.run(.{
.allocator = b.allocator,
.argv = &.{
"git",
"describe",
"--tags",
"--abbrev=0",
},
.cwd = b.pathFromRoot("."),
.expand_arg0 = .expand,
}) catch {
std.debug.print("Warning: failed to get git HEAD", .{});
unreachable;
}).stdout,
"\n \t",
),
.version = std.SemanticVersion{ .major = 0, .minor = 4, .patch = 0 },
// Current commit sha
.sha = std.posix.getenv("GIT_SHA") orelse
std.posix.getenv("GITHUB_SHA") orelse std.mem.trim(
Expand Down
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ else

fn printBanner(out: std.fs.File.Writer, full: bool) void {
out.print(
"\n👨‍🚀 buzz {s}-{s} Copyright (C) 2021-present Benoit Giannangeli\n",
"\n👨‍🚀 buzz {}-{s} Copyright (C) 2021-present Benoit Giannangeli\n",
.{
if (BuildOptions.version.len > 0) BuildOptions.version else "unreleased",
BuildOptions.version,
BuildOptions.sha,
},
) catch unreachable;
Expand Down
4 changes: 2 additions & 2 deletions src/repl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const Scanner = @import("Scanner.zig");

pub fn printBanner(out: std.fs.File.Writer, full: bool) void {
out.print(
"\n👨‍🚀 buzz {s}-{s} Copyright (C) 2021-present Benoit Giannangeli\n",
"\n👨‍🚀 buzz {}-{s} Copyright (C) 2021-present Benoit Giannangeli\n",
.{
if (BuildOptions.version.len > 0) BuildOptions.version else "unreleased",
BuildOptions.version,
BuildOptions.sha,
},
) catch unreachable;
Expand Down

0 comments on commit cb93e69

Please sign in to comment.