aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--build.zig47
-rw-r--r--build.zig.zon39
m---------deps/zigimg0
-rw-r--r--src/root.zig0
6 files changed, 73 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 1f79df4..d48bc97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
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);
}
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