-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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] Not importing all files #6800
Comments
Can you give more details to help reproduce this? Were there multiple invocations of |
In the example |
Ok, I was able to reproduce this. My current implementation assumes that Parser contains the full type system by the end of the invocation of flatc. This is wrong because the Parser is reset between different Workaround: Write a new I'll have to think about how to get around this reset behavior without breaking something else. We, unfortunately, rely on some pretty non-trivial mutable state in Parser. |
Any news on this front? |
Unfortunately, I am not working on this and don't really have time to for the foreseeable future. :( |
I believe I just ran into this. I've tried so many different incantations of flatc that its not even funny. This one got me the closest, with all imports between the various files correct, and its kinda nice that each type seems to be put in its own file (even though thats not how the fbs files were written...). However, the toplevel
The repository/commit in question is here: https://github.com/SlimeVR/slimevr_protocol/tree/6c96aabcf17c095ac648583f674a45681533190a I will try the approach of having a |
Yeah, sorry. There's a lot of legacy cruft implementation in there and the original variations made problematic assumptions. I need to deprecate the foot guns
This is required to correctly map flatbuffer's c++ style namespaces onto Rust modules... it's a long story. The old thing was broken too - it basically didn't support multiple
flatbuffers/src/idl_gen_rust.cpp Line 367 in 35281de
nvm that's wrong |
This issue is stale because it has been open 6 months with no activity. Please comment or label |
This issue was automatically closed due to no activity for 6 months plus the 14 day notice period. |
Is this going to be addressed? My team find themselves in the position to manually write the |
Does the "Only generate one Flatbuffers is a volunteer-only project, I don't have the time in my life to provide maintenance anymore, and I don't know who else may be interested, so unfortunately, I recommend contributing a fix, or at least to documentation for workarounds. Though there are a lot of considerations that influence what the right solution is, and I'm not sure how it all shakes out
A potential solution could be to generate a module namespace hierarchy file for each // file1.fbs
include "file2.fbs";
namespace a;
table Foo { bar: b.Bar; } // my_dir/file2.fbs
namespace a.b;
table Bar { } will generate // file1.rs
pub mod a {
generate_foo_here!();
// Note that using `my_dir::file2::*` at root of this file will define `a` twice.
// Therefore, we have to be specific with what we `use`.
pub mod b {
pub use my_dir::file2::a::b::Bar;
}
} // my_dir/file2.rs
pub mod a {
pub mod b {
generate_bar_here!();
}
} A usability downside of this approach is that all the symbols are locked behind the use file1::*;
use my_dir::file2::*;
fn make_bar() -> a::b::Bar<'static> {
todo!()
} Rust will error and say Also, what if you don't want to generate your schema files in the same crate? Then the import/reexport declarations need to be adjusted accordingly - should that be allowed, and if so, how would it be configured? There are likely more complications to this approach that aren't thought about. I don't know what other solutions people are using either, or their implicit requirements... Footnotes
|
Hi, @CasperN! Sorry, I just now realize my reply might denote some degree of attitude. Thank you for the through explanation, this helps us in understanding the issue at hand and also the possible workaround, as I missed your previous comment with the workaround. Initially I got confused by the flat compiler, thinking if it goes the way of generating a Understanding the issue in-depth now, we can take an action and know why we need to do it that way. |
When building multiple files from a given directory (let's call it
a
) which import files from another directoryb
, there is amod.rs
file produced which only imports mods from the last file ina
and last file inb
, yet all_generated.rs
files are produced.The text was updated successfully, but these errors were encountered: