-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
58 lines (46 loc) · 2.06 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
const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("calculo", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
exe.c_std = .C99;
exe.addIncludeDir("include");
const target_triple_str = target.linuxTriple(b.allocator) catch |err| {
std.debug.warn("{} error while trying to stringify the target triple", .{err});
std.os.exit(1);
};
const lib_dir = std.fs.path.join(b.allocator, &[_][]const u8{ "lib", target_triple_str }) catch |err| {
std.debug.warn("{} error while trying to render library path", .{err});
std.os.exit(1);
};
exe.addLibPath(lib_dir);
exe.linkLibC();
exe.linkSystemLibrary("raylib");
if (target.isDarwin()) {
exe.addFrameworkDir("/Library/Frameworks");
exe.addFrameworkDir("~/Library/Frameworks");
exe.addFrameworkDir("/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks");
exe.linkFramework("OpenCL");
} else {
exe.linkSystemLibrary("opencl");
}
exe.rdynamic = true;
exe.addIncludeDir("src/algae");
exe.addCSourceFile("src/algae/algae.c", &[_][]const u8{});
const fut = b.addSystemCommand(&[_][]const u8{ "futhark", "opencl", "--library", "src/algae/algae.fut" });
exe.step.dependOn(&fut.step);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}