https://github.com/godsarmy/libversion-zig
libversion-zig is a small wrapper around libversion C API, making it easier to use with Zig.
https://github.com/godsarmy/libversion-zig
libversion zig
Last synced: 5 months ago
JSON representation
libversion-zig is a small wrapper around libversion C API, making it easier to use with Zig.
- Host: GitHub
- URL: https://github.com/godsarmy/libversion-zig
- Owner: godsarmy
- License: mit
- Created: 2025-04-02T04:57:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-12T13:45:41.000Z (about 1 year ago)
- Last Synced: 2025-04-12T14:41:20.447Z (about 1 year ago)
- Topics: libversion, zig
- Language: Zig
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libversion-zig
This package is a thin wrapper around [libversion](https://github.com/repology/libversion)'s C API.
Its release version is in synchronization with [libversion release](https://github.com/repology/libversion/releases).
# Installation
```sh
zig fetch --save git+https://github.com/godsarmy/libversion-zig
```
Now in your build.zig you can access the module like this:
```zig
const libversion = b.dependency("libversion", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("libversion", libversion.module("libversion"));
```
# Usage
- Import `libversion-zig` like this:
```zig
const libversion = @import("libversion");
```
- Call Functions in `libversion-zig`
```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.flag.VERSIONFLAG_P_IS_PATCH,
libversion.flag.VERSIONFLAG_P_IS_PATCH,
); // return 1
_ = libverison.versionCompare4(
"1.0p1",
"1.0patch1",
libversion.flag.VERSIONFLAG_P_IS_PATCH,
libversion.flag.VERSIONFLAG_P_IS_PATCH,
); // return 0
_ = libversion.versionCompare4(
"1.0p1",
"1.0post1",
libversion.flag.VERSIONFLAG_P_IS_PATCH,
libversion.flag.VERSIONFLAG_P_IS_PATCH,
); // return 0
```
# Zig Release support
`libversion-zig` keeps track the specification of latest [stable version of Zig](https://ziglang.org/download/).
Currently, it can only be built by [Zig 0.15](https://ziglang.org/download/0.15.1/release-notes.html).
The plan is to support releases once Zig 1.0 is released but this can still change.
# Development & Build
- Install [Zig 0.15.2](https://ziglang.org/download/#release-0.15.2).
- Clone project by git.
- In project workspace, run build/test by `zig` command.
```sh
zig build test
```