-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
146 lines (126 loc) · 4.86 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const std = @import("std");
const bass = @import("libs/zig-bass/build.zig");
const ImageProcessor = @import("image_processor.zig");
const builtin = @import("builtin");
const mach_core = @import("mach");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const zig_bass = b.addModule("bass", .{
.root_source_file = .{ .path = root_path ++ "libs/zig-bass/src/bass.zig" },
});
zig_bass.addIncludePath(.{ .path = root_path ++ "libs/zig-bass/src" });
const slice_iterator = b.addModule(
"slice_iterator",
.{
.root_source_file = .{ .path = root_path ++ "util/slice_iterator.zig" },
},
);
const stb_truetype = b.addModule("stb_truetype", .{
.optimize = optimize,
.target = target,
.root_source_file = .{ .path = "game/stb_truetype.zig" },
});
stb_truetype.addCSourceFile(.{ .file = .{ .path = root_path ++ "libs/stb/impl_stb_truetype.c" }, .flags = &.{} });
stb_truetype.addIncludePath(.{ .path = root_path ++ "libs/stb" });
const zigimg_module = b.dependency("zigimg", .{}).module("zigimg");
const zini_module = b.dependency("zini", .{}).module("zini");
const app = try mach_core.App.init(b, .{
.name = "ztyping",
.src = "game/app.zig",
.target = target,
.optimize = optimize,
.deps = &[_]std.Build.Module.Import{
.{
.name = "zigimg",
.module = zigimg_module,
},
.{
.name = "zini",
.module = zini_module,
},
.{
.name = "bass",
.module = zig_bass,
},
.{
.name = "stb_truetype",
.module = stb_truetype,
},
.{
.name = "fumen_compiler",
.module = b.addModule(
"fumen_compiler",
.{
.root_source_file = .{ .path = root_path ++ "util/fumen_compile.zig" },
.imports = &.{
.{
.name = "slice_iterator",
.module = slice_iterator,
},
},
},
),
},
.{
.name = "slice_iterator",
.module = slice_iterator,
},
},
});
const app_module = app.compile.root_module.import_table.get("app").?;
app_module.resolved_target = target;
bass.linkBass(app_module);
bass.installBass(b, target.result);
app_module.addIncludePath(.{ .path = root_path ++ "libs/zig-bass/src" });
{ //process assets
var process_assets_exe = b.addExecutable(.{
.name = "asset_processor",
.root_source_file = .{ .path = root_path ++ "image_processor.zig" },
.target = b.host,
});
process_assets_exe.root_module.addImport("zigimg", zigimg_module);
var run_process_assets = b.addRunArtifact(process_assets_exe);
run_process_assets.addArg(root_path);
const process_images_step = b.step("Process images", "Process image files into a QOI texture atlas");
process_images_step.dependOn(&run_process_assets.step);
app.compile.step.dependOn(process_images_step);
} //process assets
const tempo = b.addExecutable(.{
.name = "tempo",
.root_source_file = .{ .path = root_path ++ "util/tempo.zig" },
.target = target,
.optimize = optimize,
});
b.installArtifact(tempo);
const clap = b.dependency("clap", .{});
const fumen_compile = b.addExecutable(.{
.name = "fumen_compile",
.root_source_file = .{ .path = root_path ++ "util/fumen_compile.zig" },
.target = target,
.optimize = optimize,
});
fumen_compile.root_module.addImport("slice_iterator", slice_iterator);
fumen_compile.root_module.addImport("clap", clap.module("clap"));
b.installArtifact(fumen_compile);
const fumen_compile_cmd = b.addRunArtifact(fumen_compile);
fumen_compile_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
fumen_compile_cmd.addArgs(args);
}
const fumen_compile_step = b.step("fumen_compile", "Run the fumen compiler");
fumen_compile_step.dependOn(&fumen_compile_cmd.step);
const tempo_cmd = b.addRunArtifact(tempo);
tempo_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
tempo_cmd.addArgs(args);
}
const tempo_step = b.step("tempo", "");
tempo_step.dependOn(&tempo_cmd.step);
const run_step = b.step("run", "Run the app");
run_step.dependOn(&app.run.step);
}
fn root() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
const root_path = root() ++ "/";