summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGravatar Sam Atman2025-04-30 11:58:19 -0400
committerGravatar Sam Atman2025-04-30 11:58:19 -0400
commit1be5e46490e061761b4b97dff5c6acb2181d6fe9 (patch)
tree77a1edcdedd7afae7428e92feba37d2bb1035b22 /build.zig
parentAdd general tests step (diff)
downloadzg-1be5e46490e061761b4b97dff5c6acb2181d6fe9.tar.gz
zg-1be5e46490e061761b4b97dff5c6acb2181d6fe9.tar.xz
zg-1be5e46490e061761b4b97dff5c6acb2181d6fe9.zip
Factor out 'Data' for grapheme and DisplayWidth
In the process of refactoring the whole library, so that it doesn't expose anything called "Data" separately from user functionality.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig74
1 files changed, 24 insertions, 50 deletions
diff --git a/build.zig b/build.zig
index b555bd7..3aeccd1 100644
--- a/build.zig
+++ b/build.zig
@@ -191,33 +191,18 @@ pub fn build(b: *std.Build) void {
191 }); 191 });
192 const code_point_tr = b.addRunArtifact(code_point_t); 192 const code_point_tr = b.addRunArtifact(code_point_t);
193 193
194 // Grapheme clusters 194 // Graphemes
195 const grapheme_data = b.createModule(.{ 195 const graphemes = b.addModule("Graphemes", .{
196 .root_source_file = b.path("src/GraphemeData.zig"),
197 .target = target,
198 .optimize = optimize,
199 });
200 grapheme_data.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out });
201
202 const grapheme_data_t = b.addTest(.{
203 .name = "grapheme_data",
204 .root_module = grapheme_data,
205 .target = target,
206 .optimize = optimize,
207 });
208 const grapheme_data_tr = b.addRunArtifact(grapheme_data_t);
209
210 const grapheme = b.addModule("grapheme", .{
211 .root_source_file = b.path("src/grapheme.zig"), 196 .root_source_file = b.path("src/grapheme.zig"),
212 .target = target, 197 .target = target,
213 .optimize = optimize, 198 .optimize = optimize,
214 }); 199 });
215 grapheme.addImport("code_point", code_point); 200 graphemes.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out });
216 grapheme.addImport("GraphemeData", grapheme_data); 201 graphemes.addImport("code_point", code_point);
217 202
218 const grapheme_t = b.addTest(.{ 203 const grapheme_t = b.addTest(.{
219 .name = "grapheme", 204 .name = "Graphemes",
220 .root_module = grapheme, 205 .root_module = graphemes,
221 .target = target, 206 .target = target,
222 .optimize = optimize, 207 .optimize = optimize,
223 }); 208 });
@@ -239,31 +224,15 @@ pub fn build(b: *std.Build) void {
239 const ascii_tr = b.addRunArtifact(ascii_t); 224 const ascii_tr = b.addRunArtifact(ascii_t);
240 225
241 // Fixed pitch font display width 226 // Fixed pitch font display width
242 const width_data = b.createModule(.{
243 .root_source_file = b.path("src/WidthData.zig"),
244 .target = target,
245 .optimize = optimize,
246 });
247 width_data.addAnonymousImport("dwp", .{ .root_source_file = dwp_gen_out });
248 width_data.addImport("GraphemeData", grapheme_data);
249
250 const width_data_t = b.addTest(.{
251 .name = "width_data",
252 .root_module = width_data,
253 .target = target,
254 .optimize = optimize,
255 });
256 const width_data_tr = b.addRunArtifact(width_data_t);
257
258 const display_width = b.addModule("DisplayWidth", .{ 227 const display_width = b.addModule("DisplayWidth", .{
259 .root_source_file = b.path("src/DisplayWidth.zig"), 228 .root_source_file = b.path("src/DisplayWidth.zig"),
260 .target = target, 229 .target = target,
261 .optimize = optimize, 230 .optimize = optimize,
262 }); 231 });
232 display_width.addAnonymousImport("dwp", .{ .root_source_file = dwp_gen_out });
263 display_width.addImport("ascii", ascii); 233 display_width.addImport("ascii", ascii);
264 display_width.addImport("code_point", code_point); 234 display_width.addImport("code_point", code_point);
265 display_width.addImport("grapheme", grapheme); 235 display_width.addImport("Graphemes", graphemes);
266 display_width.addImport("DisplayWidthData", width_data);
267 display_width.addOptions("options", options); // For testing 236 display_width.addOptions("options", options); // For testing
268 237
269 const display_width_t = b.addTest(.{ 238 const display_width_t = b.addTest(.{
@@ -361,6 +330,14 @@ pub fn build(b: *std.Build) void {
361 norm_data.addImport("HangulData", hangul_data); 330 norm_data.addImport("HangulData", hangul_data);
362 norm_data.addImport("NormPropsData", normp_data); 331 norm_data.addImport("NormPropsData", normp_data);
363 332
333 const norm_data_t = b.addTest(.{
334 .name = "norm_data",
335 .root_module = norm_data,
336 .target = target,
337 .optimize = optimize,
338 });
339 const norm_data_tr = b.addRunArtifact(norm_data_t);
340
364 const norm = b.addModule("Normalize", .{ 341 const norm = b.addModule("Normalize", .{
365 .root_source_file = b.path("src/Normalize.zig"), 342 .root_source_file = b.path("src/Normalize.zig"),
366 .target = target, 343 .target = target,
@@ -370,13 +347,13 @@ pub fn build(b: *std.Build) void {
370 norm.addImport("code_point", code_point); 347 norm.addImport("code_point", code_point);
371 norm.addImport("NormData", norm_data); 348 norm.addImport("NormData", norm_data);
372 349
373 const norm_data_t = b.addTest(.{ 350 const norm_t = b.addTest(.{
374 .name = "norm_data", 351 .name = "norm",
375 .root_module = norm_data, 352 .root_module = norm,
376 .target = target, 353 .target = target,
377 .optimize = optimize, 354 .optimize = optimize,
378 }); 355 });
379 const norm_data_tr = b.addRunArtifact(norm_data_t); 356 const norm_tr = b.addRunArtifact(norm_t);
380 357
381 // General Category 358 // General Category
382 const gencat_data = b.addModule("GenCatData", .{ 359 const gencat_data = b.addModule("GenCatData", .{
@@ -478,18 +455,14 @@ pub fn build(b: *std.Build) void {
478 .target = target, 455 .target = target,
479 .optimize = optimize, 456 .optimize = optimize,
480 }); 457 });
481 unicode_tests.root_module.addImport("grapheme", grapheme); 458 unicode_tests.root_module.addImport("grapheme", graphemes);
482 unicode_tests.root_module.addImport("Normalize", norm); 459 unicode_tests.root_module.addImport("Normalize", norm);
483 460
484 const run_unicode_tests = b.addRunArtifact(unicode_tests); 461 const run_unicode_tests = b.addRunArtifact(unicode_tests);
485 462
486 const unicode_test_step = b.step("unicode-test", "Run Unicode tests"); 463 const test_step = b.step("test", "Run all module tests");
487 unicode_test_step.dependOn(&run_unicode_tests.step); 464 test_step.dependOn(&run_unicode_tests.step);
488
489 const test_step = b.step("test", "Run general tests");
490 test_step.dependOn(&code_point_tr.step); 465 test_step.dependOn(&code_point_tr.step);
491 test_step.dependOn(&grapheme_data_tr.step);
492 test_step.dependOn(&width_data_tr.step);
493 test_step.dependOn(&display_width_tr.step); 466 test_step.dependOn(&display_width_tr.step);
494 test_step.dependOn(&grapheme_tr.step); 467 test_step.dependOn(&grapheme_tr.step);
495 test_step.dependOn(&ascii_tr.step); 468 test_step.dependOn(&ascii_tr.step);
@@ -499,6 +472,7 @@ pub fn build(b: *std.Build) void {
499 test_step.dependOn(&hangul_data_tr.step); 472 test_step.dependOn(&hangul_data_tr.step);
500 test_step.dependOn(&normp_data_tr.step); 473 test_step.dependOn(&normp_data_tr.step);
501 test_step.dependOn(&norm_data_tr.step); 474 test_step.dependOn(&norm_data_tr.step);
475 test_step.dependOn(&norm_tr.step);
502 test_step.dependOn(&gencat_data_tr.step); 476 test_step.dependOn(&gencat_data_tr.step);
503 test_step.dependOn(&case_fold_tr.step); 477 test_step.dependOn(&case_fold_tr.step);
504 test_step.dependOn(&case_data_tr.step); 478 test_step.dependOn(&case_data_tr.step);