Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest zig development version introduced breaking changes for build.zig #68

Closed
eshom opened this issue Feb 2, 2024 · 1 comment
Closed

Comments

@eshom
Copy link

eshom commented Feb 2, 2024

I am using latest zig version at the time of writing this (0.12.0-dev.2541+894493549).
Both raylib-zig's and the generated project's build.zig do not compile.

Person that opened #66 encountered some of the problems due to recent changes.

I tried to somehow patch build.zig by following the compiler errors but got lost along the way.
I'm also relatively new to zig.

This is as far as I've gotten. I'm not sure if it's even correct and otherwise I'm completely stumped.

diff --git a/build.zig b/build.zig
index f7b32d0..8d1b91d 100755
--- a/build.zig
+++ b/build.zig
@@ -84,30 +84,30 @@ pub fn getModule(b: *std.Build, comptime rl_path: []const u8) *std.Build.Module
     if (b.modules.contains("raylib")) {
         return b.modules.get("raylib").?;
     }
-    return b.addModule("raylib", .{ .source_file = .{ .path = rl_path ++ "/lib/raylib-zig.zig" } });
+    return b.addModule("raylib", .{ .root_source_file = .{ .path = rl_path ++ "/lib/raylib-zig.zig" } });
 }
 
 fn getModuleInternal(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" } });
+    return b.addModule("raylib", .{ .root_source_file = .{ .path = "lib/raylib-zig.zig" } });
 }
 
 pub const math = struct {
     pub fn getModule(b: *std.Build, comptime rl_path: []const u8) *std.Build.Module {
         const raylib = rl.getModule(b, rl_path);
         return b.addModule("raylib-math", .{
-            .source_file = .{ .path = rl_path ++ "/lib/raylib-zig-math.zig" },
+            .root_source_file = .{ .path = rl_path ++ "/lib/raylib-zig-math.zig" },
             .dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
         });
     }
 
     fn getModuleInternal(b: *std.Build) *std.Build.Module {
-        const raylib = rl.getModuleInternal(b);
+        //const raylib = rl.getModuleInternal(b);
         return b.addModule("raylib-math", .{
-            .source_file = .{ .path = "lib/raylib-zig-math.zig" },
-            .dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
+            .root_source_file = .{ .path = "lib/raylib-zig-math.zig" },
+            //.dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
         });
     }
 };
@@ -185,11 +185,11 @@ pub fn build(b: *std.Build) !void {
     const raylib_math = rl.math.getModuleInternal(b);
 
     for (examples) |ex| {
-        if (target.getOsTag() == .emscripten) {
-            const exe_lib = compileForEmscripten(b, ex.name, ex.path, target, optimize);
-            exe_lib.addModule("raylib", raylib);
-            exe_lib.addModule("raylib-math", raylib_math);
-            const raylib_lib = getRaylib(b, target, optimize);
+        if (target.result.os.tag == .emscripten) {
+            const exe_lib = compileForEmscripten(b, ex.name, ex.path, target.query, optimize);
+            exe_lib.root_module.addImport("raylib", raylib);
+            exe_lib.root_module.addImport("raylib-math", raylib_math);
+            const raylib_lib = getRaylib(b, target.query, optimize);
 
             // Note that raylib itself isn't actually added to the exe_lib
             // output file, so it also needs to be linked with emscripten.
@@ -209,9 +209,9 @@ pub fn build(b: *std.Build) !void {
                 .optimize = optimize,
                 .target = target,
             });
-            rl.link(b, exe, target, optimize);
-            exe.addModule("raylib", raylib);
-            exe.addModule("raylib-math", raylib_math);
+            rl.link(b, exe, target.query, optimize);
+            exe.root_module.addImport("raylib", raylib);
+            exe.root_module.addImport("raylib-math", raylib_math);
             const run_cmd = b.addRunArtifact(exe);
             const run_step = b.step(ex.name, ex.desc);
             run_step.dependOn(&run_cmd.step);
@Not-Nik
Copy link
Owner

Not-Nik commented Feb 3, 2024

This binding does not intend to keep up with every development version of the Zig compiler, but instead targets the latest release.

@Not-Nik Not-Nik closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants