kcleal / zights

htslib for the zig build system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zights

This is htslib v1.19.1 packaged for the zig build system (v0.12.0-dev).

Uses zig cc to compile hstlib as a static library, no Makefile or configure is needed.

System requirements are libraries bz2, lzma, curl

Usage

Use htslib in zig by using cImport and including the relevant header files:

const hts = @cImport({
    @cInclude("hts.h");
    @cInclude("sam.h");
});

pub fn main() void {
    const f: *hts.htsFile = hts.hts_open("a.bam", "r").?;
    _ = f;
}

Add this snippet to your build.zig file:

const zights = b.dependency("zights", .{
    .target = target,
});
your_build.addIncludePath(zights.path("htslib/htslib"));
your_build.addIncludePath(zights.path("htslib/cram"));
your_build.linkLibrary(zights.artifact("hts"));

Also, don't forget to add zights to the dependencies in your build.zig.zon file:

zig fetch --save https://github.com/kcleal/zights/archive/refs/tags/v0.0.1.tar.gz

About

htslib for the zig build system

License:Other


Languages

Language:Zig 100.0%