godsarmy/libversion-zig
libversion-zig is a small wrapper around libversion C API, making it easier to use with Zig.
This package is a thin wrapper around libversion's C API. Its release version is in synchronization with libversion release.
zig fetch --save git+https://github.com/godsarmy/libversion-zig
Now in your build.zig you can access the module like this:
const libversion = b.dependency("libversion", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("libversion", libversion.module("libversion"));
libversion-zig
like this:const libversion = @import("libversion");
libversion-zig
// execute versionCompare2
_ = libversion.versionCompare2("1.0", "1.1"); // return -1
_ = libversion.versionCompare2("2.0", "1.9"); // return 1
_ = libversion.versionCompare2("2.0", "2.0"); // return 0
// execute versionCompare4
_ = libversion.versionCompare4(
"1.0p1",
"1.0pre1",
libversion.flags.VERSIONFLAG_P_IS_PATCH,
libversion.flags.VERSIONFLAG_P_IS_PATCH,
); // return 1
_ = libverison.versionCompare4(
"1.0p1",
"1.0patch1",
libversion.flags.VERSIONFLAG_P_IS_PATCH,
libversion.flags.VERSIONFLAG_P_IS_PATCH,
); // return 0
_ = libversion.versionCompare4(
"1.0p1",
"1.0post1",
libversion.flags.VERSIONFLAG_P_IS_PATCH,
libversion.flags.VERSIONFLAG_P_IS_PATCH,
); // return 0
libversion-zig
keeps track the specification of latest stable version of Zig.
Currently, it can only be built by Zig 0.14.
The plan is to support releases once Zig 1.0 is released but this can still change.
zig
command.zig build test