Skip to content

Commit 200f454

Browse files
committed
feat: add core library
1 parent d853ce3 commit 200f454

15 files changed

Lines changed: 8331 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/target
22
.DS_Store
3+
4+
.zig-cache
5+
zig-out

core-library/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Core Library
2+
3+
## Run tests
4+
5+
```
6+
zig build test --summary all
7+
```
8+
9+
10+
## Build
11+
12+
```
13+
zig build
14+
```

core-library/build.zig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const optimize = b.standardOptimizeOption(.{});
5+
const target = b.standardTargetOptions(.{ .default_target = .{ .ofmt = .c } });
6+
7+
// Core Library
8+
//
9+
const libcore = b.addStaticLibrary(.{
10+
.name = "core",
11+
.root_source_file = b.path("src/main.zig"),
12+
.target = target,
13+
.optimize = optimize,
14+
.link_libc = true,
15+
});
16+
libcore.addIncludePath(b.path("src/includes"));
17+
libcore.addCSourceFile(.{
18+
.file = b.path("src/includes/wrapper.c"),
19+
.flags = &.{"-Wall"},
20+
});
21+
b.installArtifact(libcore);
22+
23+
// Tests
24+
//
25+
const test_main = b.addTest(.{
26+
.root_source_file = b.path("src/main.zig"),
27+
.optimize = optimize,
28+
.link_libc = true,
29+
.test_runner = b.path("src/test_main.zig")
30+
});
31+
test_main.linkLibC();
32+
test_main.addIncludePath(b.path("src/includes"));
33+
test_main.addCSourceFile(.{
34+
.file = b.path("src/includes/wrapper.c"),
35+
.flags = &.{"-Wall"},
36+
});
37+
const run_test_main = b.addRunArtifact(test_main);
38+
b.step("test", "test utility functions").dependOn(&run_test_main.step);
39+
}

core-library/build.zig.zon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.{
2+
.name = "core",
3+
.fingerprint = 0x6b8d854f40550aa0,
4+
.version = "0.0.1",
5+
.dependencies = .{
6+
7+
},
8+
.paths = .{
9+
"build.zig",
10+
"src/main.zig",
11+
},
12+
}

0 commit comments

Comments
 (0)