-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.zig
74 lines (63 loc) · 2.39 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Boehm GC
const gc = b.addStaticLibrary(.{
.name = "gc",
.target = target,
.optimize = optimize,
});
{
const cflags = [_][]const u8{"-DNO_EXECUTE_PERMISSION"};
const libgc_srcs = [_][]const u8{
"alloc.c", "reclaim.c", "allchblk.c", "misc.c", "mach_dep.c", "os_dep.c",
"mark_rts.c", "headers.c", "mark.c", "obj_map.c", "blacklst.c", "finalize.c",
"new_hblk.c", "dbg_mlc.c", "malloc.c", "dyn_load.c", "typd_mlc.c", "ptr_chck.c",
"mallocx.c",
};
gc.linkLibC();
if (target.result.isDarwin()) {
gc.linkFramework("CoreServices");
}
gc.addIncludePath(b.path("deps/github.com/ivmai/bdwgc/include"));
inline for (libgc_srcs) |src| {
gc.addCSourceFile(.{ .file = b.path("deps/github.com/ivmai/bdwgc/" ++ src), .flags = &cflags });
}
const gc_step = b.step("libgc", "build libgc");
gc_step.dependOn(&gc.step);
}
const exe = b.addExecutable(.{
.name = "bio",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.addIncludePath(b.path("deps/github.com/ivmai/bdwgc/include"));
exe.linkLibC();
exe.linkLibrary(gc);
if (target.result.os.tag != .windows) {
exe.addCSourceFile(.{ .file = b.path("deps/linenoise.c"), .flags = &[_][]const u8{ "-std=c99", "-Wno-everything" } });
exe.addIncludePath(b.path("deps"));
}
var inst = b.addInstallArtifact(exe, .{});
b.getInstallStep().dependOn(&inst.step);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
var tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
});
tests.addIncludePath(b.path("deps/github.com/ivmai/bdwgc/include"));
tests.linkLibC();
tests.linkLibrary(gc);
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_tests.step);
}