The toolchain itself is fully generic in cmake/zig-toolchain.cmake and to add a new toolchain just create <triplet>.cmake and include that helper. I only added support for the platforms I actually needed to compile to, but it has UEFI, WASI, Windows/Mac/Linux and adding support for a new platform is easy enough.
One thing I’d love to see is a guide on how to migrate a C/C++ project to Zig. The only recommendation for learning I’ve ever heard is to watch the livestream of Andrew Kelley and Loris Cro migrating Redis to the Zig build system, but that was four years ago, so I’m sure the process has changed. And the video looks like it’s not even online anymore.
I’ve learned a little bit of Zig, but I found the build file one of the hardest parts to understand, and I don’t know how to do anything much more complex than the basic build configuration you get from zig init.
Previously
If you do not want to change the project you can use one of my CMake toolchains here: https://github.com/mrexodia/zig-cross
To build a CMake project for a different project all you need to do is:
The toolchain itself is fully generic in
cmake/zig-toolchain.cmakeand to add a new toolchain just create<triplet>.cmakeand include that helper. I only added support for the platforms I actually needed to compile to, but it has UEFI, WASI, Windows/Mac/Linux and adding support for a new platform is easy enough.This is a cool effort!
One thing I’d love to see is a guide on how to migrate a C/C++ project to Zig. The only recommendation for learning I’ve ever heard is to watch the livestream of Andrew Kelley and Loris Cro migrating Redis to the Zig build system, but that was four years ago, so I’m sure the process has changed. And the video looks like it’s not even online anymore.
I’ve learned a little bit of Zig, but I found the build file one of the hardest parts to understand, and I don’t know how to do anything much more complex than the basic build configuration you get from
zig init.Reading is the best way to learn, and I think All Your Codebase is a good resource for that.
The problem is that it’s hard to unders the basics that way. For example, ffmpeg’s build.zig is 7k LOC, so that’s a hard one to learn from.
Can you recommend any that you’d describe as good beginner-level repos?