Skip to content

Commit c74cba4

Browse files
committed
Replace compute.c with compute.zig
1 parent 0704b44 commit c74cba4

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

build.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const Builder = @import("std").build.Builder;
22

33
pub fn build(b: &Builder) {
44
const exe = b.addCExecutable("main");
5+
b.addCIncludePath(".");
56
exe.addCompileFlags([][]const u8 {
67
"-std=c99"
78
});
89

910
const source_files = [][]const u8 {
10-
"compute.c",
1111
"compute_helper.c",
1212
"display.c",
1313
"main.c"
@@ -17,6 +17,15 @@ pub fn build(b: &Builder) {
1717
exe.addSourceFile(source);
1818
}
1919

20+
const zig_source_files = [][]const u8 {
21+
"compute.zig",
22+
};
23+
24+
for (zig_source_files) |source| {
25+
const object = b.addObject(source, source);
26+
exe.addObject(object);
27+
}
28+
2029
exe.setOutputPath("./main");
2130
b.default_step.dependOn(&exe.step);
2231
}

compute.c

Lines changed: 0 additions & 6 deletions
This file was deleted.

compute.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub use @cImport(@cInclude("compute_helper.h"));
2+
3+
export fn compute(a: u8) -> u8 {
4+
compute_helper(a) + 5
5+
}

0 commit comments

Comments
 (0)