-
Notifications
You must be signed in to change notification settings - Fork 383
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
Cannot include generated code #117
Comments
Why can't you just copy model.rs into source directory, and then include generated file as |
Well, that's what I'm doing right now. But it feels rather like a workaround to me. |
I've gotten around this by using a build.rs script that generates the source before the build process, then cargo will pick it up if you include it in a mod.rs. It's a little clunky, but not far off from what other large projects do. |
I think rust-protobuf does it properly. But if you need to include generated code in another file, I might suggest stripping module attributes with sed scripts. |
ok with me, i think that's feasible. |
FWIW another dirty workaround is to modify the generated file in your |
Here is an example of @mpartel idea to wrap the generated proto in @stepancheg It would be really nice if this could be supported more natively. Prost does this really well with prost-build. |
@SirVer Prost looks unmaintained. Should we somehow standardize that workaround in a crate? |
i think it should just be a simple option to protoc_rust::run. And some docs on that would be helpful, since the default is rather surprising. |
@aep option to do what exactly? Not sure why the default is surprising. Could you explain please? |
the wrap_in_module option sounds good to me :) well it's quite standard to put generated files into OUT_DIR, and the solution for those errors is non-obvious. |
@aep Rust Tower seems to be betting on Prost, so I guess development will pick up eventually again. https://medium.com/@carllerche/announcing-tower-a-library-for-writing-robust-network-services-with-rust-67273f052c40 |
I spent a good chunk of the day figuring this out since docs.rs no longer allows files to be written outside of @stepancheg I would ask that you reconsider you stance of writing files to the |
Hi,
following cargo's documentation I've tried to generate my protobufs at build time (through a
build.rs
script) and include them in mymain.rs
using:However, the (rustc) compilation then fails with:
It seems that module level attributes (e.g.
#![allow(dead_code)]
here) are not allowed in included content. Would there be a way to avoid these in the generated code by turning them into item-level attributes where needed?Many thanks,
P.
The text was updated successfully, but these errors were encountered: