From 0d4cc3ac8c6fbe09331cb0e0793f124ddf6b2bdf Mon Sep 17 00:00:00 2001 From: Not-Nik Date: Sat, 5 Aug 2023 20:10:10 +0200 Subject: [PATCH] Fix file exists in multiple modules error when including raymath --- build.zig | 7 ++++++- build.zig.zon | 6 +++--- lib/preludes/raylib-zig-math-ext-prelude.zig | 2 +- lib/preludes/raylib-zig-math-prelude.zig | 2 +- lib/raylib-zig-math-ext.zig | 2 +- lib/raylib-zig-math.zig | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index edb7aaa..b3a06cc 100755 --- a/build.zig +++ b/build.zig @@ -2,6 +2,7 @@ const std = @import("std"); const Builder = std.build.Builder; +const rl = @This(); const Program = struct { name: []const u8, @@ -65,12 +66,16 @@ pub fn getArtifact(b: *std.Build, target: std.zig.CrossTarget, optimize: std.bui } pub fn getModule(b: *std.Build) *std.Build.Module { + if (b.modules.contains("raylib")) { + return b.modules.get("raylib").?; + } return b.addModule("raylib", .{ .source_file = .{ .path = "lib/raylib-zig.zig" } }); } pub const math = struct { pub fn getModule(b: *std.Build) *std.Build.Module { - return b.addModule("raylib-math", .{ .source_file = .{ .path = "lib/raylib-zig-math.zig" } }); + var raylib = rl.getModule(b); + return b.addModule("raylib-math", .{ .source_file = .{ .path = "lib/raylib-zig-math.zig" }, .dependencies = &.{.{ .name = "raylib-zig", .module = raylib }} }); } }; diff --git a/build.zig.zon b/build.zig.zon index 3454b14..fea3cc5 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .raylib = .{ - .url = "https://github.com/raysan5/raylib/archive/ad2338b994785c887528c91a843d6720cac2c2b0.tar.gz", - .hash = "122003990d16146cfb85e04e0557f41b54e81bae635fa4379f3a597ed5fb7716ee53", + .url = "https://github.com/raysan5/raylib/archive/6094869e3e845e90e1e8ae41b98e889fb3e13e78.tar.gz", + .hash = "12203b7a16bcf8d7fe4c9990a46d92b6f2e35531a4b82eb3bdf8ba4a0dbcc5f21415", }, }, -} \ No newline at end of file +} diff --git a/lib/preludes/raylib-zig-math-ext-prelude.zig b/lib/preludes/raylib-zig-math-ext-prelude.zig index 2f06d97..0003276 100644 --- a/lib/preludes/raylib-zig-math-ext-prelude.zig +++ b/lib/preludes/raylib-zig-math-ext-prelude.zig @@ -1,4 +1,4 @@ // raylib-zig (c) Nikolas Wipper 2023 -const rl = @import("raylib-zig.zig"); +const rl = @import("raylib-zig"); const rlm = @import("raylib-zig-math.zig"); diff --git a/lib/preludes/raylib-zig-math-prelude.zig b/lib/preludes/raylib-zig-math-prelude.zig index 479425f..d16aea1 100644 --- a/lib/preludes/raylib-zig-math-prelude.zig +++ b/lib/preludes/raylib-zig-math-prelude.zig @@ -1,6 +1,6 @@ // raylib-zig (c) Nikolas Wipper 2023 -const rl = @import("raylib-zig.zig"); +const rl = @import("raylib-zig"); const cdef = @import("raylib-zig-math-ext.zig"); const std = @import("std"); diff --git a/lib/raylib-zig-math-ext.zig b/lib/raylib-zig-math-ext.zig index 207c668..c444874 100644 --- a/lib/raylib-zig-math-ext.zig +++ b/lib/raylib-zig-math-ext.zig @@ -1,6 +1,6 @@ // raylib-zig (c) Nikolas Wipper 2023 -const rl = @import("raylib-zig.zig"); +const rl = @import("raylib-zig"); const rlm = @import("raylib-zig-math.zig"); pub extern "c" fn Clamp(value: f32, min: f32, max: f32) f32; diff --git a/lib/raylib-zig-math.zig b/lib/raylib-zig-math.zig index c4ed490..63054f5 100755 --- a/lib/raylib-zig-math.zig +++ b/lib/raylib-zig-math.zig @@ -1,6 +1,6 @@ // raylib-zig (c) Nikolas Wipper 2023 -const rl = @import("raylib-zig.zig"); +const rl = @import("raylib-zig"); const cdef = @import("raylib-zig-math-ext.zig"); const std = @import("std");