-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
50 lines (47 loc) · 1.79 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
const std = @import("std");
const builtin = @import("builtin");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "tetris",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
switch (target.result.os.tag) {
.windows => {
const io_path = "src/io_windows.zig";
const io = b.createModule(.{
.optimize = optimize,
.target = target,
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = io_path } },
});
exe.root_module.addImport("io", io);
},
.macos => {
const io_path = "src/io_posix.zig";
const io = b.createModule(.{
.optimize = optimize,
.target = target,
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = io_path } },
});
const spoon = b.dependency("zig-spoon", .{ .optimize = optimize, .target = target });
io.addImport("spoon", spoon.module("spoon"));
exe.root_module.addImport("io", io);
},
else => {
const io_path = "src/io_posix.zig";
const io = b.createModule(.{
.optimize = optimize,
.target = target,
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = io_path } },
});
const spoon = b.dependency("zig-spoon", .{ .optimize = optimize, .target = target });
io.addImport("spoon", spoon.module("spoon"));
exe.root_module.addImport("io", io);
},
}
b.installArtifact(exe);
}