@@ -7,9 +7,10 @@ use anyhow::Result;
77use console:: style;
88use rayon:: prelude:: * ;
99use std:: io:: Write ;
10+ use std:: path:: { Path , PathBuf } ;
1011use std:: time:: Instant ;
1112
12- fn remove_ast ( package : & packages:: Package , source_file : & str ) {
13+ fn remove_ast ( package : & packages:: Package , source_file : & Path ) {
1314 let _ = std:: fs:: remove_file ( helpers:: get_compiler_asset (
1415 package,
1516 & packages:: Namespace :: NoNamespace ,
@@ -18,7 +19,7 @@ fn remove_ast(package: &packages::Package, source_file: &str) {
1819 ) ) ;
1920}
2021
21- fn remove_iast ( package : & packages:: Package , source_file : & str ) {
22+ fn remove_iast ( package : & packages:: Package , source_file : & Path ) {
2223 let _ = std:: fs:: remove_file ( helpers:: get_compiler_asset (
2324 package,
2425 & packages:: Namespace :: NoNamespace ,
@@ -27,15 +28,15 @@ fn remove_iast(package: &packages::Package, source_file: &str) {
2728 ) ) ;
2829}
2930
30- fn remove_mjs_file ( source_file : & str , suffix : & String ) {
31+ fn remove_mjs_file ( source_file : & Path , suffix : & String ) {
3132 let _ = std:: fs:: remove_file ( helpers:: change_extension (
3233 source_file,
3334 // suffix.to_string includes the ., so we need to remove it
3435 & suffix. to_string ( ) [ 1 ..] ,
3536 ) ) ;
3637}
3738
38- fn remove_compile_asset ( package : & packages:: Package , source_file : & str , extension : & str ) {
39+ fn remove_compile_asset ( package : & packages:: Package , source_file : & Path , extension : & str ) {
3940 let _ = std:: fs:: remove_file ( helpers:: get_compiler_asset (
4041 package,
4142 & package. namespace ,
@@ -50,7 +51,7 @@ fn remove_compile_asset(package: &packages::Package, source_file: &str, extensio
5051 ) ) ;
5152}
5253
53- pub fn remove_compile_assets ( package : & packages:: Package , source_file : & str ) {
54+ pub fn remove_compile_assets ( package : & packages:: Package , source_file : & Path ) {
5455 // optimization
5556 // only issue cmti if there is an interfacce file
5657 for extension in & [ "cmj" , "cmi" , "cmt" , "cmti" ] {
@@ -79,23 +80,20 @@ pub fn clean_mjs_files(build_state: &BuildState) {
7980 . filter_map ( |spec| {
8081 if spec. in_source {
8182 Some ( (
82- std:: path:: PathBuf :: from ( package. path . to_string ( ) )
83- . join ( & source_file. implementation . path )
84- . to_string_lossy ( )
85- . to_string ( ) ,
83+ package. path . join ( & source_file. implementation . path ) ,
8684 root_package. config . get_suffix ( spec) ,
8785 ) )
8886 } else {
8987 None
9088 }
9189 } )
92- . collect :: < Vec < ( String , String ) > > ( ) ,
90+ . collect :: < Vec < ( PathBuf , String ) > > ( ) ,
9391 )
9492 }
9593 _ => None ,
9694 } )
9795 . flatten ( )
98- . collect :: < Vec < ( String , String ) > > ( ) ;
96+ . collect :: < Vec < ( PathBuf , String ) > > ( ) ;
9997
10098 rescript_file_locations
10199 . par_iter ( )
@@ -118,7 +116,7 @@ pub fn cleanup_previous_build(
118116 let diff = compile_assets_state
119117 . ast_rescript_file_locations
120118 . difference ( & compile_assets_state. rescript_file_locations )
121- . collect :: < Vec < & String > > ( ) ;
119+ . collect :: < Vec < & PathBuf > > ( ) ;
122120
123121 let diff_len = diff. len ( ) ;
124122
@@ -133,7 +131,7 @@ pub fn cleanup_previous_build(
133131 ..
134132 } = compile_assets_state
135133 . ast_modules
136- . get ( & res_file_location. to_string ( ) )
134+ . get ( * res_file_location)
137135 . expect ( "Could not find module name for ast file" ) ;
138136
139137 let package = build_state
@@ -338,7 +336,12 @@ pub fn cleanup_after_build(build_state: &BuildState) {
338336 } ) ;
339337}
340338
341- pub fn clean ( path : & str , show_progress : bool , bsc_path : Option < String > , build_dev_deps : bool ) -> Result < ( ) > {
339+ pub fn clean (
340+ path : & Path ,
341+ show_progress : bool ,
342+ bsc_path : & Option < PathBuf > ,
343+ build_dev_deps : bool ,
344+ ) -> Result < ( ) > {
342345 let project_root = helpers:: get_abs_path ( path) ;
343346 let workspace_root = helpers:: get_workspace_root ( & project_root) ;
344347 let packages = packages:: make (
@@ -352,7 +355,7 @@ pub fn clean(path: &str, show_progress: bool, bsc_path: Option<String>, build_de
352355 let root_config_name = packages:: read_package_name ( & project_root) ?;
353356 let bsc_path = match bsc_path {
354357 Some ( bsc_path) => helpers:: get_abs_path ( & bsc_path) ,
355- None => helpers:: get_bsc ( & project_root, workspace_root. to_owned ( ) ) ,
358+ None => helpers:: get_bsc ( & project_root, & workspace_root) ,
356359 } ;
357360
358361 let rescript_version = helpers:: get_rescript_version ( & bsc_path) ;
0 commit comments