Generate Zig metadata before final build#2867
Conversation
Root build.zig and build.zig.zon were generated inside zigBuild. That meant --skip-build refreshed dependency metadata but left the root project metadata stale or missing. Generate the root metadata in the post-compile step that already handles dependency metadata, before deciding whether to run the final Zig build. Keep root stubs, pruning, and the Zig invocation inside zigBuild.
Root build.zig metadata is now generated before final build execution so --skip-build callers get the files they need. That path does not need a new verbose line; leaving output unchanged preserves the existing incremental build output shape.
The Zig dependency collision tests only inspect generated build.zig and build.zig.zon contents. They do not need to invoke the final Zig build after the metadata has been written. Run those fixtures with --always-build --skip-build so the front end still refreshes the generated metadata without spending time linking temporary Zig artifacts.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4741bb71f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| unless isRootSysProj $ | ||
| genBuildZigFiles rootSpec rootPins (ccDepOverrides cctx) pathsRoot rootDepModuleOpts rootDepPathOverrides |
There was a problem hiding this comment.
Guard root metadata writes in alt-output modes
When acton build is run with an alternate output flag such as --sigs, --parse, or --cgen, the existing final build path is still skipped by the later unless (altOutput opts'), so these commands are intended to dump analysis/codegen output without touching the root Zig project files. This unconditional root genBuildZigFiles call now overwrites build.zig and build.zig.zon even in those modes; please keep it under the same non-altOutput condition (while still allowing --skip-build) so inspection commands do not mutate project metadata.
Useful? React with 👍 / 👎.
Root build.zig and build.zig.zon were generated from inside the final Zig build path. That meant --skip-build could refresh dependency metadata while leaving the root project metadata stale or missing.
This moves the root metadata write into the post-compile step that already prepares dependency metadata before the final build decision. The final Zig build still owns root stub generation, pruning, and invoking Zig, so --skip-build stops after metadata while normal builds keep the same final build behavior.
The metadata-only tests now use --skip-build for the cases that only inspect generated build.zig.zon contents.