-
Notifications
You must be signed in to change notification settings - Fork 251
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
zcash_client_backend
: Avoid writing to src
dir in build.rs
#1420
Comments
I went ahead with the In any case, I still think it's worth completing this ticket as a tech-debt improvement, although it does not seem urgent from my perspective. |
That is not at all what this says. The quoted comment is "Copy the generated types into the source tree so changes can be committed"; the changes here are made by the generator (either due to changes to the source
This file is not generated.
The core question here is "why is the For historical context, we previously always generated code from So we compromised by checking in the generated files and adding To be clear, the build script does nothing unless:
Thus you can ensure that no writes happen in |
Ah, I see. I misunderstood "…so changes can be committed" as implying human-made changes. So the work-around of not having There is a wrinkle (for this downstream I'm not aware of any other use case where the source tree is read-only, so it seems like this is a lower priority vs enabling other cargo environments to build without |
Note that |
Background / Motivation
While attempting to create a
nix
flake forzingolib
, I hit a blocker due to thezcash_client_backend
build script writing intosrc
.The
nix
build system aims for deterministic builds, and one mechanism it uses by default is ensuring all package sources are read-only during the build process. For this specific case aflake.nix
-specific work-around would be to copy the source to a temporary read/write directory. However, this feels like a work-around for what I assume to be a work-around inzcash_client_backend
, so this ticket is about addressing the upstream non-nix
-specific behavior.(Also: this is the first time I've seen the
crane
build library fornix
fail on a cargo crate for this reason, so I think it is unusual/disrecommended practice in rust land.)Current Status
I started looking into why
zcash_client_backend
does this, and see the comments such as this inbuild.rs
that explain the rationale as allowing revision-controlled edits of the generated source. I glanced at theblame
for one of the generated-and-also-manually-edited files and I can't yet tell which changes are the manual edits without more digging.Are manual edits still required?
My guess is that they were necessary because
protoc
failed to include some rust attributes or some other tweak. Hopefully, it can now include all necessary changes in thebuild.rs
inputs or.proto
files?I am not sure I can answer this without feedback from the maintainers, perhaps @str4d or @nuttycom. In fact, I currently don't understand why the manual edits aren't overwritten by the
protoc
output when I build.Next Steps
If manual edits are no longer necessary, the fix should be dirt simple: remove the
fs::copy
lines inbuild.rs
.If not, the next step I would take is determine what customizations to
protoc
output are needed, see if newer versions support that, and/or investigateprotoc
alternatives like https://github.com/stepancheg/rust-protobuf/ (which also incidentally simplifies system prerequisites by avoiding "then installprotoc
in theREADME.md
). ;-)The text was updated successfully, but these errors were encountered: