Embed binary data at compile time

You escape braces in format strings by doubling them.

What I dislike about it is that it generates one big source file that encodes binary data as text (which then gets converted back into binary by the compiler), if any of the input files are changed you need to re-convert all files not just the ones that changed (depends on your use-case whether that is a problem).


But I am also unsure whether there is an easy build-cache friendly alternative for handling a folder of files that you want to transform and then embed, without re-doing unnecessary work.

If your build script walks the directory to enumerate the individual files, it could create a run-step for each individual file to convert it from svg to tvg, then you could use one addWriteFiles to collect all the transformed output files in one directory that should be cached by the build system and only re-run the individual conversions for input-svgs that changed. (haven’t tested this specific scenario)

That wouldn’t handle adding or removing files while using watch or incremental builds, but should allow editing existing files.

I think the resulting wf.getDirectory() then could be passed on to Zig Asset Bundler

There is also this older related topic:


Overall I would say, I don’t think your solution is ideal, or should be the go to solution long term, but if it works for you, it might be the pragmatic solution for now, until somebody shows how to handle this more simply / idiomatically.