Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vrischmann committed Dec 20, 2024
0 parents commit 2923f4d
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/zig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI - Zig

on:
create:
push:
branches: master
pull_request:
schedule:
- cron: "0 18 * * *"
workflow_dispatch:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
- run: zig fmt --check .
- run: zig build
- run: zig build test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.zig-cache
69 changes: 69 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const upstream = b.dependency("upstream", .{
.target = target,
.optimize = optimize,
});

const lib = b.addStaticLibrary(.{
.name = "picohttpparser",
.target = target,
.optimize = optimize,
});
lib.addIncludePath(b.path("."));
lib.linkLibC();
lib.addCSourceFiles(.{
.root = upstream.path("."),
.files = &[_][]const u8{
"picohttpparser.c",
},
.flags = &[_][]const u8{
"-Wall", "-fsanitize=address,undefined",
},
});
lib.installHeader(upstream.path("picohttpparser.h"), "picohttpparser.h");

b.installArtifact(lib);

// Tests

const picotest = b.dependency("picotest", .{
.target = target,
.optimize = optimize,
});

const tests = b.addExecutable(.{
.name = "test-bin",
.target = target,
.optimize = optimize,
});
tests.linkLibrary(lib);
tests.addIncludePath(upstream.path("."));
tests.addIncludePath(picotest.path("."));
tests.addCSourceFiles(.{
.root = picotest.path("."),
.files = &[_][]const u8{
"picotest.c",
},
.flags = &[_][]const u8{
"-Wall", "-fsanitize=address,undefined",
},
});
tests.addCSourceFiles(.{
.root = upstream.path("."),
.files = &[_][]const u8{
"test.c",
},
.flags = &[_][]const u8{
"-Wall", "-fsanitize=address,undefined",
},
});

const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run the tests");
test_step.dependOn(&run_tests.step);
}
20 changes: 20 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.{
.name = "picohttpparser",
.version = "0.0.0",
.dependencies = .{
.upstream = .{
.url = "git+https://github.com/h2o/picohttpparser?ref=master#f8d0513f1a7a111f2597d643b073935a8afaf9e5",
.hash = "1220783b493dce554f478bef55bdd94acd7dbb753dc8bc17dc2fbc57709b2a8a0909",
},
.picotest = .{
.url = "git+https://github.com/h2o/picotest?ref=master#a99858e0c33b97b24cd09ceae729f2be33ec01e1",
.hash = "1220d93e9c4cfccdc0bf3ea0c30f85785f8e7e0e0096b1d2fe16a9713b7261667c33",
},
},
.minimum_zig_version = "0.13.0",

.paths = .{
"build.zig",
"build.zig.zon",
},
}

0 comments on commit 2923f4d

Please sign in to comment.