@@ -11,10 +11,10 @@ use serde_json::json;
1111
1212use super :: compile_cmds:: LinkCmd ;
1313use super :: TranspilerConfig ;
14- use crate :: get_module_name;
1514use crate :: CrateSet ;
1615use crate :: ExternCrateDetails ;
1716use crate :: PragmaSet ;
17+ use crate :: { get_module_name, rustfmt} ;
1818
1919#[ derive( Debug , Copy , Clone ) ]
2020pub enum BuildDirectoryContents {
@@ -225,7 +225,10 @@ fn emit_build_rs(
225225 } ) ;
226226 let output = reg. render ( "build.rs" , & json) . unwrap ( ) ;
227227 let output_path = build_dir. join ( "build.rs" ) ;
228- maybe_write_to_file ( & output_path, output, tcfg. overwrite_existing )
228+ let path = maybe_write_to_file ( & output_path, output, tcfg. overwrite_existing ) ?;
229+ rustfmt ( & output_path, build_dir) ;
230+
231+ Some ( path)
229232}
230233
231234/// Emit lib.rs (main.rs) for a library (binary). Returns `Some(path)`
@@ -252,8 +255,10 @@ fn emit_lib_rs(
252255
253256 let output_path = build_dir. join ( file_name) ;
254257 let output = reg. render ( "lib.rs" , & json) . unwrap ( ) ;
258+ let path = maybe_write_to_file ( & output_path, output, tcfg. overwrite_existing ) ?;
259+ rustfmt ( & output_path, build_dir) ;
255260
256- maybe_write_to_file ( & output_path , output , tcfg . overwrite_existing )
261+ Some ( path )
257262}
258263
259264/// If we translate variadic functions, the output will only compile
0 commit comments