const std = @import("std"); const material_max_len_default: usize = 40; const dimension_max_len_default: usize = 16; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // comptime config options const lib_options = blk: { const material_max_len = b.option( usize, "material-max-len", "Maximum length a material name can have", ) orelse material_max_len_default; const options = b.addOptions(); options.addOption(usize, "material_max_len", material_max_len); break :blk options; }; const zap_dep = b.dependency("zap", .{ .openssl = false }); const clap_dep = b.dependency("clap", .{}); // craftflut library const lib_mod = blk: { const mod = b.addModule("craftflut", .{ .root_source_file = b.path("src/root.zig"), }); mod.addOptions("build_options", lib_options); mod.addImport("zap", zap_dep.module("zap")); break :blk mod; }; // craftflut executable const exe_mod = blk: { const mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); mod.addImport("craftflut", lib_mod); mod.addImport("clap", clap_dep.module("clap")); break :blk mod; }; const exe = b.addExecutable(.{ .name = "craftflut", .root_module = exe_mod, }); b.installArtifact(exe); // run step const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); // const lib_unit_tests = b.addTest(.{ // .root_module = lib_mod, // }); // const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); // const exe_unit_tests = b.addTest(.{ // .root_module = exe_mod, // }); // const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); // // Similar to creating the run step earlier, this exposes a `test` step to // // the `zig build --help` menu, providing a way for the user to request // // running the unit tests. // const test_step = b.step("test", "Run unit tests"); // test_step.dependOn(&run_lib_unit_tests.step); // test_step.dependOn(&run_exe_unit_tests.step); }