Not-Nik / raylib-zig

Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib
MIT License
473 stars 101 forks source link

Updates for zig build #35

Closed charlieman closed 1 year ago

charlieman commented 1 year ago

This updates the build.zig file to work with the new Build API, which raylib master is already using. It also uses the new indexing in for loops.

In raylib-zig-math.zig I had to import raylib as a module instead of the file directly otherwise zig complains with this error:

lib\raylib-zig.zig:1:1: error: file exists in multiple modules
lib\raylib-zig.zig:1:1: note: root of module root.raylib
lib\raylib-zig-math.zig:1:20: note: imported from module root.raylib-math
const rl = @import("raylib-zig.zig");
                   ^~~~~~~~~~~~~~~~
lib\raylib-wa.zig:1:20: note: imported from module root.raylib
const rl = @import("raylib-zig.zig");
                   ^~~~~~~~~~~~~~~~

Running the generator also added/removed some functions.

Tested the examples with zig version 0.11.0-dev.1910+6d7fb8f19

Not-Nik commented 1 year ago

Reopen when Zig 0.11 is released

ezntek commented 9 months ago

zig 0.11 is now released, and I added it in the build.zig.zon file, with all the metadata. However, when building, zig build panics on unable to find artifact 'raylib'.

relavant extract of build.zig:

    const raylib = b.dependency("raylib", .{
        .target = target,
        .optimize = optimize,
    });

    const exe = b.addExecutable(.{
        .name = "beanmaths",
        // In this case the main source file is merely a path, however, in more
        // complicated build scripts, this could be a generated file.
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    exe.addModule("raylib", raylib.module("raylib"));
    exe.linkLibrary(raylib.artifact("raylib"));

    // This declares intent for the executable to be installed into the
    // standard location when the user invokes the "install" step (the default
    // step when running `zig build`).
    b.installArtifact(exe);
Not-Nik commented 9 months ago

Maybe that's because in our build.zig.zon the library is called raylib-zig

ezntek commented 9 months ago

well its named raylib in mine, and the tarball is independent from the package name in youyr build.zig.zon.

I still changed it, and it still doesnt work, with the error being unable to find module