1
- use color_eyre:: eyre:: { ensure , Result } ;
1
+ use color_eyre:: eyre:: { bail , Result } ;
2
2
use std:: {
3
3
path:: { Path , PathBuf } ,
4
4
process:: Command ,
@@ -12,13 +12,14 @@ pub fn build_dependencies(config: &Config) -> Result<Vec<(String, PathBuf)>> {
12
12
Some ( path) => path,
13
13
None => return Ok ( vec ! [ ] ) ,
14
14
} ;
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" ) , & [ ] , & [ ] ) ,
18
18
} ;
19
19
let mut build = Command :: new ( program) ;
20
20
build. env_clear ( ) ;
21
21
build. env ( "PATH" , std:: env:: var_os ( "PATH" ) . unwrap ( ) ) ;
22
+ build. envs ( envs. iter ( ) . map ( |( k, v) | ( k, v) ) ) ;
22
23
build. args ( args) ;
23
24
build. arg ( "run" ) ;
24
25
if let Some ( target) = & config. target {
@@ -32,7 +33,12 @@ pub fn build_dependencies(config: &Config) -> Result<Vec<(String, PathBuf)>> {
32
33
33
34
let output = build. output ( ) ?;
34
35
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
+
36
42
let output = output. stdout ;
37
43
let output = String :: from_utf8 ( output) ?;
38
44
Ok ( output
0 commit comments