@@ -2,19 +2,21 @@ use std::collections::BTreeMap;
22use std:: fs:: { self , File } ;
33use std:: io:: Write ;
44use std:: path:: { Path , PathBuf } ;
5+ use std:: process:: Command ;
56use std:: str:: FromStr ;
67
78use handlebars:: Handlebars ;
9+ use log:: warn;
810use pathdiff:: diff_paths;
911use serde_derive:: Serialize ;
1012use serde_json:: json;
1113
1214use super :: compile_cmds:: LinkCmd ;
1315use super :: TranspilerConfig ;
14- use crate :: get_module_name;
1516use crate :: CrateSet ;
1617use crate :: ExternCrateDetails ;
1718use crate :: PragmaSet ;
19+ use crate :: { get_module_name, rustfmt} ;
1820
1921#[ derive( Debug , Copy , Clone ) ]
2022pub enum BuildDirectoryContents {
@@ -225,7 +227,10 @@ fn emit_build_rs(
225227 } ) ;
226228 let output = reg. render ( "build.rs" , & json) . unwrap ( ) ;
227229 let output_path = build_dir. join ( "build.rs" ) ;
228- maybe_write_to_file ( & output_path, output, tcfg. overwrite_existing )
230+ let path = maybe_write_to_file ( & output_path, output, tcfg. overwrite_existing ) ?;
231+ rustfmt ( & output_path, build_dir) ;
232+
233+ Some ( path)
229234}
230235
231236/// Emit lib.rs (main.rs) for a library (binary). Returns `Some(path)`
@@ -252,8 +257,10 @@ fn emit_lib_rs(
252257
253258 let output_path = build_dir. join ( file_name) ;
254259 let output = reg. render ( "lib.rs" , & json) . unwrap ( ) ;
260+ let path = maybe_write_to_file ( & output_path, output, tcfg. overwrite_existing ) ?;
261+ rustfmt ( & output_path, build_dir) ;
255262
256- maybe_write_to_file ( & output_path , output , tcfg . overwrite_existing )
263+ Some ( path )
257264}
258265
259266/// If we translate variadic functions, the output will only compile
0 commit comments