diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | build.zig | 47 | ||||
| -rw-r--r-- | build.zig.zon | 39 | ||||
| m--------- | deps/zigimg | 0 | ||||
| -rw-r--r-- | src/root.zig | 0 |
6 files changed, 73 insertions, 18 deletions
@@ -1,3 +1,3 @@ -/zig-cache +/.zig-cache /zig-out /out.png diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 63ed6e7..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "deps/zigimg"] - path = deps/zigimg - url = https://github.com/zigimg/zigimg.git @@ -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); } diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..e35459c --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,39 @@ +.{ + // This is the default name used by packages depending on this one. For + // example, when a user runs `zig fetch --save <url>`, this field is used + // as the key in the `dependencies` table. Although the user can choose a + // different name, most users will stick with this provided value. + // + // It is redundant to include "zig" in this name because it is already + // within the Zig package namespace. + .name = "RayTracingInOneWeekend", + + // This is a [Semantic Version](https://semver.org/). + // In a future version of Zig it will be used for package deduplication. + .version = "0.1.0", + + // This field is optional. + // This is currently advisory only; Zig does not yet do anything + // with this value. + //.minimum_zig_version = "0.11.0", + + // This field is optional. + // Each dependency must either provide a `url` and `hash`, or a `path`. + // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. + // Once all dependencies are fetched, `zig build` no longer requires + // internet connectivity. + .dependencies = .{ + .zigimg = .{ + .url = "https://github.com/zigimg/zigimg/archive/d9dbbe22b5f7b5f1f4772169ed93ffeed8e8124d.tar.gz", + .hash = "122013646f7038ecc71ddf8a0d7de346d29a6ec40140af57f838b0a975c69af512b0", + }, + }, + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + // For example... + //"LICENSE", + //"README.md", + }, +} diff --git a/deps/zigimg b/deps/zigimg deleted file mode 160000 -Subproject 637974e2d31dcdbc33f1e9cc8ffb2e46abd2e21 diff --git a/src/root.zig b/src/root.zig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/root.zig |
