Ghext
is a small library that pulls HEAD hashes from git repositories. Deploy it as a regular library or use it within build.zig
.
libgit2
or its bindings would be a heavy dependency. This library is light and capable of delivering even without git
installed (MO builds, very edgy cases, etc.).
I wanted to see if I could drop heap allocations before the upcoming release, but after figuring out the build system usage, it became less relevant, so probably later.
build.zig
:
const build_options = b.addOptions();
exe.root_module.addOptions("build_options", build_options);
build_options.addOption([]const u8, "head_hash", try hash());
inline fn hash() ![]const u8 {
const gxt = @import("ghext").Ghext.read(std.heap.page_allocator) catch unreachable;
return gxt.hash;
}
app.zig
:
const build_options = @import("build_options");
const hash = build_options.head_hash[0..7];
Any feedback is appreciated!
Cheers!!