fixup! init
Some checks are pending
CI / build (macos-latest, 0.13.0) (push) Waiting to run
CI / build (true, ubuntu-latest, master) (push) Waiting to run
CI / build (ubuntu-latest, 0.12.1) (push) Waiting to run
CI / build (ubuntu-latest, 0.13.0) (push) Waiting to run
CI / build (windows-latest, 0.13.0) (push) Waiting to run

This commit is contained in:
torque 2024-09-15 19:43:40 -07:00
parent aeb3b30e36
commit 32de7d35d9
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
4 changed files with 85 additions and 11 deletions

40
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,40 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
zig-version: ["0.13.0"]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- zig-version: "0.12.1"
os: ubuntu-latest
- zig-version: "master"
check-format: true
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ matrix.zig-version }}
- if: ${{ matrix.check-format }}
name: Check Formatting
run: zig fmt --ast-check --check .
- name: Build
run: zig build --summary all

View File

@ -24,9 +24,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize, .optimize = optimize,
}); });
const cflags: []const []const u8 = &.{ const cflags: []const []const u8 = &.{};
"-fno-sanitize=undefined",
};
const src_root = upstream.path("src"); const src_root = upstream.path("src");
@ -76,7 +74,7 @@ pub fn build(b: *std.Build) void {
for (install_headers) |header| { for (install_headers) |header| {
lib.installHeader( lib.installHeader(
src_root.path(b, header), upstream.path(b.pathJoin(&.{ "src", header })),
b.pathJoin(&.{ "nats", header }), b.pathJoin(&.{ "nats", header }),
); );
} }

View File

@ -10,10 +10,12 @@
.libressl = .{ .libressl = .{
.url = "git+https://github.com/allyourcodebase/libressl.git?ref=3.9.2#a373b82991947b694196ee630bd6a648d71e2b3f", .url = "git+https://github.com/allyourcodebase/libressl.git?ref=3.9.2#a373b82991947b694196ee630bd6a648d71e2b3f",
.hash = "1220b1536d43ed8ce79ee05c53929f90b67dd299e61dfa249fa8f476f17eee46a95f", .hash = "1220b1536d43ed8ce79ee05c53929f90b67dd299e61dfa249fa8f476f17eee46a95f",
.lazy = true,
}, },
.protobuf_c = .{ .protobuf_c = .{
.url = "git+https://github.com/allyourcodebase/protobuf-c.git?ref=1.5.0#ae7587481485e615d3866861703d41d3efc22b82", .url = "git+https://github.com/allyourcodebase/protobuf-c.git?ref=1.5.0#ae7587481485e615d3866861703d41d3efc22b82",
.hash = "1220f454bf9412333c5d21b8c21b323fc7e4e37b02341bf2fa49f110b8bc5d97c972", .hash = "1220f454bf9412333c5d21b8c21b323fc7e4e37b02341bf2fa49f110b8bc5d97c972",
.lazy = true,
}, },
}, },
.paths = .{ .paths = .{

View File

@ -1,23 +1,57 @@
# LibreSSL # NATS.c
This is the [NATS C client library](https://github.com/nats-io/nats.c), packaged for [Zig](https://ziglang.org/). This is the [NATS C client library][nats.c], packaged for [Zig](https://ziglang.org/).
## Installation ## Status
This library only explicitly supports Linux, macOS, and Windows operating systems. Building for other platforms is currently untested, so your mileage may vary.
## Zig Bindings
The following projects provide zig language bindings to the NATS.c library:
- [`epicyclic-dev/nats-client`][epicyclic-dev-bindings]
## Usage
First, update your `build.zig.zon`: First, update your `build.zig.zon`:
``` ```sh
# Initialize a `zig build` project if you haven't already # Initialize a `zig build` project if you haven't already
zig init zig init
zig fetch --save <PLACEHOLDER> # replace <refname> with the version you want to use, e.g. 3.8.2
zig fetch --save git+https://github.com/allyourcodebase/protobuf-c#<refname>
``` ```
You can then import `nats_c` in your `build.zig` with: You can then import `nats_c` in your `build.zig` with:
```zig ```zig
const nats_c_dependency = b.dependency("nats_c", .{ const nats_c_dep = b.dependency("nats_c", .{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.@"enable-tls" = true, // enable SSL/TLS support
.@"force-host-verify" = true, // force hostname verification for TLS connections
.@"enable-streaming" = true, // build with support for NATS streaming extensions
}); });
your_exe.linkLibrary(nats_c_dependency.artifact("nats_c")); your_exe.linkLibrary(nats_c_dep.artifact("nats_c"));
``` ```
## Dependencies
The NATS.c library has two optional dependencies:
- [`libressl`][libressl] when building with `enable-tls`
- [`protobuf-c`][protobuf-c] when building with `enable-streaming`
These dependencies are currently automatically retrieved and compiled as static libraries by the zig build system.
## Version Support Matrix
| Refname | NATS.c Version | Zig `0.12.x` | Zig `0.13.x` | Zig `0.14.0-dev` |
|----------|----------------|--------------|--------------|------------------|
| `3.8.2` | `3.8.2` | ✅ | ✅ | ✅ |
[nats.c]: https://github.com/nats-io/nats.c
[libressl]: https://github.com/allyourcodebase/libressl
[protobuf-c]: https://github.com/allyourcodebase/protobuf-c
[epicyclic-dev-bindings]: https://github.com/epicyclic-dev/nats-client