Best way to release packages for libraries?

One slightly different take on that idea might be to craft a generic build.zig, that parses the build.zig.zon in the same folder and adds every dependency via a predictable scheme as importable modules.

That way you could just copy that build.zig where you want it and then use it.
Similarly it could take the name for the exe also from the build.zig.zon.

One other possibility would be to write a script that uses build.zig.zon and then calls zig fetch and then uses zig build-exe with passing parameters corresponding to the things in the build.zig.zon, but all of that seems brittle and more complicated to me.

I think if you want to have a whole bunch of small tools with a few dependencies, maybe just put all of them in one project and have one shared build.zig and build.zig.zon for them, and have the build.zig, create separate executables for all the different mini applications.

Basically I think trying to use less files isn’t really paying of, you still would need separate folders for the application.zig+build.zig.zon pair, so adding a third file doesn’t really cost anything.

2 Likes