tokio-rs / prost

PROST! a Protocol Buffers implementation for the Rust Language
Apache License 2.0
3.86k stars 500 forks source link

Feature so that prost-types depends on prost-derive only optionally. #1075

Closed ernoc closed 3 months ago

caspermeijn commented 4 months ago

Can you explain when this is useful?

ernoc commented 4 months ago

When using Bazel+rules_rust instead of Cargo, depending on prost-derive makes the entire crate index require std, which makes it impossible to build for bare metal. One workaround is to not depend on prost-derive as a "dep", and add the dependency as a proc macro (e.g. https://github.com/project-oak/oak/blob/88928b96e1fe72d173c106f511d7f6537ed30000/micro_rpc/BUILD#L30) .

The approach in this PR, however, doesn't seem to work, unless we were open to changing CI tests to always have "derive" feature active for prost-types.

PD: I'm making this PR a draft for now.

caspermeijn commented 4 months ago

When using Bazel+rules_rust instead of Cargo, depending on prost-derive makes the entire crate index require std, which makes it impossible to build for bare metal. One workaround is to not depend on prost-derive as a "dep", and add the dependency as a proc macro (e.g. https://github.com/project-oak/oak/blob/88928b96e1fe72d173c106f511d7f6537ed30000/micro_rpc/BUILD#L30) .

That seems like a bug in bazel. Because prost-derive only runs on the host.

The approach in this PR, however, doesn't seem to work, unless we were open to changing CI tests to always have "derive" feature active for prost-types.

I believe that prost-types without prost-derive is not useful, as it could never compile all the useful types in protobuf.rs. Am I right?

caspermeijn commented 3 months ago

I will close this for now. Please re-open when you think you have new information.