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

Add a codegen builder #10

Closed
danburkert opened this issue Jun 26, 2017 · 8 comments
Closed

Add a codegen builder #10

danburkert opened this issue Jun 26, 2017 · 8 comments

Comments

@danburkert
Copy link
Collaborator

There are expected to be a few more optional features in the future: map type, service generator, zero copy, etc.

@valarauca
Copy link

I'm just passing by to 👍 this issue.

I'm using ProtoBufs in a Rust project for work and we currently have a monorepo that holds all our protobuffers (and a very long 200+ LoC Makefile) to build them I've spent a few hours to integrate this tool this morning and exposing a way to pass args to --proto_path is desperately needed via the build.rs file.

@danburkert
Copy link
Collaborator Author

@valarauca That's already possible, have you seen the docs in https://github.com/danburkert/prost/tree/master/prost-build README? prost_build::compile_protos's second argument is the include paths. Note that the protobuf builtin .protos are already included (the well known types stuff).

@valarauca
Copy link

valarauca commented Jun 28, 2017

I'm really not sure I understand (or I misstated my issue).

I'm attempting to retrofit prost into our my companies existing structure without breaking anything.

Structure example:

proto/
----Makefile
----build.gradle
----Gopkg.toml
----Gopkg.lock
-----team/
---------team.proto
-----another_team/
---------name1.proto
---------name2.proto

So this becomes

proto/
----Cargo.toml
----build.rs
----Makefile
----build.gradle
----Gopkg.toml
----Gopkg.lock
-----src/
---------lib.rs
---------item.rs #Hopefuly
-----team/
---------team.proto
-----another_team/
---------name1.proto
---------name2.proto

If I just do something like prost_build::compile_protos(&["agent/agent.proto"], &[], None).unwrap()

This fails as agent.proto's package is agent.proto So I should do prost_build::compile_protos(&[], &["agent/agent.proto"], None).unwrap()?


I will try this but currently I cannot build prost requires bytes = "0.1.2" which requires nightly? I see 0.4 is called out, but 0.1.2 is always fetched by cargo. I attempted to fully purge my ~/.cargo/registry


I've attempted to rm -rf ~/.cargo/register and cargo update ref neither solves the bytes = "0.1.2" requirement. It ends up being the second crate that is fetched.

@danburkert
Copy link
Collaborator Author

Yes, this is currently supported. The first arg to compile_protos is the list of .protos you want to compile (you can skip any that are transitively imported, you only have to include the 'root' .protos). The second arg is the include paths. What the include paths should be depends on what the package declaration in the protobufs is, but assuming that's package team; and package another_team;, and we're compiling from the first source tree above, I think you want:

prost_build::compile_protos(&["src/team/team.proto"], &["src/"], None).unwrap()

@valarauca
Copy link

valarauca commented Jun 28, 2017

Awesome. Any clue what's up with the bytes v0.1.2 being imported?

My first attempt it didn't happen, but on the 2nd, 3rd, and 4th it crashed and burned. Currently I can't even build anything that requires prost.

@danburkert
Copy link
Collaborator Author

hmm, no. My usual route for debugging issues like that is to inspect Cargo.lock and figure out where they are coming from. prost and prost-build have a dependency on 0.4, so it shouldn't be pulling in 0.1.

@valarauca
Copy link

Interesting.

I'll throw this in queue.

@danburkert
Copy link
Collaborator Author

A code generator config has been added in 17474e8. @valarauca if you're still having build issues feel free to open another issue.

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

No branches or pull requests

2 participants