aboutsummaryrefslogtreecommitdiffhomepage
path: root/build.zig
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-11 20:42:48 +0900
committernsfisis <nsfisis@gmail.com>2024-07-11 21:05:50 +0900
commit42f06f1841d70a97bad48084cc3360209589196f (patch)
treec6bec95f80bd95f6188a077026f87fdcd7749266 /build.zig
parent55bf05f1268c8fbbf7f2fb0b6ed44f76801d6b0f (diff)
downloadRayTracingInOneWeekend.zig-42f06f1841d70a97bad48084cc3360209589196f.tar.gz
RayTracingInOneWeekend.zig-42f06f1841d70a97bad48084cc3360209589196f.tar.zst
RayTracingInOneWeekend.zig-42f06f1841d70a97bad48084cc3360209589196f.zip
feat: update zig to 0.13.0
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig47
1 files changed, 33 insertions, 14 deletions
diff --git a/build.zig b/build.zig
index 4e02250..b2f4f0a 100644
--- a/build.zig
+++ b/build.zig
@@ -15,23 +15,33 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
- const exe = b.addExecutable(.{
+ const lib = b.addStaticLibrary(.{
.name = "RayTracingInOneWeekend",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
- .root_source_file = .{ .path = "src/main.zig" },
+ .root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
- exe.root_module.addAnonymousImport(
- "zigimg",
- .{
- .root_source_file = .{
- .path = "deps/zigimg/zigimg.zig",
- },
- },
- );
+ // This declares intent for the library to be installed into the standard
+ // location when the user invokes the "install" step (the default step when
+ // running `zig build`).
+ b.installArtifact(lib);
+
+ const exe = b.addExecutable(.{
+ .name = "RayTracingInOneWeekend",
+ .root_source_file = b.path("src/main.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const zigimg_dependency = b.dependency("zigimg", .{
+ .target = target,
+ .optimize = optimize,
+ });
+
+ exe.root_module.addImport("zigimg", zigimg_dependency.module("zigimg"));
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
@@ -63,17 +73,26 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
- const unit_tests = b.addTest(.{
- .root_source_file = .{ .path = "src/main.zig" },
+ const lib_unit_tests = b.addTest(.{
+ .root_source_file = b.path("src/root.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
+
+ const exe_unit_tests = b.addTest(.{
+ .root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
- const run_unit_tests = b.addRunArtifact(unit_tests);
+ 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_unit_tests.step);
+ test_step.dependOn(&run_lib_unit_tests.step);
+ test_step.dependOn(&run_exe_unit_tests.step);
}