Merge pull request #618 from Techatrix/report-version

Report zls version using git describe
This commit is contained in:
Auguste Rame 2022-09-02 01:47:54 -04:00 committed by GitHub
commit 34ce200b2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0
submodules: true submodules: true
- uses: goto-bus-stop/setup-zig@v1 - uses: goto-bus-stop/setup-zig@v1
with: with:

View File

@ -43,6 +43,15 @@ pub fn build(b: *std.build.Builder) !void {
b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse false, b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse false,
); );
const version = v: {
const git_describe_untrimmed = try b.exec(&[_][]const u8{
"git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags",
});
break :v std.mem.trim(u8, git_describe_untrimmed, " \n\r");
};
exe_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
const KNOWN_FOLDERS_DEFAULT_PATH = "src/known-folders/known-folders.zig"; const KNOWN_FOLDERS_DEFAULT_PATH = "src/known-folders/known-folders.zig";
const known_folders_path = b.option([]const u8, "known-folders", "Path to known-folders package (default: " ++ KNOWN_FOLDERS_DEFAULT_PATH ++ ")") orelse KNOWN_FOLDERS_DEFAULT_PATH; const known_folders_path = b.option([]const u8, "known-folders", "Path to known-folders package (default: " ++ KNOWN_FOLDERS_DEFAULT_PATH ++ ")") orelse KNOWN_FOLDERS_DEFAULT_PATH;
exe.addPackage(.{ .name = "known-folders", .source = .{ .path = known_folders_path } }); exe.addPackage(.{ .name = "known-folders", .source = .{ .path = known_folders_path } });

View File

@ -192,7 +192,7 @@ fn parseArgs(
return .exit; return .exit;
} }
if (specified.get(.version)) { if (specified.get(.version)) {
try std.io.getStdOut().writer().print("Data Version: {s}\n", .{@tagName(build_options.data_version)}); try std.io.getStdOut().writeAll(build_options.version ++ "\n");
return .exit; return .exit;
} }
if (specified.get(.config)) { if (specified.get(.config)) {