Skip to content

Commit 6ef7164

Browse files
committed
feat(build): add initial build.zig
Targets Zig 0.16. Upstreamed from Neovim; currently only supports compiling and installing the library.
1 parent 7e43ffb commit 6ef7164

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: test
22
on:
33
push:
4+
branches:
5+
- 'master'
46
pull_request:
7+
branches:
8+
- 'master'
59
workflow_dispatch:
610

711
permissions:
@@ -50,3 +54,21 @@ jobs:
5054
5155
- name: Run tests
5256
run: ctest --test-dir build --output-on-failure
57+
58+
linux-zig:
59+
runs-on: ubuntu-latest
60+
timeout-minutes: 15
61+
steps:
62+
- uses: actions/checkout@v7.0.0
63+
with:
64+
persist-credentials: false
65+
66+
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1
67+
with:
68+
version: 0.16.0
69+
70+
- name: Install dependencies
71+
run: sudo apt --update install build-essential libncurses-dev cmake
72+
73+
- name: Build
74+
run: zig build

‎build.zig‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
var unibilium = b.createModule(.{
8+
.target = target,
9+
.optimize = optimize,
10+
.link_libc = true,
11+
});
12+
13+
const lib: *std.Build.Step.Compile = b.addLibrary(.{
14+
.name = "unibilium",
15+
.linkage = .static,
16+
.root_module = unibilium,
17+
});
18+
19+
lib.installHeader(b.path("unibilium.h"), "unibilium.h");
20+
21+
unibilium.addCSourceFiles(.{ .root = b.path("."), .files = &.{
22+
"unibilium.c",
23+
"uninames.c",
24+
"uniutil.c",
25+
}, .flags = &.{ "-DTERMINFO_DIRS=\"/etc/terminfo:/usr/share/terminfo\"", "-DTERMINFO=\"/usr/share/terminfo\"" } });
26+
27+
b.installArtifact(lib);
28+
}

‎build.zig.zon‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.{
2+
.name = .unibilium,
3+
.fingerprint = 0x1d1baa4896ad720,
4+
.version = "2.1.3",
5+
.paths = .{
6+
"build.zig",
7+
"build.zig.zon",
8+
"unibilium.h",
9+
"unibilium.c",
10+
"uninames.c",
11+
"uniutil.c",
12+
"README.md",
13+
"LICENSE",
14+
},
15+
}

0 commit comments

Comments
 (0)