ryupold / examples-raylib.zig

Example usage of raylib.zig bindings
MIT License
43 stars 4 forks source link

Not possible to build examples anymore with zig 0.11.0-dev.2652+ #3

Closed alfredbaudisch closed 1 year ago

alfredbaudisch commented 1 year ago

I am just getting started with Zig, and the first version I got is 0.11.0-dev.2652. With it, it's not possible to build your wasm examples anymore:

lib.setOutputDir(webCachedir); https://github.com/ryupold/examples-raylib.zig/blob/main/build.zig#L123

error: no field or member function named 'setOutputDir' in 'Build.CompileStep'

Also lib.install doesn't work anymore, but this one I managed to changed to b.installArtifact(lib). But still, due to not being able to setOutputDir, it's not possible to build for web anymore.

I tried installing Zig 0.10, but then there's even more incompatibilities. Which version of 0.11.* are you targeting currently?

Thanks!

alfredbaudisch commented 1 year ago

setOutputDir was removed last week: https://github.com/ziglang/zig/commit/5a8b1bde5b3ce2628a8e490c3cef9fcc95f94ab5

ryupold commented 1 year ago

Hey, thanks for testing with the newest version. My last update was with the 0.11 version from 21th March and until now I did not update. I updated to the newest version and now also getting the errors. I see that this problem is also in the build.zig of the raylib repository as they are also using setOutDir. But where can I now set the output directory?

alfredbaudisch commented 1 year ago

I'm new to the zig ecosystem too.

It seems that now we have to use b.installDirectory(.{ .source_dir = "", .install_dir = .{ .custom = webCachedir }, .install_subdir = webCachedir }); (this doesn't work because I don't know which paths to set).

But then how to mimic what was a simple single directory with "setOutputDir"? It seems complicated now.

ryupold commented 1 year ago

I couldn't figure out how to set the output dir otherwise but with installArtifact as you mentioned in the beginning.

const libraryOutputFolder = "zig-out/lib/";
// this installs the lib (libraylib-zig-examples.a) to the `libraryOutputFolder` folder
b.installArtifact(lib);

then I pass this folder also to the emcc build so it can find the static library. I liked it better the way it was before but now it works again at least.

alfredbaudisch commented 1 year ago

Thanks for sharing, this also helps learn more about the zig builder.