-
Notifications
You must be signed in to change notification settings - Fork 23
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
Auto protobuf build #38
Auto protobuf build #38
Conversation
Copying SpinResearch/RustySecrets#69 (comment): would it be possible to ensure in |
LGTM. What do you think @nvesely? |
build.rs
Outdated
@@ -0,0 +1,15 @@ | |||
extern crate protoc_rust; | |||
|
|||
fn build_protobuf<'a>(out_dir: &'a str, input: &'a [&'a str], includes: &'a [&'a str]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine without the 'a
.
Edit: I think only the first two issues I bring up here should be considered potential blockers to merge. The second two I can fix in a follow-up PR unless @dingxiangfei2009 would like to take care of them as well. My issue comment #38 (comment) also falls into this latter category.
I must not be understanding what @dingxiangfei2009 is saying here. Since the generated code will not be present in the rustfmt build (since rustfmt does not compile before checking and the generated code is not committed to the repository) why would it fail? If we do in fact need to disable it temporarily we should at least open an issue with a plan for a followup PR that would allow us to re-enable it. e0af347 seems like a good solution for Travis, but my intention when I wrote #38 (comment) was to suggest that the generated code should be consistent for all users. The build should fail on any platform where
It would be nice if build.rs:
Cargo.toml (relevant sections):[build-dependencies] protoc-rust = { version = "1.7.1" , optional = true } |
When I look into the
That missing I also tried applying |
How about running It might be good also to file an issue for this in the rustfmt repo. It's possible there's either already a way to do this without having to do the build/ code generation (at least nothing in https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md seemed suitable to me), or there should be a way (e.g., by extending the interpretation of |
Though I could not get Now the |
The purpose of the rustfmt.toml is so rustfmt doesn't check the src/proto/proof.rs we just hypothetically generated with protoc in the rustfmt matrix build. Protoc code is not does not conform to rustfmt standards and the build would always fail. |
Okay, two more small things and then I'd say this is ready to merge:
I tested this locally and rustfmt passed, so it should work in Travis as well. |
and generate the schema before running rustfmt
e398fdb
to
9607c19
Compare
9607c19
to
ddf6b93
Compare
I do not know how you have configured
|
This might work - env:
- NAME='rustfmt'
# use env so updating versions causes cache invalidation
- PROTOBUF_CODEGEN_VERSION=2.0.0
# So `protoc` can find `protoc-gen-rust`
- PATH=$PATH:$HOME/cargo/bin
rust: nightly
before_script:
- rustup component add rustfmt-preview
# Protoc plugin needed to generate proof.rs from proof.proto
- cargo install protobuf-codegen --version $PROTOBUF_CODEGEN_VERSION || echo "protobuf-codegen already installed"
# TODO: see if we can avoid installing protobuf-codegen and generating
# proof.rs in this build by using rustfmt options (see
# https://github.com/SpinResearch/merkle.rs/pull/38#issuecomment-391336829,
# paragraph 2).
- protoc --rust_out src/proto/ protobuf/proof.proto
script:
- cargo fmt --all -- --check |
I think it's better to complicate the travis build than the code and build/ runtime dependencies, but ideally that TODO gets resolved at some point. Also, referencing my yaml above, I'm not actually sure we need to pin a version of this package because when I'm actually a bit confused as to why |
Ok, I pushed in some changes as you have recommended. If this looks good to you, I will make a similar change to the other pull request in RustySecrets and fix a similar problem there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response, LGTM!
Blocked by #40. If you re-run Travis on this PR, it should fail. |
Em, I don't see how Travis fails on this PR. It is still passing. I am going to try merging #40 with this PR and see what happens. |
Closing this PR since #44 attempts to properly build protobuf schema with a correct |
This is related to this merge request.
As a dependency of
rusty_secrets
, the currentmerkle
crate is failing the build due to the recent breaking change inprotobuf
internal APIs. This is an attempt to fix the build failure by re-building the protobuf schemata automatically.Note that
rustfmt
target in the Travis-CI build script is temporarily disabled, since the generated schema is not checked into the repository and it is not re-generated whenrustfmt
is run, while it has currently no capability to recognise conditional directives in the source code.Protobuf is included into the cache by the build script, so that it can be reused in future builds on Travis-CI. The idea is taken from here. The cache is working as seen from this Travis log.