Merge pull request #1381 from wkral/build-fmt-error
Improve rustfmt missing error during build (#1379)
This commit is contained in:
@@ -9,7 +9,7 @@ use std::fs;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::{self, Command};
|
||||||
|
|
||||||
fn find_prolog_files(libraries: &mut File, prefix: &str, current_dir: &Path) {
|
fn find_prolog_files(libraries: &mut File, prefix: &str, current_dir: &Path) {
|
||||||
let entries = match current_dir.read_dir() {
|
let entries = match current_dir.read_dir() {
|
||||||
@@ -68,10 +68,7 @@ fn main() {
|
|||||||
.write_all(quoted_output.to_string().as_bytes())
|
.write_all(quoted_output.to_string().as_bytes())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Command::new("rustfmt")
|
format_generated_file(instructions_path.as_path());
|
||||||
.arg(instructions_path.as_os_str())
|
|
||||||
.spawn().unwrap()
|
|
||||||
.wait().unwrap();
|
|
||||||
|
|
||||||
let static_atoms_path = Path::new(&out_dir).join("static_atoms.rs");
|
let static_atoms_path = Path::new(&out_dir).join("static_atoms.rs");
|
||||||
let mut static_atoms_file = File::create(&static_atoms_path).unwrap();
|
let mut static_atoms_file = File::create(&static_atoms_path).unwrap();
|
||||||
@@ -82,10 +79,24 @@ fn main() {
|
|||||||
.write_all(quoted_output.to_string().as_bytes())
|
.write_all(quoted_output.to_string().as_bytes())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Command::new("rustfmt")
|
format_generated_file(static_atoms_path.as_path());
|
||||||
.arg(static_atoms_path.as_os_str())
|
|
||||||
.spawn().unwrap()
|
|
||||||
.wait().unwrap();
|
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=src/");
|
println!("cargo:rerun-if-changed=src/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn format_generated_file(path: &Path) {
|
||||||
|
Command::new("rustfmt")
|
||||||
|
.arg(path.as_os_str())
|
||||||
|
.spawn()
|
||||||
|
.unwrap_or_else(|err| {
|
||||||
|
eprintln!(
|
||||||
|
"{}: rustfmt (https://github.com/rust-lang/rustfmt) \
|
||||||
|
is required build time dependency and must be available \
|
||||||
|
in the environment's PATH variable.",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
process::exit(1);
|
||||||
|
})
|
||||||
|
.wait()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user