-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Compile flatbuffers for Rust in build.rs #1202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this fbs.es file is being generated on compile time, is it gitignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it doesn't exist in source tree at all, we write it into OUT_DIR
that is specifically designed for that purpose just like the rest of stuff, see build.rs
.
Read notes on https://doc.rust-lang.org/cargo/reference/environment-variables.html that contain OUT_DIR
for details, there are a few of them there.
|
||
fs::write( | ||
format!("{out_dir}/fbs.rs"), | ||
planus_codegen::generate_rust(&flatbuffers_declarations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's all? No need to tricks in generated fbs.ts file to make clippy happy and so on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also a bit surprised given the fact that we do literal include!()
, but apparently Rust tracks where source code comes from and from path it is clear that file is auto-generated and it ignores all warnings from there 🤷♂️
I'm not sure why that happens and lazy to search, but it works out for well for us here 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
flatbuffers
file is now auto-generated during compilation ofmediasoup-sys
, imports were changed accordingly, alsofbs
was added toworker/Cargo.toml
since otherwise it'll fail to publish.