-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
203 lines (181 loc) · 6.78 KB
/
Copy pathbuild.zig
File metadata and controls
203 lines (181 loc) · 6.78 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("image_to_ascii", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
const zigimg_dep = b.dependency("zigimg", .{
.target = target,
.optimize = optimize,
});
const zigimg_mod = zigimg_dep.module("zigimg");
const ppm_support_mod = b.createModule(.{
.root_source_file = b.path("test_support/ppm.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
},
});
const image_loader_mod = b.createModule(.{
.root_source_file = b.path("test_support/image_loader.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
.{ .name = "ppm_support", .module = ppm_support_mod },
.{ .name = "zigimg", .module = zigimg_mod },
},
});
const quality_tools_mod = b.createModule(.{
.root_source_file = b.path("tools/quality.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
},
});
const exe = b.addExecutable(.{
.name = "cell-render",
.root_module = b.createModule(.{
.root_source_file = b.path("src/cli.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
.{ .name = "ppm_support", .module = ppm_support_mod },
.{ .name = "image_loader", .module = image_loader_mod },
},
}),
});
b.installArtifact(exe);
const bench_exe = b.addExecutable(.{
.name = "image-to-ascii-bench",
.root_module = b.createModule(.{
.root_source_file = b.path("bench/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
.{ .name = "image_loader", .module = image_loader_mod },
.{ .name = "quality_tools", .module = quality_tools_mod },
},
}),
});
const compare_exe = b.addExecutable(.{
.name = "image-to-ascii-compare",
.root_module = b.createModule(.{
.root_source_file = b.path("tools/render_compare.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
.{ .name = "ppm_support", .module = ppm_support_mod },
.{ .name = "image_loader", .module = image_loader_mod },
},
}),
});
const calibrate_mod = b.createModule(.{
.root_source_file = b.path("tools/calibrate_font.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
calibrate_mod.addIncludePath(b.path("tools/stb"));
calibrate_mod.addCSourceFile(.{
.file = b.path("tools/stb/stb_truetype_impl.c"),
.flags = &.{"-std=c99"},
});
const calibrate_exe = b.addExecutable(.{
.name = "image-to-ascii-calibrate",
.root_module = calibrate_mod,
});
const glyphshot_mod = b.createModule(.{
.root_source_file = b.path("tools/glyphshot.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{
.{ .name = "image_to_ascii", .module = mod },
.{ .name = "image_loader", .module = image_loader_mod },
},
});
glyphshot_mod.addIncludePath(b.path("tools/stb"));
glyphshot_mod.addCSourceFile(.{
.file = b.path("tools/stb/stb_truetype_impl.c"),
.flags = &.{"-std=c99"},
});
const glyphshot_exe = b.addExecutable(.{
.name = "image-to-ascii-glyphshot",
.root_module = glyphshot_mod,
});
const run_step = b.step("run", "Run the CLI");
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
run_step.dependOn(&run_cmd.step);
const bench_step = b.step("bench", "Run renderer benchmarks");
const bench_cmd = b.addRunArtifact(bench_exe);
if (b.args) |args| {
bench_cmd.addArgs(args);
}
bench_step.dependOn(&bench_cmd.step);
const compare_step = b.step("compare", "Render an image and score reconstruction quality");
const compare_cmd = b.addRunArtifact(compare_exe);
if (b.args) |args| {
compare_cmd.addArgs(args);
}
compare_step.dependOn(&compare_cmd.step);
const calibrate_step = b.step("calibrate", "Generate or inspect a glyph atlas (scaffold)");
const calibrate_cmd = b.addRunArtifact(calibrate_exe);
if (b.args) |args| {
calibrate_cmd.addArgs(args);
}
calibrate_step.dependOn(&calibrate_cmd.step);
const glyphshot_step = b.step("glyphshot", "Rasterize a render through a real TTF to a PPM (headless visual check)");
const glyphshot_cmd = b.addRunArtifact(glyphshot_exe);
if (b.args) |args| {
glyphshot_cmd.addArgs(args);
}
glyphshot_step.dependOn(&glyphshot_cmd.step);
const mod_tests = b.addTest(.{
.root_module = mod,
});
const run_mod_tests = b.addRunArtifact(mod_tests);
const ppm_support_tests = b.addTest(.{
.root_module = ppm_support_mod,
});
const run_ppm_support_tests = b.addRunArtifact(ppm_support_tests);
const image_loader_tests = b.addTest(.{
.root_module = image_loader_mod,
});
const run_image_loader_tests = b.addRunArtifact(image_loader_tests);
const exe_tests = b.addTest(.{
.root_module = exe.root_module,
});
const run_exe_tests = b.addRunArtifact(exe_tests);
const bench_tests = b.addTest(.{
.root_module = bench_exe.root_module,
});
const run_bench_tests = b.addRunArtifact(bench_tests);
const compare_tests = b.addTest(.{
.root_module = compare_exe.root_module,
});
const run_compare_tests = b.addRunArtifact(compare_tests);
const calibrate_tests = b.addTest(.{
.root_module = calibrate_exe.root_module,
});
const run_calibrate_tests = b.addRunArtifact(calibrate_tests);
const test_step = b.step("test", "Run all tests");
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_ppm_support_tests.step);
test_step.dependOn(&run_image_loader_tests.step);
test_step.dependOn(&run_exe_tests.step);
test_step.dependOn(&run_bench_tests.step);
test_step.dependOn(&run_compare_tests.step);
test_step.dependOn(&run_calibrate_tests.step);
}