init
This commit is contained in:
commit
92342d6d8c
21
LICENSE
Normal file
21
LICENSE
Normal 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
32
LICENSE-PROTOBUF_C
Normal 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
29
build.zig
Normal 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();
|
||||||
|
|
||||||
|
lib.addCSourceFiles(.{
|
||||||
|
.root = upstream.path("protobuf-c"),
|
||||||
|
.files = &.{"protobuf-c.c"},
|
||||||
|
.flags = &.{},
|
||||||
|
});
|
||||||
|
|
||||||
|
lib.installHeader(
|
||||||
|
upstream.path("protobuf-c/protobuf-c.h"),
|
||||||
|
b.pathJoin(&.{ "protobuf-c", "protobuf-c.h" }),
|
||||||
|
);
|
||||||
|
|
||||||
|
b.installArtifact(lib);
|
||||||
|
}
|
18
build.zig.zon
Normal file
18
build.zig.zon
Normal 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",
|
||||||
|
},
|
||||||
|
}
|
30
readme.md
Normal file
30
readme.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# `protobuf-c` Runtime
|
||||||
|
|
||||||
|
This is the [protobuf-c runtime](https://github.com/protobuf-c/protobuf-c/tree/master/protobuf-c), packaged for [Zig](https://ziglang.org/).
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
This project only builds the `protobuf-c` runtime library. It does not build `protoc-c`, the corresponding protocol buffers C language code generator.
|
||||||
|
|
||||||
|
The runtime library depends only on a small amount of functionality from libc, so it should compile for most targets. Linux, macOS and Windows are tested by CI.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
First, update your `build.zig.zon`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Initialize a `zig build` project if you haven't already
|
||||||
|
zig init
|
||||||
|
# replace <refname> with the version you want to use, e.g. 1.5.0
|
||||||
|
zig fetch --save git+https://github.com/allyourcodebase/protobuf-c#<refname>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then use `protobuf_c` in your `build.zig` with:
|
||||||
|
|
||||||
|
```zig
|
||||||
|
const protobuf_c_dep = b.dependency("protobuf_c", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
your_exe.linkLibrary(protobuf_c_dep.artifact("protobuf_c"));
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user