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
[Rust] Add better support for "crate-per-schema" #8273
Comments
I don't particularly care about doing this through flatc directly. We use Bazel downstream and I have some patches to implement this, but we're somewhat behind master so it might take me a bit of time to send a PR. It is on my radar though. The big thing that needs to change is the
The generated code should be like // foo_generated.rs
use foo_generated::*;
pub mod foo {
use foo_generated::foo::*; // As opposed to currently `foo_generated::*;
pub mod bar {
// No need to include foo_generated here since it doesn't live in `foo.bar`
}
} I think the correct approach is to include |
Unfortunately, this doesn't work when the imports are ambiguous. For instance:
This will result in We will probably have to change the code generation to use absolute paths instead for our use case. Would love to upstream our work once it's ready. Would this be a reasonable contribution or would this change to absolute paths break other use cases? |
Currently, flatc allows using
--rust-module-root-file
and--gen-all
to generate multiple schemas into a single crate with a top-levelmod.rs
. This is good but makes it really hard to use in many contexts since the best (only?) option to have inter-dependent schemas is to generate everything together into a single crate.Ideally, we can generate each schema independently of the includes (as each include will be its own generated crate), and link them all at build time.
The text was updated successfully, but these errors were encountered: