report zls version using git describe

This commit is contained in:
Techatrix 2022-09-01 15:42:15 +02:00
parent da03c81992
commit 66b35d62b2
2 changed files with 10 additions and 1 deletions

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)) {