ryupold / raylib.zig

Idiomatic Zig bindings for raylib utilizing raylib_parser
MIT License
215 stars 35 forks source link

It doesn't build on latest zig #39

Open AntonC9018 opened 6 months ago

AntonC9018 commented 6 months ago

Trying to build a project using raylib with zig version

0.12.0-dev.3193+4ba4f94c9

Getting the following error.

As you can see the problem is that zig build now expects relative paths to c source files from the root build folder. So I've fixed that by changing the paths to be relative in build.zig of the raylib submodule. Now I get a different error, about marshal.h not being found.

Then I realized the raylib submodule is just raylib, so I switched that to master. Now this is the error: https://pastebin.com/YZe4grhz Which pushed me to try and regenerate the bindings. A file didn't compile because of FileSource missing. I've fixed that too by writing a custom relative path function, just like in the other file:

const srcdir = struct {
    fn f() []const u8 {
        return std.fs.path.dirname(@src().file).?;
    }
}.f();

fn srcRelative(comptime path: []const u8) std.Build.LazyPath {
    return .{ .path = srcdir ++ path };
}

(but later found out it's been renamed to LazyPath).

Now I've tried to regenerate the bindings. zig build parse worked, zig build intermediate failed with UnexpectedToken.

At this point I think I'm getting way too deep. Maintainer, please fix.

AntonC9018 commented 6 months ago

Ah didn't see this https://github.com/ryupold/raylib.zig/issues/37

AntonC9018 commented 6 months ago

I have found why the json conversion fails. The type of the field RaylibDefine.value is a string, but the json contains numbers instead, sometimes. std.json fails to convert from numbers to strings. Must be a recent change as well. The fix would be to either modify the raylib_parser.c to always output strings where strings are expected, or modify the parser in the zig standard library to accept numbers as strings.