Run `rustfmt` ourselves and provide a helpful message if we couldn't
@@ -21,6 +21,7 @@ fn main() {
}
bindgen::Builder::default()
+ .rustfmt_bindings(false)
.header("src/sys/bindings.h")
.clang_arg(String::from("-I") + &node_include_path)
.rustified_enum("(napi_|uv_).+")
@@ -31,9 +32,12 @@ fn main() {
.write_to_file("src/sys/bindings.rs")
.expect("Unable to write napi bindings");
- Command::new("rustup").args(&["run", "nightly", "rustfmt", "src/sys/bindings.rs"])
+ let status = Command::new("rustup").args(&["run", "nightly", "rustfmt", "src/sys/bindings.rs"])
.status()
- .expect("Unable to format napi bindings");
+ .expect("Failed to execute rustup");
+ if !status.success() {
+ println!("cargo:warning=Couldn't run rustfmt on generated napi bindings. See the README for instructions on installing it.");
+ }
cc::Build::new()
.cpp(true)
