Source code generation policy #994
Replies: 3 comments 4 replies
-
|
Personally I prefer the out-of-tree approach. But I've been significantly jaded by CMake's handling of such things; where it regularly runs afoul of similar issues with rebuilding and miscompiling. If we are concerned with specific generated code audits e.g. rust files that we manually write our in the build script, then we could experiment auditing this by moving the format string into its own separate file. This file can then be ^^ haven't actually tried this; but I don't see why it wouldn't simply work :) |
Beta Was this translation helpful? Give feedback.
-
|
I'd like to revive this discussion, cc @TomasArrachea. In particular because of a PR reworking our node proto files 0xMiden/miden-node#723, and because its again caused some major CI regressions fixed in #1230. I've also personally run into the issue that changing proto files does not cause rebuilds because one has to override it. |
Beta Was this translation helpful? Give feedback.
-
|
One other downside of generated files in src is that such files shouldn't really matter when merging or rebasing, but since they're committed to src, they do cause conflicts during rebasing. The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We generate code in a few
build.rsacross our various repos. Our current policy has been to generate this code in-tree, allowing us to audit this as part of code reviews in PRs.General guidelines
This policy does go against the common guideline that code generation should be done out-of-tree and never checked into source control. This is also the policy that the
Rustreference suggests:Why revisit this
Our policy has bitten us recently. Additional code generation was added to
build.rs, and the generated files were added to thererun-if-changedpragma (which is perfectly valid). However this caused the build script to always trigger, causing a full recompile each time. This was patched in #991, but I have to admit I still don't fully understand why it was happening. Probably it didn't like a trigger of a generated file; though that feels like it should be allowed to prevent accidental mutation post-generation.Pros/Cons of current policy
Positives:
Negatives:
Beta Was this translation helpful? Give feedback.
All reactions