Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattnite/zig-zlib
compile zlib in your build.zig
https://github.com/mattnite/zig-zlib
build zig zig-package zlib
Last synced: 23 days ago
JSON representation
compile zlib in your build.zig
- Host: GitHub
- URL: https://github.com/mattnite/zig-zlib
- Owner: mattnite
- License: mit
- Created: 2021-12-17T16:30:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-09T23:34:23.000Z (7 months ago)
- Last Synced: 2024-10-05T15:15:06.057Z (about 1 month ago)
- Topics: build, zig, zig-package, zlib
- Language: Zig
- Homepage:
- Size: 30.3 KB
- Stars: 21
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - zig-zlib🗒️compile zlib in your build.zig
README
# zlib build package
[![build](https://github.com/mattnite/zig-zlib/actions/workflows/build.yml/badge.svg)](https://github.com/mattnite/zig-zlib/actions/workflows/build.yml)
## Like this project?
If you like this project or other works of mine, please consider [donating to or sponsoring me](https://github.com/sponsors/mattnite) on Github [:heart:](https://github.com/sponsors/mattnite)
## 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:
```zig
const c = @cImport({
@cInclude("zlib.h");
});
```### Link and add bindings to your application
In order to statically link zlib into your application and access the bindings with a configurable import string:
```zig
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")`.
### Only link to your application
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:
```zig
lib.link(exe, .{});
```