This commit is contained in:
torque 2024-09-14 20:10:10 -07:00
commit 7e92a6b12c
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
5 changed files with 123 additions and 0 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

32
LICENSE-PROTOBUF_C Normal file
View File

@ -0,0 +1,32 @@
Copyright (c) 2008-2023, Dave Benson and the protobuf-c authors.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The code generated by the protoc-gen-c code generator and by the
protoc-c compiler is owned by the owner of the input files used when
generating it. This code is not standalone and requires a support
library to be linked with it. This support library is covered by the
above license.

29
build.zig Normal file
View File

@ -0,0 +1,29 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const upstream = b.dependency("protobuf_c", .{});
const lib = b.addStaticLibrary(.{
.name = "protobuf_c",
.target = target,
.optimize = optimize,
});
lib.linkLibC();
const src_root = upstream.path("protobuf-c");
lib.addCSourceFiles(.{
.root = src_root,
.files = &.{"protobuf-c.c"},
.flags = &.{},
});
lib.installHeader(
src_root.path(b, "protobuf-c.h"),
b.pathJoin(&.{ "protobuf-c", "protobuf-c.h" }),
);
b.installArtifact(lib);
}

18
build.zig.zon Normal file
View File

@ -0,0 +1,18 @@
.{
.name = "protobuf_c",
.version = "1.5.0",
.minimum_zig_version = "0.12.0",
.dependencies = .{
.protobuf_c = .{
.url = "git+https://github.com/protobuf-c/protobuf-c?ref=v1.5.0#8c201f6e47a53feaab773922a743091eb6c8972a",
.hash = "12205a20f38efb23d8f688ddb208047b26235608d9fde4c84ce3302ea156443c2b12",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"LICENSE",
"LICENSE-PROTOBUF_C",
"readme.md",
},
}

23
readme.md Normal file
View File

@ -0,0 +1,23 @@
# LibreSSL
This is the [protobuf-c runtime](https://github.com/protobuf-c/protobuf-c/tree/master/protobuf-c), packaged for [Zig](https://ziglang.org/).
## Installation
First, update your `build.zig.zon`:
```
# Initialize a `zig build` project if you haven't already
zig init
zig fetch --save <PLACEHOLDER>
```
You can then import `protobuf_c` in your `build.zig` with:
```zig
const protobuf_c_dependency = b.dependency("protobuf_c", .{
.target = target,
.optimize = optimize,
});
your_exe.linkLibrary(protobuf_c_dependency.artifact("protobuf_c"));
```