const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // =========================================== // Main library module // =========================================== const zcatp2p_mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); // =========================================== // Tests // =========================================== const lib_unit_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }), }); const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_lib_unit_tests.step); // =========================================== // Example // =========================================== const example = b.addExecutable(.{ .name = "zcatp2p-example", .root_module = b.createModule(.{ .root_source_file = b.path("examples/basic.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "zcatp2p", .module = zcatp2p_mod }, }, }), }); b.installArtifact(example); const run_example = b.addRunArtifact(example); run_example.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_example.addArgs(args); } const run_step = b.step("run", "Run the example"); run_step.dependOn(&run_example.step); }