From 2436eeb57143108decfd37fe531cf87ca8d56cf8 Mon Sep 17 00:00:00 2001 From: Jose Colon Rodriguez Date: Thu, 15 Feb 2024 12:25:33 -0400 Subject: build.zig module reorg --- build.zig | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 8193f0d..6353874 100644 --- a/build.zig +++ b/build.zig @@ -4,8 +4,10 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + // Dependencies const ziglyph = b.dependency("ziglyph", .{}); + // Code generation const gbp_gen_exe = b.addExecutable(.{ .name = "gbp", .root_source_file = .{ .path = "codegen/gbp.zig" }, @@ -15,6 +17,22 @@ pub fn build(b: *std.Build) void { const run_gbp_gen_exe = b.addRunArtifact(gbp_gen_exe); const gbp_gen_out = run_gbp_gen_exe.addOutputFileArg("gbp.zig"); + // Modules we provide + const code_point = b.addModule("CodePoint", .{ + .root_source_file = .{ .path = "src/CodePoint.zig" }, + .target = target, + .optimize = optimize, + }); + + const grapheme = b.addModule("Grapheme", .{ + .root_source_file = .{ .path = "src/Grapheme.zig" }, + .target = target, + .optimize = optimize, + }); + grapheme.addImport("CodePoint", code_point); + grapheme.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); + + // Benchmark rig const exe = b.addExecutable(.{ .name = "zgbench", .root_source_file = .{ .path = "src/main.zig" }, @@ -22,7 +40,7 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); exe.root_module.addImport("ziglyph", ziglyph.module("ziglyph")); - exe.root_module.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); + exe.root_module.addImport("Grapheme", grapheme); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); @@ -32,13 +50,14 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); + // Tests const exe_unit_tests = b.addTest(.{ .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); exe_unit_tests.root_module.addImport("ziglyph", ziglyph.module("ziglyph")); - exe_unit_tests.root_module.addAnonymousImport("gbp", .{ .root_source_file = gbp_gen_out }); + exe_unit_tests.root_module.addImport("Grapheme", grapheme); const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); -- cgit v1.2.3