Is there a way to get a list of the files involved in a build?

After building a wasm file, I want to put watches on the files involved so that I can initiate a rebuild as soon as any of those files changes. Is there a way I can get this list from the compiler? I see a number of listings in zig-cache/h. Obviously I would rather not touch stuff I’m not supposed to be touching.

Files “involved in a build” are way too many files - if you did, you’d often be in a permanent build loop. Anything in the cache is off-limits. What you need to know is the set of input files to the build process (including your dependencies and not just zig source and direct C imports, which is all the compiler itself could tell you about).

For the most part, it’s simpler to set up build on save in your editor, and perhaps a watch for a folder where you keep your assets edited by something other than your programming editor. That would cover the majority of your cases.


I’m working on a Rollup/Vite plugin. I have to hand the list of dependencies to Vite so that HMR would work as the user expect.

The files that you found in zig-cache/h are called manifests.

The header of the manifest (first line) is a single 0 and then each line consists of file information (file size, i-node, last modification time, contents hex digest, prefix enum, path under prefix). The first file (in 2nd line) normally is the root.

See the code that writes the manifest: std.Build.Cache.Manifest.writeManifest

1 Like

Thanks for the info. If there’s no other way then I’ll scan those files. What I work on is so intricately tied to the compiler anyway.