Skip to content

Commit 2923f4d

Browse files
committed
initial commit
0 parents  commit 2923f4d

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

.github/workflows/zig.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI - Zig
2+
3+
on:
4+
create:
5+
push:
6+
branches: master
7+
pull_request:
8+
schedule:
9+
- cron: "0 18 * * *"
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: goto-bus-stop/setup-zig@v2
22+
- run: zig fmt --check .
23+
- run: zig build
24+
- run: zig build test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.zig-cache

build.zig

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
const optimize = b.standardOptimizeOption(.{});
6+
7+
const upstream = b.dependency("upstream", .{
8+
.target = target,
9+
.optimize = optimize,
10+
});
11+
12+
const lib = b.addStaticLibrary(.{
13+
.name = "picohttpparser",
14+
.target = target,
15+
.optimize = optimize,
16+
});
17+
lib.addIncludePath(b.path("."));
18+
lib.linkLibC();
19+
lib.addCSourceFiles(.{
20+
.root = upstream.path("."),
21+
.files = &[_][]const u8{
22+
"picohttpparser.c",
23+
},
24+
.flags = &[_][]const u8{
25+
"-Wall", "-fsanitize=address,undefined",
26+
},
27+
});
28+
lib.installHeader(upstream.path("picohttpparser.h"), "picohttpparser.h");
29+
30+
b.installArtifact(lib);
31+
32+
// Tests
33+
34+
const picotest = b.dependency("picotest", .{
35+
.target = target,
36+
.optimize = optimize,
37+
});
38+
39+
const tests = b.addExecutable(.{
40+
.name = "test-bin",
41+
.target = target,
42+
.optimize = optimize,
43+
});
44+
tests.linkLibrary(lib);
45+
tests.addIncludePath(upstream.path("."));
46+
tests.addIncludePath(picotest.path("."));
47+
tests.addCSourceFiles(.{
48+
.root = picotest.path("."),
49+
.files = &[_][]const u8{
50+
"picotest.c",
51+
},
52+
.flags = &[_][]const u8{
53+
"-Wall", "-fsanitize=address,undefined",
54+
},
55+
});
56+
tests.addCSourceFiles(.{
57+
.root = upstream.path("."),
58+
.files = &[_][]const u8{
59+
"test.c",
60+
},
61+
.flags = &[_][]const u8{
62+
"-Wall", "-fsanitize=address,undefined",
63+
},
64+
});
65+
66+
const run_tests = b.addRunArtifact(tests);
67+
const test_step = b.step("test", "Run the tests");
68+
test_step.dependOn(&run_tests.step);
69+
}

build.zig.zon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.{
2+
.name = "picohttpparser",
3+
.version = "0.0.0",
4+
.dependencies = .{
5+
.upstream = .{
6+
.url = "git+https://github.com/h2o/picohttpparser?ref=master#f8d0513f1a7a111f2597d643b073935a8afaf9e5",
7+
.hash = "1220783b493dce554f478bef55bdd94acd7dbb753dc8bc17dc2fbc57709b2a8a0909",
8+
},
9+
.picotest = .{
10+
.url = "git+https://github.com/h2o/picotest?ref=master#a99858e0c33b97b24cd09ceae729f2be33ec01e1",
11+
.hash = "1220d93e9c4cfccdc0bf3ea0c30f85785f8e7e0e0096b1d2fe16a9713b7261667c33",
12+
},
13+
},
14+
.minimum_zig_version = "0.13.0",
15+
16+
.paths = .{
17+
"build.zig",
18+
"build.zig.zon",
19+
},
20+
}

0 commit comments

Comments
 (0)