Skip to content

godsarmy/libversion-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libversion-zig

This package is a thin wrapper around libversion's C API. Its release version is in synchronization with libversion release.

Installation

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"));

Usage

  • Import libversion-zig like this:
    const libversion = @import("libversion");
  • Call Functions in 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.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. 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.

Development & Build

  • Install Zig 0.14.
  • Clone project by git.
  • In project workspace, run build/test by zig command.
    zig build test

About

libversion-zig is a small wrapper around libversion C API, making it easier to use with Zig.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages