diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-01-08 18:01:23 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-01-08 18:01:23 +0000 |
commit | eda4791472f5bf8daeba342efe97dc0977666613 (patch) | |
tree | cd10f6b19bd0657792dcba21af56dc9c497bd734 /autochomp/build.rs | |
parent | 0a837400e0ffa7fca1a1902b34f375d0dc5b5f6b (diff) |
Minor fix-ups to AutoChomp
Diffstat (limited to 'autochomp/build.rs')
-rw-r--r-- | autochomp/build.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/autochomp/build.rs b/autochomp/build.rs index 952d49c..58c12a1 100644 --- a/autochomp/build.rs +++ b/autochomp/build.rs @@ -5,7 +5,7 @@ use std::{ fs, io::{Read, Write}, path::Path, - process::exit, + process::Command, }; use chomp::{ @@ -36,9 +36,13 @@ fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let mut input = String::new(); - let res = fs::File::open(PATH) + + fs::File::open(PATH) .map_err(|e| Box::new(e) as Box<dyn Error>) - .and_then(|mut file| file.read_to_string(&mut input).map_err(|e| Box::new(e) as Box<dyn Error>)) + .and_then(|mut file| { + file.read_to_string(&mut input) + .map_err(|e| Box::new(e) as Box<dyn Error>) + }) .and_then(|_| syn::parse_str(&input).map_err(|e| Box::new(e) as Box<dyn Error>)) .and_then(|nibble: File| nibble.convert().ok_or(Box::new(UndecVar) as Box<dyn Error>)) .and_then(|(funs, goal)| { @@ -64,10 +68,11 @@ fn main() { fs::File::create(Path::new(&out_dir).join("nibble.rs")) .and_then(|mut f| write!(f, "{}", code)) .map_err(|e| Box::new(e) as Box<dyn Error>) - }); + }) + .unwrap(); - if let Err(e) = res { - eprintln!("{}", e); - exit(1) - } + Command::new("rustfmt") + .arg(&format!("{}/nibble.rs", out_dir)) + .status() + .unwrap(); } |