Code Monkey home page Code Monkey logo

Comments (8)

valarauca avatar valarauca commented on May 19, 2024

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.

from prost.

danburkert avatar danburkert commented on May 19, 2024

@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).

from prost.

valarauca avatar valarauca commented on May 19, 2024

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.

from prost.

danburkert avatar danburkert commented on May 19, 2024

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()

from prost.

valarauca avatar valarauca commented on May 19, 2024

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.

from prost.

danburkert avatar danburkert commented on May 19, 2024

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.

from prost.

valarauca avatar valarauca commented on May 19, 2024

Interesting.

I'll throw this in queue.

from prost.

danburkert avatar danburkert commented on May 19, 2024

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

from prost.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.