From 35627a8fe9068aca2d43e5ee88275a309ae13997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 11 Aug 2017 22:38:33 +0200 Subject: [PATCH] Renames format-* command-line arguments to rustfmt-* The --rustfmt-configuration-file command-line argument automatically activates --rustfmt-bindings. --- src/lib.rs | 30 +++++++++++++++++------------- src/options.rs | 24 ++++++++++++------------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 431fea0e6a..1f18d680b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -456,13 +456,16 @@ impl Builder { ); } - if !self.options.format_bindings { - output_vector.push("--format-bindings".into()); + if !self.options.rustfmt_bindings { + output_vector.push("--rustfmt-bindings".into()); } - if let Some(path) = self.options.format_configuration_file.as_ref().and_then( - |f| f.to_str()) { - output_vector.push("--format-configuration-file".into()); + if let Some(path) = self.options + .rustfmt_configuration_file + .as_ref() + .and_then(|f| f.to_str()) + { + output_vector.push("--rustfmt-configuration-file".into()); output_vector.push(path.into()); } @@ -852,15 +855,16 @@ impl Builder { } /// Set whether rustfmt should format the generated bindings. - pub fn format_bindings(mut self, doit: bool) -> Self { - self.options.format_bindings = doit; + pub fn rustfmt_bindings(mut self, doit: bool) -> Self { + self.options.rustfmt_bindings = doit; self } /// Set the absolute path to the rustfmt configuration file, if None, the standard rustfmt /// options are used. - pub fn format_configuration_file(mut self, path: Option) -> Self { - self.options.format_configuration_file = path; + pub fn rustfmt_configuration_file(mut self, path: Option) -> Self { + self = self.rustfmt_bindings(true); + self.options.rustfmt_configuration_file = path; self } @@ -1125,11 +1129,11 @@ pub struct BindgenOptions { rust_features: RustFeatures, /// Whether rustfmt should format the generated bindings. - pub format_bindings: bool, + pub rustfmt_bindings: bool, /// The absolute path to the rustfmt configuration file, if None, the standard rustfmt /// options are used. - pub format_configuration_file: Option, + pub rustfmt_configuration_file: Option, } /// TODO(emilio): This is sort of a lie (see the error message that results from @@ -1214,8 +1218,8 @@ impl Default for BindgenOptions { objc_extern_crate: false, enable_mangling: true, prepend_enum_name: true, - format_bindings: true, - format_configuration_file: None, + rustfmt_bindings: true, + rustfmt_configuration_file: None, } } } diff --git a/src/options.rs b/src/options.rs index 074807c8d3..7b5169b7f9 100644 --- a/src/options.rs +++ b/src/options.rs @@ -233,15 +233,15 @@ 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("format-bindings") - .long("format-bindings") + Arg::with_name("rustfmt-bindings") + .long("rustfmt-bindings") .help("Format the generated bindings with rustfmt. \ Rustfmt needs to be in the global PATH."), - Arg::with_name("format-configuration-file") - .long("format-configuration-file") + 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 \ - (when enabled by --format-bindings).") + The configuration file will be used for formatting the bindings. \ + Setting this parameter, will automatically set --rustfmt-bindings.") .value_name("path") .takes_value(true) .multiple(false) @@ -472,25 +472,25 @@ where builder.dump_preprocessed_input()?; } - if matches.is_present("format-bindings") { - builder = builder.format_bindings(true); + if matches.is_present("rustfmt-bindings") { + builder = builder.rustfmt_bindings(true); } - if let Some(path_str) = matches.value_of("format-configuration-file") { + if let Some(path_str) = matches.value_of("rustfmt-configuration-file") { let path = PathBuf::from(path_str); if !path.is_absolute() { return Err(Error::new(ErrorKind::Other, - "--format-configuration--file needs to be an absolute path!")); + "--rustfmt-configuration--file needs to be an absolute path!")); } if path.to_str().is_none() { return Err( Error::new(ErrorKind::Other, - "--format-configuration-file contains non-valid UTF8 characters.")); + "--rustfmt-configuration-file contains non-valid UTF8 characters.")); } - builder = builder.format_configuration_file(Some(path)); + builder = builder.rustfmt_configuration_file(Some(path)); } let verbose = matches.is_present("verbose");