Closed Ev1lT3rm1nal closed 3 months ago
@Not-Nik What do you think?
Hi @Ev1lT3rm1nal,
wouldn't this already be enough?:
snippet from a build.zig
using raylib-zig
:
// ...
const exe = b.addExecutable(.{
.name = "my-executable-name",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const raylib_dep = b.dependency("raylib-zig", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("raylib", raylib_dep.module("raylib"));
exe.linkLibrary(raylib_dep.artifact("raylib"));
// ...
snippet from a build.zig.zon
using raylib-zig
:
//...
.dependencies = .{
.@"raylib-zig" = .{
.url = "https://github.com/stefanpartheym/raylib-zig/archive/0c94e9f48626ad3cae3f1bd2dea218d334a1839f.tar.gz",
.hash = "12207d73b118b050394da32101996d615e2385380b99843c942efcd8e64222dc3e23",
},
},
// ...
Note: I'm using my own fork of raylib-zig for compatibility with zig 0.12.0-dev. But in your case, you could probably already use the main repo, if you're on an older zig version.
Best regards Stefan
@stefanpartheym You are absolutely right, this is something I should have done ages ago, when package manager support was first added. The build code looks slightly different on 0.11.0 (which is the Zig version this project currently mainly targets), but it works all the same. I have now updated the project_setup.sh
script to reflect this. The emscripten build still uses part of the binding build script, but I have isolated that code into its own file, so it can easily be copied. Also the project generation script will always be behind the main repository by a few commits, but everything should still work. Too bad you can't leave out the hash in a dependency.
To my knowledge, using this library requires you to clone it. However, I suspect there's a more efficient method to incorporate it as a dependency in
build.zig.zon
.I implemented the following adjustments to make it work:
In
build.zig.zon
raylib-zig's
build.zig
Similarly for math:
However, I've encountered an issue with
getRaylib()
as it requires adding the original raylib dependency, which necessitates a workaround to resolve.Also, it’s better to use path.join rather than just sticking paths together with concatenation.