diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 81 |
1 files changed, 60 insertions, 21 deletions
| @@ -11,7 +11,34 @@ pub fn build(b: *std.Build) void { | |||
| 11 | .optimize = optimize, | 11 | .optimize = optimize, |
| 12 | }); | 12 | }); |
| 13 | 13 | ||
| 14 | // Code generation | 14 | //| Options |
| 15 | |||
| 16 | // Display width | ||
| 17 | const cjk = b.option(bool, "cjk", "Ambiguous code points are wide (display width: 2)") orelse false; | ||
| 18 | const dwp_options = b.addOptions(); | ||
| 19 | dwp_options.addOption(bool, "cjk", cjk); | ||
| 20 | |||
| 21 | // Visible Controls | ||
| 22 | const c0_width = b.option( | ||
| 23 | i4, | ||
| 24 | "c0_width", | ||
| 25 | "C0 controls have this width (default: 0, <BS> <Del> default -1)", | ||
| 26 | ); | ||
| 27 | dwp_options.addOption(?i4, "c0_width", c0_width); | ||
| 28 | const c1_width = b.option( | ||
| 29 | i4, | ||
| 30 | "c1_width", | ||
| 31 | "C1 controls have this width (default: 0)", | ||
| 32 | ); | ||
| 33 | dwp_options.addOption(?i4, "c1_width", c1_width); | ||
| 34 | |||
| 35 | //| Offset size | ||
| 36 | const fat_offset = b.option(bool, "fat_offset", "Offsets in iterators and data structures will be u64") orelse false; | ||
| 37 | const size_config = b.addOptions(); | ||
| 38 | size_config.addOption(bool, "fat_offset", fat_offset); | ||
| 39 | |||
| 40 | //| Code generation | ||
| 41 | |||
| 15 | // Grapheme break | 42 | // Grapheme break |
| 16 | const gbp_gen_exe = b.addExecutable(.{ | 43 | const gbp_gen_exe = b.addExecutable(.{ |
| 17 | .name = "gbp", | 44 | .name = "gbp", |
| @@ -32,24 +59,14 @@ pub fn build(b: *std.Build) void { | |||
| 32 | const run_emoji_gen_exe = b.addRunArtifact(emoji_gen_exe); | 59 | const run_emoji_gen_exe = b.addRunArtifact(emoji_gen_exe); |
| 33 | const emoji_gen_out = run_emoji_gen_exe.addOutputFileArg("emoji.bin.z"); | 60 | const emoji_gen_out = run_emoji_gen_exe.addOutputFileArg("emoji.bin.z"); |
| 34 | 61 | ||
| 35 | // Display width | 62 | const wbp_gen_exe = b.addExecutable(.{ |
| 36 | const cjk = b.option(bool, "cjk", "Ambiguous code points are wide (display width: 2).") orelse false; | 63 | .name = "wbp", |
| 37 | const options = b.addOptions(); | 64 | .root_source_file = b.path("codegen/wbp.zig"), |
| 38 | options.addOption(bool, "cjk", cjk); | 65 | .target = b.graph.host, |
| 39 | 66 | .optimize = .Debug, | |
| 40 | // Visible Controls | 67 | }); |
| 41 | const c0_width = b.option( | 68 | const run_wbp_gen_exe = b.addRunArtifact(wbp_gen_exe); |
| 42 | i4, | 69 | const wbp_gen_out = run_wbp_gen_exe.addOutputFileArg("wbp.bin.z"); |
| 43 | "c0_width", | ||
| 44 | "C0 controls have this width (default: 0, <BS> <Del> default -1)", | ||
| 45 | ); | ||
| 46 | options.addOption(?i4, "c0_width", c0_width); | ||
| 47 | const c1_width = b.option( | ||
| 48 | i4, | ||
| 49 | "c1_width", | ||
| 50 | "C1 controls have this width (default: 0)", | ||
| 51 | ); | ||
| 52 | options.addOption(?i4, "c1_width", c1_width); | ||
| 53 | 70 | ||
| 54 | const dwp_gen_exe = b.addExecutable(.{ | 71 | const dwp_gen_exe = b.addExecutable(.{ |
| 55 | .name = "dwp", | 72 | .name = "dwp", |
| @@ -57,7 +74,7 @@ pub fn build(b: *std.Build) void { | |||
| 57 | .target = b.graph.host, | 74 | .target = b.graph.host, |
| 58 | .optimize = .Debug, | 75 | .optimize = .Debug, |
| 59 | }); | 76 | }); |
| 60 | dwp_gen_exe.root_module.addOptions("options", options); | 77 | dwp_gen_exe.root_module.addOptions("options", dwp_options); |
| 61 | const run_dwp_gen_exe = b.addRunArtifact(dwp_gen_exe); | 78 | const run_dwp_gen_exe = b.addRunArtifact(dwp_gen_exe); |
| 62 | const dwp_gen_out = run_dwp_gen_exe.addOutputFileArg("dwp.bin.z"); | 79 | const dwp_gen_out = run_dwp_gen_exe.addOutputFileArg("dwp.bin.z"); |
| 63 | 80 | ||
| @@ -193,12 +210,14 @@ pub fn build(b: *std.Build) void { | |||
| 193 | const props_gen_out = run_props_gen_exe.addOutputFileArg("props.bin.z"); | 210 | const props_gen_out = run_props_gen_exe.addOutputFileArg("props.bin.z"); |
| 194 | 211 | ||
| 195 | // Modules we provide | 212 | // Modules we provide |
| 213 | |||
| 196 | // Code points | 214 | // Code points |
| 197 | const code_point = b.addModule("code_point", .{ | 215 | const code_point = b.addModule("code_point", .{ |
| 198 | .root_source_file = b.path("src/code_point.zig"), | 216 | .root_source_file = b.path("src/code_point.zig"), |
| 199 | .target = target, | 217 | .target = target, |
| 200 | .optimize = optimize, | 218 | .optimize = optimize, |
| 201 | }); | 219 | }); |
| 220 | code_point.addOptions("config", size_config); | ||
| 202 | 221 | ||
| 203 | const code_point_t = b.addTest(.{ | 222 | const code_point_t = b.addTest(.{ |
| 204 | .name = "code_point", | 223 | .name = "code_point", |
| @@ -216,6 +235,7 @@ pub fn build(b: *std.Build) void { | |||
| 216 | }); | 235 | }); |
| 217 | graphemes.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); | 236 | graphemes.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); |
| 218 | graphemes.addImport("code_point", code_point); | 237 | graphemes.addImport("code_point", code_point); |
| 238 | graphemes.addOptions("config", size_config); | ||
| 219 | 239 | ||
| 220 | const grapheme_t = b.addTest(.{ | 240 | const grapheme_t = b.addTest(.{ |
| 221 | .name = "Graphemes", | 241 | .name = "Graphemes", |
| @@ -241,6 +261,23 @@ pub fn build(b: *std.Build) void { | |||
| 241 | }); | 261 | }); |
| 242 | const emoji_tr = b.addRunArtifact(emoji_t); | 262 | const emoji_tr = b.addRunArtifact(emoji_t); |
| 243 | 263 | ||
| 264 | // Word Breaking | ||
| 265 | const words = b.addModule("Words", .{ | ||
| 266 | .root_source_file = b.path("src/Words.zig"), | ||
| 267 | .target = target, | ||
| 268 | .optimize = optimize, | ||
| 269 | }); | ||
| 270 | words.addAnonymousImport("wbp", .{ .root_source_file = wbp_gen_out }); | ||
| 271 | words.addImport("code_point", code_point); | ||
| 272 | |||
| 273 | const words_t = b.addTest(.{ | ||
| 274 | .name = "WordBreak", | ||
| 275 | .root_module = words, | ||
| 276 | .target = target, | ||
| 277 | .optimize = optimize, | ||
| 278 | }); | ||
| 279 | const words_tr = b.addRunArtifact(words_t); | ||
| 280 | |||
| 244 | // ASCII utilities | 281 | // ASCII utilities |
| 245 | const ascii = b.addModule("ascii", .{ | 282 | const ascii = b.addModule("ascii", .{ |
| 246 | .root_source_file = b.path("src/ascii.zig"), | 283 | .root_source_file = b.path("src/ascii.zig"), |
| @@ -266,7 +303,7 @@ pub fn build(b: *std.Build) void { | |||
| 266 | display_width.addImport("ascii", ascii); | 303 | display_width.addImport("ascii", ascii); |
| 267 | display_width.addImport("code_point", code_point); | 304 | display_width.addImport("code_point", code_point); |
| 268 | display_width.addImport("Graphemes", graphemes); | 305 | display_width.addImport("Graphemes", graphemes); |
| 269 | display_width.addOptions("options", options); // For testing | 306 | display_width.addOptions("options", dwp_options); // For testing |
| 270 | 307 | ||
| 271 | const display_width_t = b.addTest(.{ | 308 | const display_width_t = b.addTest(.{ |
| 272 | .name = "display_width", | 309 | .name = "display_width", |
| @@ -470,6 +507,7 @@ pub fn build(b: *std.Build) void { | |||
| 470 | }); | 507 | }); |
| 471 | unicode_tests.root_module.addImport("Graphemes", graphemes); | 508 | unicode_tests.root_module.addImport("Graphemes", graphemes); |
| 472 | unicode_tests.root_module.addImport("Normalize", norm); | 509 | unicode_tests.root_module.addImport("Normalize", norm); |
| 510 | unicode_tests.root_module.addImport("Words", words); | ||
| 473 | 511 | ||
| 474 | const run_unicode_tests = b.addRunArtifact(unicode_tests); | 512 | const run_unicode_tests = b.addRunArtifact(unicode_tests); |
| 475 | 513 | ||
| @@ -479,6 +517,7 @@ pub fn build(b: *std.Build) void { | |||
| 479 | test_step.dependOn(&display_width_tr.step); | 517 | test_step.dependOn(&display_width_tr.step); |
| 480 | test_step.dependOn(&grapheme_tr.step); | 518 | test_step.dependOn(&grapheme_tr.step); |
| 481 | test_step.dependOn(&emoji_tr.step); | 519 | test_step.dependOn(&emoji_tr.step); |
| 520 | test_step.dependOn(&words_tr.step); | ||
| 482 | test_step.dependOn(&ascii_tr.step); | 521 | test_step.dependOn(&ascii_tr.step); |
| 483 | test_step.dependOn(&ccc_data_tr.step); | 522 | test_step.dependOn(&ccc_data_tr.step); |
| 484 | test_step.dependOn(&canon_data_tr.step); | 523 | test_step.dependOn(&canon_data_tr.step); |