zig init template: add compiler version to build.zig.zon by default #22698
+72
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
referenced here on ziggit which describes the problem in depth, but the gist is that this solves the problem of having to manually try many different compiler versions to attempt to build a project that is unclear what version was used. If someone uses a tagged version, its not such a big deal (still annoying) but if they used a non-tagged version, it becomes nigh impossible to pin down what zig version was used to build a project. This currently just serves as an anchor point of reference so this is easier. It could also allow zig version managers to automatically use the correct version of the zig compiler.
Instead of parsing the zon file, I opted for using a wildcard like what is used for the '.name' field and just appending the version to the buffer that gets written.
It doesn't handle updating the version, I guess its better for the programmer to do so manually, and another simple expansion upon this could be emitting a warning when the current zig version is lower than or not equal to what is specified in the
build.zig.zon
file.