@@ -85,6 +85,10 @@ impl<'a> BuildAction<'a> {
8585 metadata : & ' a Metadata ,
8686 ) -> Result < Self > {
8787 // TODO: validate params
88+ anyhow:: ensure!(
89+ !params. working_dir. as_os_str( ) . is_empty( ) ,
90+ "working_dir must not be empty"
91+ ) ;
8892 Ok ( Self {
8993 working_dir : absolute ( params. working_dir ) ?,
9094 profile : params. profile ,
@@ -151,14 +155,13 @@ impl<'a> BuildAction<'a> {
151155 ) ;
152156
153157 let mut is_valid_dir_with_rust_projects = false ;
154- for dir in & dirs {
155- if self . fs . dir_file_type ( dir) ?. is_dir ( )
156- && self . fs . exists ( & dir. path ( ) . join ( "Cargo.toml" ) )
157- {
158+ for entry in & dirs {
159+ if entry. is_dir && self . fs . exists ( & entry. path . join ( "Cargo.toml" ) ) {
158160 debug ! (
159- "Found atleast one valid Rust project directory: {}, continuing with the \
161+ "Found at least one valid Rust project directory: {}, continuing with the \
160162 build flow",
161- dir. path( )
163+ entry
164+ . path
162165 . file_name( )
163166 . expect(
164167 "package sub directory name ended with \" ..\" which is not expected"
@@ -179,26 +182,24 @@ impl<'a> BuildAction<'a> {
179182 info ! ( "Building packages in {}" , self . working_dir. display( ) ) ;
180183
181184 let mut failed_atleast_one_project = false ;
182- for dir in dirs {
183- debug ! ( "Checking dir entry: {}" , dir. path( ) . display( ) ) ;
184- if !self . fs . dir_file_type ( & dir) ?. is_dir ( )
185- || !self . fs . exists ( & dir. path ( ) . join ( "Cargo.toml" ) )
186- {
185+ for entry in dirs {
186+ debug ! ( "Checking dir entry: {}" , entry. path. display( ) ) ;
187+ if !entry. is_dir || !self . fs . exists ( & entry. path . join ( "Cargo.toml" ) ) {
187188 debug ! ( "Dir entry is not a valid Rust package" ) ;
188189 continue ;
189190 }
190191
191- let working_dir_path = dir . path ( ) ; // Avoids a short-lived temporary
192- let sub_dir = working_dir_path
192+ let cargo_package_path = entry . path ;
193+ let package_dir_name = cargo_package_path
193194 . file_name ( )
194195 . expect ( "package sub directory name ended with \" ..\" which is not expected" )
195196 . to_string_lossy ( ) ;
196197
197- debug ! ( "Building package(s) in dir {sub_dir }" ) ;
198- if let Err ( e) = self . run_from_workspace_root ( & dir . path ( ) ) {
198+ debug ! ( "Building package(s) in dir {package_dir_name }" ) ;
199+ if let Err ( e) = self . run_from_workspace_root ( & cargo_package_path ) {
199200 failed_atleast_one_project = true ;
200201 err ! (
201- "Error building project: {sub_dir }, error: {:?}" ,
202+ "Error building project: {package_dir_name }, error: {:?}" ,
202203 anyhow:: Error :: new( e)
203204 ) ;
204205 }
0 commit comments