this repo has no description
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6
7 const options = b.addOptions();
8
9 const strip = b.option(bool, "strip", "") orelse (optimize != .Debug);
10 const max_depth = b.option(u64, "max-depth", "Set the max depth of the BVH tree") orelse std.math.maxInt(u64);
11 options.addOption(u64, "max_depth", max_depth);
12
13 const save_during_render = b.option(bool, "save-during-render", "Save image during the render process") orelse false;
14 options.addOption(bool, "save_during_render", save_during_render);
15
16 const output_file: std.Build.LazyPath = b.option(std.Build.LazyPath, "output", "File to save rendered image to") orelse {
17 std.log.err("Please specify a save file location", .{});
18 return;
19 };
20 options.addOption([]const u8, "output", output_file.getPath(b));
21
22 const rayray = b.addModule("rayray", .{
23 .root_source_file = b.path("src/rayray.zig"),
24 .target = target,
25 .optimize = optimize,
26 });
27 rayray.strip = strip;
28 rayray.addOptions("build-options", options);
29
30 addDeps(b, rayray);
31
32 const exe = b.addExecutable(.{
33 .name = "rayray",
34 .root_source_file = b.path("src/main.zig"),
35 .target = target,
36 .optimize = optimize,
37 });
38 exe.root_module.strip = strip;
39 exe.root_module.addImport("rayray", rayray);
40
41 const alib = b.dependency("a", .{
42 .log_ignore_default = true,
43 });
44 exe.root_module.addImport("a", alib.module("a"));
45
46 b.installArtifact(exe);
47
48 const run_cmd = b.addRunArtifact(exe);
49 run_cmd.step.dependOn(b.getInstallStep());
50
51 if (b.args) |args| {
52 run_cmd.addArgs(args);
53 }
54
55 const run_step = b.step("run", "Run the app");
56 run_step.dependOn(&run_cmd.step);
57}
58
59fn addDeps(b: *std.Build, module: *std.Build.Module) void {
60 const zmath = b.dependency("zmath", .{
61 .optimize = .ReleaseFast,
62 .enable_cross_platform_determinism = false,
63 });
64 module.addImport("zmath", zmath.module("root"));
65
66 const zigimg = b.dependency("zigimg", .{
67 .optimize = .ReleaseFast,
68 });
69 module.addImport("zigimg", zigimg.module("zigimg"));
70}