diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 54 |
1 files changed, 32 insertions, 22 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", |
| @@ -31,32 +58,13 @@ pub fn build(b: *std.Build) void { | |||
| 31 | const run_wbp_gen_exe = b.addRunArtifact(wbp_gen_exe); | 58 | const run_wbp_gen_exe = b.addRunArtifact(wbp_gen_exe); |
| 32 | const wbp_gen_out = run_wbp_gen_exe.addOutputFileArg("wbp.bin.z"); | 59 | const wbp_gen_out = run_wbp_gen_exe.addOutputFileArg("wbp.bin.z"); |
| 33 | 60 | ||
| 34 | // Display width | ||
| 35 | const cjk = b.option(bool, "cjk", "Ambiguous code points are wide (display width: 2).") orelse false; | ||
| 36 | const options = b.addOptions(); | ||
| 37 | options.addOption(bool, "cjk", cjk); | ||
| 38 | |||
| 39 | // Visible Controls | ||
| 40 | const c0_width = b.option( | ||
| 41 | i4, | ||
| 42 | "c0_width", | ||
| 43 | "C0 controls have this width (default: 0, <BS> <Del> default -1)", | ||
| 44 | ); | ||
| 45 | options.addOption(?i4, "c0_width", c0_width); | ||
| 46 | const c1_width = b.option( | ||
| 47 | i4, | ||
| 48 | "c1_width", | ||
| 49 | "C1 controls have this width (default: 0)", | ||
| 50 | ); | ||
| 51 | options.addOption(?i4, "c1_width", c1_width); | ||
| 52 | |||
| 53 | const dwp_gen_exe = b.addExecutable(.{ | 61 | const dwp_gen_exe = b.addExecutable(.{ |
| 54 | .name = "dwp", | 62 | .name = "dwp", |
| 55 | .root_source_file = b.path("codegen/dwp.zig"), | 63 | .root_source_file = b.path("codegen/dwp.zig"), |
| 56 | .target = b.graph.host, | 64 | .target = b.graph.host, |
| 57 | .optimize = .Debug, | 65 | .optimize = .Debug, |
| 58 | }); | 66 | }); |
| 59 | dwp_gen_exe.root_module.addOptions("options", options); | 67 | dwp_gen_exe.root_module.addOptions("options", dwp_options); |
| 60 | const run_dwp_gen_exe = b.addRunArtifact(dwp_gen_exe); | 68 | const run_dwp_gen_exe = b.addRunArtifact(dwp_gen_exe); |
| 61 | const dwp_gen_out = run_dwp_gen_exe.addOutputFileArg("dwp.bin.z"); | 69 | const dwp_gen_out = run_dwp_gen_exe.addOutputFileArg("dwp.bin.z"); |
| 62 | 70 | ||
| @@ -199,6 +207,7 @@ pub fn build(b: *std.Build) void { | |||
| 199 | .target = target, | 207 | .target = target, |
| 200 | .optimize = optimize, | 208 | .optimize = optimize, |
| 201 | }); | 209 | }); |
| 210 | code_point.addOptions("config", size_config); | ||
| 202 | 211 | ||
| 203 | const code_point_t = b.addTest(.{ | 212 | const code_point_t = b.addTest(.{ |
| 204 | .name = "code_point", | 213 | .name = "code_point", |
| @@ -216,6 +225,7 @@ pub fn build(b: *std.Build) void { | |||
| 216 | }); | 225 | }); |
| 217 | graphemes.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); | 226 | graphemes.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); |
| 218 | graphemes.addImport("code_point", code_point); | 227 | graphemes.addImport("code_point", code_point); |
| 228 | graphemes.addOptions("config", size_config); | ||
| 219 | 229 | ||
| 220 | const grapheme_t = b.addTest(.{ | 230 | const grapheme_t = b.addTest(.{ |
| 221 | .name = "Graphemes", | 231 | .name = "Graphemes", |
| @@ -267,7 +277,7 @@ pub fn build(b: *std.Build) void { | |||
| 267 | display_width.addImport("ascii", ascii); | 277 | display_width.addImport("ascii", ascii); |
| 268 | display_width.addImport("code_point", code_point); | 278 | display_width.addImport("code_point", code_point); |
| 269 | display_width.addImport("Graphemes", graphemes); | 279 | display_width.addImport("Graphemes", graphemes); |
| 270 | display_width.addOptions("options", options); // For testing | 280 | display_width.addOptions("options", dwp_options); // For testing |
| 271 | 281 | ||
| 272 | const display_width_t = b.addTest(.{ | 282 | const display_width_t = b.addTest(.{ |
| 273 | .name = "display_width", | 283 | .name = "display_width", |