Skip to content
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

Merged
merged 1 commit into from
Oct 29, 2023

Conversation

nazar-pc
Copy link
Collaborator

flatbuffers file is now auto-generated during compilation of mediasoup-sys, imports were changed accordingly, also fbs was added to worker/Cargo.toml since otherwise it'll fail to publish.

@nazar-pc nazar-pc requested review from ibc and jmillan October 29, 2023 19:51
worker/build.rs Show resolved Hide resolved
Copy link
Member

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?

Copy link
Collaborator Author

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)
Copy link
Member

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?

Copy link
Collaborator Author

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 🙂

@nazar-pc nazar-pc merged commit 54731fa into flatbuffers Oct 29, 2023
32 checks passed
@nazar-pc nazar-pc deleted the compile-flatbuffers-build.rs branch October 29, 2023 21:09
Copy link
Member

@jmillan jmillan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants