From 134a7df8206aa66ca7b0abbc7f31f08410b502d2 Mon Sep 17 00:00:00 2001 From: Jose Colon Rodriguez Date: Tue, 20 Feb 2024 09:13:36 -0400 Subject: Replaced ccc_map with table. 20ms faster --- build.zig | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 3d4c98f..def8b24 100644 --- a/build.zig +++ b/build.zig @@ -33,6 +33,16 @@ pub fn build(b: *std.Build) void { const run_dwp_gen_exe = b.addRunArtifact(dwp_gen_exe); const dwp_gen_out = run_dwp_gen_exe.addOutputFileArg("dwp.zig"); + // Normalization properties + const normp_gen_exe = b.addExecutable(.{ + .name = "normp", + .root_source_file = .{ .path = "codegen/normp.zig" }, + .target = b.host, + .optimize = .Debug, + }); + const run_normp_gen_exe = b.addRunArtifact(normp_gen_exe); + const normp_gen_out = run_normp_gen_exe.addOutputFileArg("normp.zig"); + // Modules we provide // Code points const code_point = b.addModule("code_point", .{ @@ -68,6 +78,16 @@ pub fn build(b: *std.Build) void { display_width.addImport("grapheme", grapheme); display_width.addAnonymousImport("dwp", .{ .root_source_file = dwp_gen_out }); + // Normalization + const norm = b.addModule("Normalizer", .{ + .root_source_file = .{ .path = "src/Normalizer.zig" }, + .target = target, + .optimize = optimize, + }); + norm.addImport("code_point", code_point); + norm.addImport("ziglyph", ziglyph.module("ziglyph")); + norm.addAnonymousImport("normp", .{ .root_source_file = normp_gen_out }); + // Benchmark rig const exe = b.addExecutable(.{ .name = "zg", @@ -80,6 +100,7 @@ pub fn build(b: *std.Build) void { exe.root_module.addImport("code_point", code_point); exe.root_module.addImport("grapheme", grapheme); exe.root_module.addImport("display_width", display_width); + exe.root_module.addImport("Normalizer", norm); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); @@ -91,15 +112,17 @@ pub fn build(b: *std.Build) void { // Tests const exe_unit_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/grapheme.zig" }, + .root_source_file = .{ .path = "src/Normalizer.zig" }, .target = target, .optimize = optimize, }); - exe_unit_tests.root_module.addImport("ascii", ascii); + // exe_unit_tests.root_module.addImport("ascii", ascii); exe_unit_tests.root_module.addImport("code_point", code_point); - exe_unit_tests.root_module.addImport("grapheme", grapheme); - exe_unit_tests.root_module.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); - exe_unit_tests.root_module.addAnonymousImport("dwp", .{ .root_source_file = dwp_gen_out }); + // exe_unit_tests.root_module.addImport("grapheme", grapheme); + // exe_unit_tests.root_module.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); + // exe_unit_tests.root_module.addAnonymousImport("dwp", .{ .root_source_file = dwp_gen_out }); + exe_unit_tests.root_module.addImport("ziglyph", ziglyph.module("ziglyph")); + exe_unit_tests.root_module.addAnonymousImport("normp", .{ .root_source_file = normp_gen_out }); const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); -- cgit v1.2.3