Comments (9)
@danburkert prost-build
might be superior but when dealing with other languages like go and javascript we use protoc
to generate code more than one language. Adding another language is just adding one line script. For prost, we have to carry proto files so we can generate source code. The approach at https://github.com/pingcap/kvproto, which is a single repo for go and rust, could not work for prost.
from prost.
Thanks for thoughtful reply!
There are some upsides we might miss out on: It can be nice to look at the generated code and if the Rust file is in the project less-fancy editors like vim can still do autocompletion on the protobuf structs. This might be less of an issue with this crate since there are not getters and setters.
I will try it out and will let you know how it works out in our project.
from prost.
@danburkert Because we need the proto files and protoc at build-time and I don't like distributing proto files. Pre-generating solves the problem missing proto files and protoc on the device. For example, I use Raspberry PI to build some projects and it seems that prost-build cannot download Linux arm64 protoc binary so I can't generate proto files on Raspberry PI.
from prost.
There actually used to be a protoc plugin ,protoc-gen-prost
, but it got removed in 0529321. It could be added back somewhat easily, but I really think the prost-build
approach is superior in most respects. I'm a big believer in build-time generation, since it's fast, easier to configure (code vs env opts), and makes the build more reproducible in most situations.
I do sympathize with the external .proto
issue, though. That's actually the situation I'm in with the project which motivated building prost
. I'm currently solving it by downloading the required .proto
s at build time (see this example). I find this an acceptable practice, but I imagine downloading things during a build (even when cached) can turn people off. It's always an option to just copy the .proto
s into the project.
from prost.
If you need to look at the generated code, you can find it in target/debug/build/<crate-name>-<random-digits>/out/
, and cargo-expand can be used to see the expansion of derive(Message
. The auto-complete issue is interesting, I'm not sure whether racer et al can 'see through' the include!
trick.
from prost.
Going to close this out, but feel free to re-open if you still feel like a protoc
plugin would be helpful.
from prost.
@sercand I'm not seeing why the prost
approach couldn't work for such a repo. Couldn't you just remove the pre-generated .rs files and add a build.rs which generates them at build-time?
from prost.
I have a couple issues with the current approach:
- To have a look at the generated code, I have to go fish around
target/
for*.rs
files. And for some reason, there are usually 3-4 folders and only one of them has the up-to-date schemas, e.g.:
target/debug/build/sometool-25a8aa2698a97ed5/out/api.rs
target/debug/build/sometool-4029fb7b227cd879/out/api.rs
target/debug/build/sometool-69de7112f213c302/out/api.rs
target/debug/build/sometool-a32f6a50bd8eb3e2/out/api.rs
- Also because of this, IntelliJ IDEA doesn't see the compiled schemas, and I get no autocompletion in its editor.
If anyone here has found a way around these, I'd love to hear from you.
from prost.
@abreis, I'm having the exact same issue with VS Code. I think I understand why to generate the files this way, but I feel it's not very straight forward to work with them like that.
I'd be glad to hear if anyone found a better way around this
from prost.
Related Issues (20)
- Panic in `prost-build` with potentially unsupported `extern_path`
- Buf/ButMut bounds should be ?Sized HOT 2
- Implementing `prost::Message` externally is annoying, we need to improve it HOT 1
- bytes dependency is locked to 1.0.x
- prost_build::Config::prost_path is unusable. HOT 2
- Deserialization not working properly anymore after updating message HOT 1
- Can you clarify whether prost works with no_std? HOT 1
- How to get <T> instead of Option<T> as default representation for all user-defined message types HOT 1
- `enable_type_names` fails for multiple proto files with the same package name. Is this expected? HOT 2
- HOWTO decode a serialized protobuf (in C) within Rust (prost crate)? HOT 2
- prost-build doc link broken on docs.rs HOT 2
- `prost-types` crate missing Well Known Types from google.protobuf.wrapper HOT 1
- feature: Deterministic Serialization HOT 2
- How to customize grpc method uri HOT 1
- `proto3` doesn't pack repeated fields by default HOT 2
- Generate `From<>` cast automatically for `protobuf::one`
- Unable to import proto from another library HOT 1
- #[deprecated] decorator is missing on enum access functions
- required field being deserialized as empty string
- prost-build: Allow path globbing for type and field attributes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prost.