-
Notifications
You must be signed in to change notification settings - Fork 795
feat(abigen): emit cargo build script directives #2449
Conversation
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.
nice, smol nit re error message otherwise lgtm
let contents = fs::read_to_string(&path).wrap_err("Could not read file")?; | ||
|
||
Self::new(name, contents) | ||
let path = path.as_ref().to_str().ok_or_else(|| eyre::eyre!("invalid path"))?; |
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.
nit: error should include the path
/// Specify whether to print [cargo build script directives][ref] if the source is a path. By | ||
/// default, this is true only when executing inside of a build script. | ||
/// | ||
/// [ref]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script |
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.
I need to adapt this href style
@@ -368,6 +396,11 @@ impl ContractBindings { | |||
} | |||
} | |||
|
|||
/// Returns whether the current executable is a cargo build script. | |||
fn in_build_script() -> bool { | |||
std::env::var("CARGO_MAKEFLAGS").is_ok() |
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.
TIL
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.
honestly i just went over all of the env vars, and this one was the only one that is set only on build scripts, per docs. Not 100% sure
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.
TARGET
should be fine as well.
89d392b
to
f6ce0d8
Compare
f6ce0d8
to
235ffce
Compare
Motivation
... and an
include_bytes!
when not in build scripts. Signals Cargo to rebuild if the source files change.Solution
PR Checklist