diff --git a/build.zig b/build.zig index f038af1b..0a70619d 100644 --- a/build.zig +++ b/build.zig @@ -37,8 +37,8 @@ pub fn build(b: *std.Build) !void { const font_assets_dep = b.dependency("font_assets", .{}); const module = b.addModule("mach", .{ - .source_file = .{ .path = sdkPath("/src/main.zig") }, - .dependencies = &.{ + .root_source_file = .{ .path = sdkPath("/src/main.zig") }, + .imports = &.{ .{ .name = "mach-core", .module = mach_core_dep.module("mach-core") }, .{ .name = "mach-ecs", .module = mach_ecs_dep.module("mach-ecs") }, .{ .name = "mach-sysaudio", .module = mach_sysaudio_dep.module("mach-sysaudio") }, @@ -50,7 +50,7 @@ pub fn build(b: *std.Build) !void { }, }); - if (target.getCpuArch() != .wasm32) { + if (target.result.cpu.arch != .wasm32) { // Creates a step for unit testing. This only builds the test executable // but does not run it. const unit_tests = b.addTest(.{ @@ -58,28 +58,27 @@ pub fn build(b: *std.Build) !void { .target = target, .optimize = optimize, }); - var iter = module.dependencies.iterator(); + var iter = module.import_table.iterator(); while (iter.next()) |e| { - unit_tests.addModule(e.key_ptr.*, e.value_ptr.*); + unit_tests.root_module.addImport(e.key_ptr.*, e.value_ptr.*); } - // TODO: move link into a helper function shared between tests in App - @import("mach_freetype").linkFreetype(mach_freetype_dep.builder, unit_tests); - @import("mach_freetype").linkHarfbuzz(mach_freetype_dep.builder, unit_tests); - // Exposes a `test` step to the `zig build --help` menu, providing a way for the user to // request running the unit tests. const run_unit_tests = b.addRunArtifact(unit_tests); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_unit_tests.step); - const install_docs = b.addInstallDirectory(.{ - .source_dir = unit_tests.getEmittedDocs(), - .install_dir = .prefix, // default build output prefix, ./zig-out - .install_subdir = "docs", - }); - const docs_step = b.step("docs", "Generate API docs"); - docs_step.dependOn(&install_docs.step); + // TODO: autodoc segfaults the build if we have this enabled + // https://github.com/hexops/mach/issues/1145 + // + // const install_docs = b.addInstallDirectory(.{ + // .source_dir = unit_tests.getEmittedDocs(), + // .install_dir = .prefix, // default build output prefix, ./zig-out + // .install_subdir = "docs", + // }); + // const docs_step = b.step("docs", "Generate API docs"); + // docs_step.dependOn(&install_docs.step); } } diff --git a/build.zig.zon b/build.zig.zon index e2855697..50b0aa45 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -12,32 +12,32 @@ }, .dependencies = .{ .mach_ecs = .{ - .url = "https://pkg.machengine.org/mach-ecs/7267d8eb26ced985f65d4526770e96af488d007c.tar.gz", - .hash = "1220d252360b3ddb0e9a3d813f179142a455c089eccdfdb5e4615b6d39fab5e23e96", + .url = "https://pkg.machengine.org/mach-ecs/2b921e55de07c3554a5490fca29738104ab07b37.tar.gz", + .hash = "1220a5785894922edb70e84f5e00917defbffc64ee16e88cc8fdb3ccf68c9b244a5d", }, .mach_core = .{ - .url = "https://pkg.machengine.org/mach-core/cce02fb96ca787378289c5855b381f0ca9f3e090.tar.gz", - .hash = "122096b39d9266d275b780df4d63b1afe6e9a3726f19766baf74b34af3f092532cd3", + .url = "https://pkg.machengine.org/mach-core/370bc1504cebaffcda5ed1ae9915fd2ac6778479.tar.gz", + .hash = "12205da1ecba58ba8c9ca65dbf75e32f42fde0490d34a98596ae72d4d3db81659dc5", }, .mach_basisu = .{ - .url = "https://pkg.machengine.org/mach-basisu/30897f45e8d2d58ac90f1e8fbe15ceabe2127adb.tar.gz", - .hash = "1220db419f993fe9204580f761f8d805a9cb07fa910f182899089ad0f4873bfd8b49", + .url = "https://pkg.machengine.org/mach-basisu/5a68105a5e503c7183aab481b7ec6ae16b996943.tar.gz", + .hash = "12204098c8d8d15a687068a3c0b15fe95d20f8fe074531e34e78f9dfe518cf86a67c", }, .mach_sysaudio = .{ - .url = "https://pkg.machengine.org/mach-sysaudio/ec0d3e4a9f053163b4b99ca96d10fd1912563b55.tar.gz", - .hash = "1220a547d08517c7be1b3b0fd2806a399cb71d4189ab5a794f58570af215adc3903a", + .url = "https://pkg.machengine.org/mach-sysaudio/8e4d73150af291d63a5390b157552ce0bbcd4a1d.tar.gz", + .hash = "12206c2ca0378bbc54721553e8167c037325e95e2791379fbe0e245a34334679dc90", }, .mach_freetype = .{ - .url = "https://pkg.machengine.org/mach-freetype/a6d971285dfe731e49f82e81c81da2b7f5c6a442.tar.gz", - .hash = "1220e0de43cacb583b8f9efddcbe359398cfca17a39e265b56c8f2a10314eb8f7a5f", + .url = "https://pkg.machengine.org/mach-freetype/7546a906b6c4b308b98d36264dfbe32ca24ae579.tar.gz", + .hash = "12205faaaaf547019f0763ac620af77fff2728b8eb4222b62120ee224ce53392cf31", }, .mach_sysjs = .{ - .url = "https://pkg.machengine.org/mach-sysjs/bafd6c9b8fd5e7be1e8e24cfbd156703d6026aa8.tar.gz", - .hash = "1220187935c4c5d4cf824927df28e858dcd06cb864bb5d6be4cd349d2836abb4aec4", + .url = "https://pkg.machengine.org/mach-sysjs/eeef024f79beae189b7a4ed85e64ed076e76d538.tar.gz", + .hash = "1220db6845ce34743ae2a1ab0222efc942496adde2736c20e3443d4fde4ef64b11b9", }, .font_assets = .{ - .url = "https://github.com/hexops/font-assets/archive/4c6ed096d705fb98f811f010ca1237a260c88617.tar.gz", - .hash = "122008070b460fcb5d513362fd9ee21cda3e8984920ca4239f6190cedda1ea2b8de8", + .url = "https://github.com/hexops/font-assets/archive/6b43c160451e8fa5c64620ffb614929feacf2f5d.tar.gz", + .hash = "12202039304f0603a9706105788e450fd4f901c3e20eca28a52a2173879b14c606c7", }, }, } diff --git a/src/gfx/atlas/Atlas.zig b/src/gfx/atlas/Atlas.zig index 56eaed9e..c8b68d0d 100644 --- a/src/gfx/atlas/Atlas.zig +++ b/src/gfx/atlas/Atlas.zig @@ -144,7 +144,7 @@ pub fn reserve(self: *Atlas, alloc: Allocator, width: u32, height: u32) !Region if (width == 0 and height == 0) return region; // Find the location in our nodes list to insert the new node for this region. - var best_idx: usize = best_idx: { + const best_idx: usize = best_idx: { var best_height: u32 = std.math.maxInt(u32); var best_width: u32 = best_height; var chosen: ?usize = null; @@ -256,11 +256,8 @@ pub fn set(self: *Atlas, reg: Region, data: []const u8) void { while (i < reg.height) : (i += 1) { const tex_offset = (((reg.y + i) * self.size) + reg.x) * depth; const data_offset = i * reg.width * depth; - std.mem.copy( - u8, - self.data[tex_offset..], - data[data_offset .. data_offset + (reg.width * depth)], - ); + const src = data[data_offset .. data_offset + (reg.width * depth)]; + @memcpy(self.data[tex_offset .. tex_offset + src.len], src); } self.modified = true; diff --git a/src/math/mat.zig b/src/math/mat.zig index 6590d0b2..3b832577 100644 --- a/src/math/mat.zig +++ b/src/math/mat.zig @@ -752,7 +752,7 @@ test "Mat2x2_mulVec_vec2_ident" { const v = math.Vec2.splat(1); const ident = math.Mat2x2.ident; const expected = v; - var m = math.Mat2x2.mulVec(&ident, &v); + const m = math.Mat2x2.mulVec(&ident, &v); try testing.expect(math.Vec2, expected).eql(m); } diff --git a/src/math/ray.zig b/src/math/ray.zig index ae55533d..b69a8450 100644 --- a/src/math/ray.zig +++ b/src/math/ray.zig @@ -72,7 +72,7 @@ pub fn Ray(comptime Vec3P: type) type { vc: *const Vec3P, backface_culling: bool, ) ?Hit { - var kz: u8 = maxDim([3]P{ + const kz: u8 = maxDim([3]P{ @abs(ray.direction.v[0]), @abs(ray.direction.v[1]), @abs(ray.direction.v[2]), @@ -110,25 +110,25 @@ pub fn Ray(comptime Vec3P: type) type { var u: P = cx * by - cy * bx; var v: P = ax * cy - ay * cx; - var w: P = bx * ay - by * ax; + const w: P = bx * ay - by * ax; // Double precision fallback if (u == 0.0 or v == 0.0 or w == 0.0) { const cxby: PP = @as(PP, @floatCast(cx)) * @as(PP, @floatCast(by)); - var cybx: PP = @as(PP, @floatCast(cy)) * + const cybx: PP = @as(PP, @floatCast(cy)) * @as(PP, @floatCast(bx)); u = @floatCast(cxby - cybx); - var axcy: PP = @as(PP, @floatCast(ax)) * + const axcy: PP = @as(PP, @floatCast(ax)) * @as(PP, @floatCast(cy)); - var aycx: PP = @as(PP, @floatCast(ay)) * + const aycx: PP = @as(PP, @floatCast(ay)) * @as(PP, @floatCast(cx)); v = @floatCast(axcy - aycx); - var bxay: PP = @as(PP, @floatCast(bx)) * + const bxay: PP = @as(PP, @floatCast(bx)) * @as(PP, @floatCast(ay)); - var byax: PP = @as(PP, @floatCast(by)) * + const byax: PP = @as(PP, @floatCast(by)) * @as(PP, @floatCast(ax)); v = @floatCast(bxay - byax); }