-
Notifications
You must be signed in to change notification settings - Fork 707
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
Add a feature to make which dependency optional #1615
Changes from all commits
f64287d
b97192b
af4eebd
258940a
ebd8d4d
e627649
c22fcf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ lazy_static = "1" | |
peeking_take_while = "0.1.2" | ||
quote = { version = "1", default-features = false } | ||
regex = "1.0" | ||
which = ">=1.0, <3.0" | ||
which = { version = ">=1.0, <3.0", optional = true } | ||
shlex = "0.1" | ||
fxhash = "0.2" | ||
# New validation in 0.3.6 breaks bindgen-integration: | ||
|
@@ -70,9 +70,11 @@ optional = true | |
version = "0.4" | ||
|
||
[features] | ||
default = ["logging", "clap"] | ||
default = ["logging", "clap", "which-rustfmt"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So then you replace |
||
logging = ["env_logger", "log"] | ||
static = [] | ||
# Dynamically discover a `rustfmt` binary using the `which` crate | ||
which-rustfmt = ["which"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And remove this line. |
||
|
||
# These features only exist for CI testing -- don't use them if you're not hacking | ||
# on bindgen! | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ extern crate quote; | |
extern crate proc_macro2; | ||
extern crate regex; | ||
extern crate shlex; | ||
#[cfg(feature = "which-rustfmt")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
extern crate which; | ||
|
||
#[cfg(feature = "logging")] | ||
|
@@ -1908,10 +1909,13 @@ impl Bindings { | |
if let Ok(rustfmt) = env::var("RUSTFMT") { | ||
return Ok(Cow::Owned(rustfmt.into())); | ||
} | ||
#[cfg(feature = "which-rustfmt")] | ||
match which::which("rustfmt") { | ||
Ok(p) => Ok(Cow::Owned(p)), | ||
Err(e) => Err(io::Error::new(io::ErrorKind::Other, format!("{}", e))), | ||
} | ||
#[cfg(not(feature = "which-rustfmt"))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd just return an error here, like The error is not fatal so you'd still generate bindings. |
||
Err(io::Error::new(io::ErrorKind::Other, "which wasn't enabled, and no rustfmt binary specified")) | ||
} | ||
|
||
/// Checks if rustfmt_bindings is set and runs rustfmt on the string | ||
|
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.
What about just leaving this change, then the feature will be automatically called
which
(you get a feature for each optional dependency).