From 4796ff6de5fb6e7b229fba15414b322061671293 Mon Sep 17 00:00:00 2001 From: copygirl Date: Tue, 20 Feb 2024 12:05:42 +0100 Subject: [PATCH] Add zmath dependency --- README.md | 20 ++++++++++++++++---- build.zig | 10 +++++++++- build.zig.zon | 1 + libs/zig-gamedev | 1 + 4 files changed, 27 insertions(+), 5 deletions(-) create mode 160000 libs/zig-gamedev diff --git a/README.md b/README.md index a669e5a..22f1400 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,19 @@ # Zig Bloxel Game -This is a small project attempting to create a "bloxel" game (think Minecraft) using the relatively new [Zig] programming language with the help of [Mach] and [Flecs]. +This is a small project attempting to create a "bloxel" game (think Minecraft) using the relatively new [Zig] programming language with the help of [Mach], [Flecs] and [zig-gamedev]. Due to Zig being a quickly evolving language, Mach and zig-gamedev, and as a result this project, target version `0.12.0-dev.2063+804cee3b9` of Zig. -[Zig]: https://ziglang.org/ -[Mach]: https://machengine.org/ -[Flecs]: https://flecs.dev/ +[Zig]: https://ziglang.org/ +[Mach]: https://github.com/hexops/mach-core +[Flecs]: https://github.com/SanderMertens/flecs +[zig-gamedev]: https://github.com/zig-gamedev/zig-gamedev + +## Dependencies + +```sh +mkdir -p libs && cd libs +# Clone zig-gamedev sparsely, only grabbing top-level files. +git clone --sparse --filter=blob:none https://github.com/zig-gamedev/zig-gamedev.git +# However, we also care about zmath, so check that out too. +cd zig-gamedev +git sparse-checkout add libs/zmath +``` diff --git a/build.zig b/build.zig index b224710..1a3091a 100644 --- a/build.zig +++ b/build.zig @@ -1,10 +1,15 @@ const std = @import("std"); const mach_core = @import("mach_core"); +const zmath = @import("zmath"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const zmath_pkg = zmath.package(b, target, optimize, .{ + .options = .{ .enable_cross_platform_determinism = true }, + }); + const mach_core_dep = b.dependency("mach_core", .{ .target = target, .optimize = optimize, @@ -14,7 +19,9 @@ pub fn build(b: *std.Build) !void { .src = "src/main.zig", .target = target, .optimize = optimize, - .deps = &.{}, + .deps = &.{ + .{ .name = "zmath", .module = zmath_pkg.zmath }, + }, }); if (b.args) |args| app.run.addArgs(args); @@ -26,6 +33,7 @@ pub fn build(b: *std.Build) !void { .target = target, .optimize = optimize, }); + unit_tests.root_module.addImport("zmath", zmath_pkg.zmath); const run_unit_tests = b.addRunArtifact(unit_tests); const test_step = b.step("test", "Run unit tests"); diff --git a/build.zig.zon b/build.zig.zon index cac1b77..43c92be 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -14,5 +14,6 @@ .url = "https://pkg.machengine.org/mach-core/6a62bcc90e0d072d632788a6575d77942bd09a19.tar.gz", .hash = "12209d39954fcda0be158461c10f64d14d5c7d097bd6d26785b332d75ffefa7dd7a0", }, + .zmath = .{ .path = "libs/zig-gamedev/libs/zmath" }, }, } diff --git a/libs/zig-gamedev b/libs/zig-gamedev new file mode 160000 index 0000000..25e1794 --- /dev/null +++ b/libs/zig-gamedev @@ -0,0 +1 @@ +Subproject commit 25e1794d608d6a1d13e84a42d98c950fd250050d