bazel /
crubit /
42abfc85ec018fe7ae20f3154425a9b2c86d0268 Send IR to Rust to generate rust source code using quote!
To pass IR across the FFI boundary we serialize it to a json string, pass the string to Rust, and return a string with generated Rust source code back.
Alternatives considered:
Protobuf instead of json
------------------------
using protobuf as a serialization format would have some advantages (defining types only once, we wouldn't have to write our own serialization logic in C++), we decided not to use it because:
* there is no approved way of using protobufs in Rust in google3 today, and we didn't want to special case us. We could still use protobuf on the C++ side and generate json using it, so at least we don't have to write serialization code ourselves.
* we felt going with json and manual serialization will be more flexible in the uncertain future
* we tossed a coin and json won
Implementing our own Rust code generator in C++
-----------------------------------------------
We sketched the code in unknown commit, and we decided going with Rust solution is more readable and maintainable. We also plan to use Clang syntax trees to generate C++ source code, of which quote!, proc_macro2, and syn are moral equivalents.
PiperOrigin-RevId: 389566607
8 files changed
tree: 635f5f164ae76c762e364263c65089f27d2f4c81
- rs_bindings_from_cc/
- CODE_OF_CONDUCT
- CONTRIBUTING
- LICENSE
- README.md
README.md
Crubit: C++/Rust Bidirectional Interop Tool
Extremely experimental interop tooling for C++ and Rust.
Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.