Skip to content

Commit 5bdc864

Browse files
committed
feat: build bchunk with zig + add gh workflow
1 parent b01026f commit 5bdc864

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
pull_request:
8+
branches: [main]
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Zig
21+
uses: mlugg/setup-zig@v2
22+
23+
- name: Run `build`
24+
run: zig build

build.zig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 bchunk = b.dependency("bchunk", .{});
8+
9+
const bchunk_mod = b.createModule(.{
10+
.target = target,
11+
.optimize = optimize,
12+
.link_libc = true,
13+
});
14+
15+
bchunk_mod.addCSourceFile(.{
16+
.file = bchunk.builder.path("bchunk.c"),
17+
});
18+
19+
const exe = b.addExecutable(.{
20+
.name = "bchunk",
21+
.root_module = bchunk_mod,
22+
});
23+
24+
b.installArtifact(exe);
25+
26+
const run_step = b.step("run", "Run the app");
27+
28+
const run_cmd = b.addRunArtifact(exe);
29+
run_step.dependOn(&run_cmd.step);
30+
31+
run_cmd.step.dependOn(b.getInstallStep());
32+
33+
if (b.args) |args| {
34+
run_cmd.addArgs(args);
35+
}
36+
}

build.zig.zon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.{
2+
.name = .bchunk,
3+
.version = "1.2.2",
4+
.fingerprint = 0xa7da89c18fac697f, // Changing this has security and trust implications.
5+
.minimum_zig_version = "0.15.1",
6+
.dependencies = .{
7+
.bchunk = .{
8+
.url = "https://github.com/hessu/bchunk/archive/refs/tags/release/1.2.2.tar.gz",
9+
.hash = "N-V-__8AAEioAACEKJ1Kyxhwk-TXBfaRBszr74whx5omexvh",
10+
},
11+
},
12+
.paths = .{
13+
"build.zig",
14+
"build.zig.zon",
15+
},
16+
}

0 commit comments

Comments
 (0)