https://github.com/allyourcodebase/libgit2
libgit2 ported to the Zig build system
https://github.com/allyourcodebase/libgit2
Last synced: 8 months ago
JSON representation
libgit2 ported to the Zig build system
- Host: GitHub
- URL: https://github.com/allyourcodebase/libgit2
- Owner: allyourcodebase
- License: mit
- Created: 2024-07-26T23:45:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-31T23:47:16.000Z (over 1 year ago)
- Last Synced: 2024-11-12T15:14:06.919Z (over 1 year ago)
- Language: Zig
- Size: 35.2 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libgit2
This is [libgit2](https://libgit2.org/) packaged using Zig's build system.
Currently only supports Windows and Linux targets.
While libgit2 supports many different options for system dependencies, I've opted to use [MbedTLS](https://www.trustedfirmware.org/projects/mbed-tls/) by default on Linux for TLS, crypto, and certificate support. You can replace MbedTLS with OpenSSL if you prefer. SSH support is optional, and is provided by [libssh2](https://libssh2.org/).
All other dependencies are bundled in the source tree and compiled statically.
## Usage
Update your `build.zig.zon`:
```sh
zig fetch --save git+https://github.com/allyourcodebase/libgit2
# or if you want a tagged release
zig fetch --save https://github.com/allyourcodebase/libgit2/archive/refs/tags/${tag}.tar.gz
```
Then, in your `build.zig`, you can access the library as a dependency:
```zig
const libgit2_dep = b.dependency("libgit2", .{
.target = target,
.optimize = optimize,
.@"enable-ssh" = true, // optional ssh support via libssh2
.@"tls-backend" = .openssl, // use openssl instead of mbedtls
});
your_compile_step.linkLibrary(libgit_dep.artifact("git2"));
```
Don't forget to import headers too:
```zig
const c = @cImport({
@cInclude("git2.h");
});
```