this repo has no description
at main 62 lines 1.9 kB view raw
1const std = @import("std"); 2 3pub fn build(b: *std.Build) void { 4 const target = b.standardTargetOptions(.{}); 5 6 const options = .{ 7 .optimize = b.option( 8 std.builtin.OptimizeMode, 9 "optimize", 10 "Select optimization mode", 11 ) orelse b.standardOptimizeOption(.{ 12 .preferred_optimize_mode = .ReleaseFast, 13 }), 14 .enable_cross_platform_determinism = b.option( 15 bool, 16 "enable_cross_platform_determinism", 17 "Enable cross-platform determinism", 18 ) orelse true, 19 }; 20 21 const options_step = b.addOptions(); 22 inline for (std.meta.fields(@TypeOf(options))) |field| { 23 options_step.addOption(field.type, field.name, @field(options, field.name)); 24 } 25 26 const options_module = options_step.createModule(); 27 28 const zmath = b.addModule("root", .{ 29 .root_source_file = b.path("src/main.zig"), 30 .imports = &.{ 31 .{ .name = "zmath_options", .module = options_module }, 32 }, 33 }); 34 35 const test_step = b.step("test", "Run zmath tests"); 36 37 const tests = b.addTest(.{ 38 .name = "zmath-tests", 39 .root_source_file = b.path("src/main.zig"), 40 .target = target, 41 .optimize = options.optimize, 42 }); 43 b.installArtifact(tests); 44 45 tests.root_module.addImport("zmath_options", options_module); 46 47 test_step.dependOn(&b.addRunArtifact(tests).step); 48 49 const benchmark_step = b.step("benchmark", "Run zmath benchmarks"); 50 51 const benchmarks = b.addExecutable(.{ 52 .name = "zmath-benchmarks", 53 .root_source_file = b.path("src/benchmark.zig"), 54 .target = target, 55 .optimize = options.optimize, 56 }); 57 b.installArtifact(benchmarks); 58 59 benchmarks.root_module.addImport("zmath", zmath); 60 61 benchmark_step.dependOn(&b.addRunArtifact(benchmarks).step); 62}