-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a --check
argument to cargo codegen
#3495
Labels
codegen/idl
🧑💻 dev experience
developer experience (excluding CI)
enhancement
New feature or request
good first issue
Good for newcomers
🏎️ Quick Issue
Can be fixed in a few hours or less
Milestone
Comments
jleibs
added
enhancement
New feature or request
🧑💻 dev experience
developer experience (excluding CI)
codegen/idl
labels
Sep 27, 2023
The various codegens should not write to the filesystem directly, but instead return a |
emilk
added
good first issue
Good for newcomers
🏎️ Quick Issue
Can be fixed in a few hours or less
labels
Oct 9, 2023
4 tasks
teh-cmc
added a commit
that referenced
this issue
Oct 17, 2023
**Commit by commit** This is necessary refactoring work for the upcoming `attr.rust.custom_crate` attribute, itself necessary for the upcoming serde-codegen support, itself necessary for the upcoming blueprint experimentations as well as #3741. ### Changes 1. The `CodeGenerator` trait as well as all post-processing helpers (gitattributes, orphan detection...) are now I/O-free. ```rust pub type GeneratedFiles = std::collections::BTreeMap<camino::Utf8PathBuf, String>; pub trait CodeGenerator { fn generate( &mut self, reporter: &crate::Reporter, objects: &crate::Objects, arrow_registry: &crate::ArrowRegistry, ) -> GeneratedFiles; } ``` 2. All post-processing helpers are now agnostic to the location output. This is very important as it makes it possible to generate e.g. rust code out of the `re_types` crate without everything crumbling down. A side-effect is that gitattributes files are now finer-grained. 3. The Rust codegen pass is now crate agnostic: it is driven by the workspace path rather than a specific crate path. Necessary for the upcoming `attr.rust.custom_crate`. 4. All codegen passes now follow the exact same 4-step structure: ``` // 1. Generate in-memory code files. let mut gen = MyGenerator::new(); let mut files = gen.generate(reporter, objects, arrow_registry); // 2. Generate in-memory attribute files. generate_gitattributes_for_generated_files(&mut files); // 3. Write all in-memory files to disk. write_files(&gen.pkg_path, &gen.testing_pkg_path, &files); // 4. Remove orphaned files. crate::codegen::common::remove_orphaned_files(reporter, &files); ``` 5. The documentation codegen pass now removes its orphans, which is why some `md` files were removed in this PR. --- - Unblocks #3741 - Unblocks #3495
4 tasks
teh-cmc
added a commit
that referenced
this issue
Oct 19, 2023
- Adds a new `CodeFormatter` trait. - Adds a new trait-based generic `generate_code` helper, and reimplement all language-specific backends in terms of it. - Adds `--check` flag. - Use `--check` instead of git dirtyness checks on CI. --- - Fixes #3495
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
codegen/idl
🧑💻 dev experience
developer experience (excluding CI)
enhancement
New feature or request
good first issue
Good for newcomers
🏎️ Quick Issue
Can be fixed in a few hours or less
This should do a dry-run and return an error code if any of the files would be modified.
This would be a bit clearer and less error prone in the CI check:
rerun/.github/workflows/reusable_checks.yml
Lines 138 to 140 in 50222c2
And would also be something that could be added to a git
pre-push
hook to reduce frequency of submitting code that's going to fail the codegen check.The text was updated successfully, but these errors were encountered: