1- use color_eyre:: eyre:: { ensure , Result } ;
1+ use color_eyre:: eyre:: { bail , Result } ;
22use std:: {
33 path:: { Path , PathBuf } ,
44 process:: Command ,
@@ -12,13 +12,14 @@ pub fn build_dependencies(config: &Config) -> Result<Vec<(String, PathBuf)>> {
1212 Some ( path) => path,
1313 None => return Ok ( vec ! [ ] ) ,
1414 } ;
15- let ( program, args) : ( & Path , & [ _ ] ) = match & config. dependency_builder {
16- Some ( ( path, args) ) => ( path, args) ,
17- None => ( Path :: new ( "cargo" ) , & [ ] ) ,
15+ let ( program, args, envs ) : ( & Path , & [ _ ] , & [ _ ] ) = match & config. dependency_builder {
16+ Some ( ( path, args, envs ) ) => ( path, args, envs ) ,
17+ None => ( Path :: new ( "cargo" ) , & [ ] , & [ ] ) ,
1818 } ;
1919 let mut build = Command :: new ( program) ;
2020 build. env_clear ( ) ;
2121 build. env ( "PATH" , std:: env:: var_os ( "PATH" ) . unwrap ( ) ) ;
22+ build. envs ( envs. iter ( ) . map ( |( k, v) | ( k, v) ) ) ;
2223 build. args ( args) ;
2324 build. arg ( "run" ) ;
2425 if let Some ( target) = & config. target {
@@ -32,7 +33,12 @@ pub fn build_dependencies(config: &Config) -> Result<Vec<(String, PathBuf)>> {
3233
3334 let output = build. output ( ) ?;
3435
35- ensure ! ( output. status. success( ) , "{output:#?}" ) ;
36+ if !output. status . success ( ) {
37+ let stdout = String :: from_utf8 ( output. stdout ) ?;
38+ let stderr = String :: from_utf8 ( output. stderr ) ?;
39+ bail ! ( "failed to compile dependencies:\n stderr:\n {stderr}\n \n stdout:{stdout}" ) ;
40+ }
41+
3642 let output = output. stdout ;
3743 let output = String :: from_utf8 ( output) ?;
3844 Ok ( output
0 commit comments