You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Matt Knight f42d279890 Fix build api breaks and morale (#85)
* fix build api breaks

* fix ci

* zig parser api update
7 months ago
..
.github/workflows Fix build api breaks and morale (#85) 7 months ago
src Fix build api breaks and morale (#85) 7 months ago
zlib Fix build api breaks and morale (#85) 7 months ago
.gitattributes Fix build api breaks and morale (#85) 7 months ago
.gitignore Fix build api breaks and morale (#85) 7 months ago
.gitmodules Fix build api breaks and morale (#85) 7 months ago
LICENSE Fix build api breaks and morale (#85) 7 months ago
README.md Fix build api breaks and morale (#85) 7 months ago
build.zig Fix build api breaks and morale (#85) 7 months ago
gyro.zzz Fix build api breaks and morale (#85) 7 months ago
zlib.zig Fix build api breaks and morale (#85) 7 months ago

README.md

zlib build package

build

Like this project?

If you like this project or other works of mine, please consider donating to or sponsoring me on Github ❤️

How to use

This repo contains code for your build.zig that can statically compile zlib, as well as some idiomatic Zig bindings for zlib that you can use in your application. In either case below you will be able to include zlibs header with:

const c = @cImport({
    @cInclude("zlib.h");
});

In order to statically link zlib into your application and access the bindings with a configurable import string:

const zlib = @import("path/to/zlib.zig");

pub fn build(b: *std.build.Builder) void {
    // ...

    const lib = zlib.create(b, target, mode);

    const exe = b.addExecutable("my-program", "src/main.zig");
    lib.link(exe, .{ .import_name = "zlib" });
}

Now code that is part of the my-program executable can import the zlib bindings with @import("zlib").

In order to just link to the application, all you need to do is omit the .import_name = "zlib" argument to zlib's link options:

    lib.link(exe, .{});