Rust Protobuf Support

3 views
Skip to first unread message

Jingyun Liu

unread,
Dec 11, 2025, 6:29:22 PM (6 days ago) Dec 11
to rust...@chromium.org
Hi rust-dev,

I'm trying to compile and generate a proto message in Rust so that it can be used as a deps in a rust lib that we want to build. I didn't find any existing `rust_proto_library` rules in the codebase, but I did find the rust protobuf compiler already exists.  
I'm wondering if there's any support for generating rust files from proto files, and if there's any examples to follow? If not, what's the recommended approach?

Thank you in advance,
- Jingyun

Łukasz Anforowicz

unread,
Dec 11, 2025, 6:32:47 PM (6 days ago) Dec 11
to rust-dev, Jingyun Liu, Marcel Hlopko
There is no existing support in the Chromium build system for generating Rust bindings for protobufs.  If there is demand, then we can probably figure out together the path forward.  I assume that we would just mimic what google3 does, so let me /cc @hlopko, who I hope can help us figure out if/how we can try to reuse google3 protobuf/Rust integration in Chromium.

Jingyun Liu

unread,
Dec 12, 2025, 1:26:38 PM (5 days ago) Dec 12
to Łukasz Anforowicz, rust-dev, Marcel Hlopko
Thank you for the quick reply! 

We use the Rust proto as a data container for our Rust parser to return serialized parsed results back to C++ (our directory cannot depend on //base, so we can't use json either)

I made some attempt to update the various build rules for rust in https://crrev.com/c/7254707, but I still cannot get it to build. Would really appreciate it if anyone could help!

- Jingyun

Łukasz Anforowicz

unread,
Dec 12, 2025, 2:50:21 PM (5 days ago) Dec 12
to Jingyun Liu, rust-dev, Marcel Hlopko
I am not sure what exactly is the problem when trying `ninja.sh -C out/rel protoc-gen-rust`.  I see that 1) the `upb_reflection` target has `upb/reflection/stage0` in its `include_dirs` and 2) `upb_reflection` is in `public_deps` of `upb`, and 3) `upb` is in `deps` (I also tried changing this to `public_deps`) of the new `protoc_rust` target.  I think that maybe the `include_dirs` needs to be put into a `config` and then exposed as `public_configs` from `upb_reflection`?  Not sure, but let me try that quickly.
Reply all
Reply to author
Forward
0 new messages