Instead of exporting
pub const Ghext = @import("src/ghext.zig");
in the build.zig
my suggestion would be to create a module that somebody can use if they want to use it in their application and if they want to use it in a build script you could provide that by creating an application (that internally uses that module for its implementation but wraps a cli interface around it) and then use that tool with addRunArtifact
.
I think it would be a combination of this:
https://ziglang.org/learn/build-system/#project-tools and what is described by Zig Build System Basics
The benefit would be that all the code runs purely at runtime (within a build context or not) could be shared between application and build-time usages and there would be no reason to try to do anything at comptime or avoiding allocation.
(I haven’t fully understood why you try to avoid allocation, seemingly because you try to do things at comptime, which in my opinion doesn’t make sense, because long-term comptime will be locked down more and more and this code shouldn’t need comptime anyway)