summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs10
-rw-r--r--src/options.rs22
2 files changed, 21 insertions, 11 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 85e43979..9e54ddc9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -492,7 +492,7 @@ impl Builder {
}
if !self.options.rustfmt_bindings {
- output_vector.push("--rustfmt-bindings".into());
+ output_vector.push("--no-rustfmt-bindings".into());
}
if let Some(path) = self.options
@@ -1416,7 +1416,7 @@ impl Default for BindgenOptions {
enable_mangling: true,
prepend_enum_name: true,
time_phases: false,
- rustfmt_bindings: false,
+ rustfmt_bindings: true,
rustfmt_configuration_file: None,
no_partialeq_types: Default::default(),
}
@@ -1608,10 +1608,8 @@ impl Bindings {
let rustfmt = if let Ok(rustfmt) = which::which("rustfmt") {
rustfmt
} else {
- return Err(io::Error::new(
- io::ErrorKind::Other,
- "Rustfmt activated, but it could not be found in global path.",
- ));
+ warn!("Not running rustfmt because it does not exist in PATH");
+ return Ok(());
};
let mut cmd = Command::new(rustfmt);
diff --git a/src/options.rs b/src/options.rs
index d8a98641..aec4a2bd 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -257,15 +257,19 @@ where
Useful when debugging bindgen, using C-Reduce, or when \
filing issues. The resulting file will be named \
something like `__bindgen.i` or `__bindgen.ii`."),
+ Arg::with_name("no-rustfmt-bindings")
+ .long("no-rustfmt-bindings")
+ .help("Do not format the generated bindings with rustfmt."),
Arg::with_name("rustfmt-bindings")
.long("rustfmt-bindings")
- .help("Format the generated bindings with rustfmt. \
- Rustfmt needs to be in the global PATH."),
+ .help("Format the generated bindings with rustfmt. DEPRECATED: \
+ --rustfmt-bindings is now enabled by default. Disable \
+ with --no-rustfmt-bindings."),
Arg::with_name("rustfmt-configuration-file")
.long("rustfmt-configuration-file")
.help("The absolute path to the rustfmt configuration file. \
The configuration file will be used for formatting the bindings. \
- Setting this parameter, will automatically set --rustfmt-bindings.")
+ This parameter is incompatible with --no-rustfmt-bindings.")
.value_name("path")
.takes_value(true)
.multiple(false)
@@ -529,13 +533,21 @@ where
builder.dump_preprocessed_input()?;
}
- if matches.is_present("rustfmt-bindings") {
- builder = builder.rustfmt_bindings(true);
+ let no_rustfmt_bindings = matches.is_present("no-rustfmt-bindings");
+ if no_rustfmt_bindings {
+ builder = builder.rustfmt_bindings(false);
}
if let Some(path_str) = matches.value_of("rustfmt-configuration-file") {
let path = PathBuf::from(path_str);
+ if no_rustfmt_bindings {
+ return Err(Error::new(
+ ErrorKind::Other,
+ "Cannot supply both --rustfmt-configuration-file and --no-rustfmt-bindings"
+ ));
+ }
+
if !path.is_absolute() {
return Err(Error::new(
ErrorKind::Other,