File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
#![ allow( clippy:: option_if_let_else) ]
2
2
3
3
use std:: env;
4
+ use std:: ffi:: OsString ;
4
5
use std:: path:: Path ;
5
- use std:: process:: { Command , ExitStatus , Stdio } ;
6
+ use std:: process:: { self , Command , ExitStatus , Stdio } ;
6
7
use std:: str;
7
8
8
9
#[ cfg( all( feature = "backtrace" , not( feature = "std" ) ) ) ]
@@ -66,8 +67,8 @@ fn compile_probe() -> Option<ExitStatus> {
66
67
return None ;
67
68
}
68
69
69
- let rustc = env :: var_os ( "RUSTC" ) ? ;
70
- let out_dir = env :: var_os ( "OUT_DIR" ) ? ;
70
+ let rustc = cargo_env_var ( "RUSTC" ) ;
71
+ let out_dir = cargo_env_var ( "OUT_DIR" ) ;
71
72
let probefile = Path :: new ( "build" ) . join ( "probe.rs" ) ;
72
73
73
74
// Make sure to pick up Cargo rustc configuration.
@@ -115,3 +116,13 @@ fn rustc_minor_version() -> Option<u32> {
115
116
}
116
117
pieces. next ( ) ?. parse ( ) . ok ( )
117
118
}
119
+
120
+ fn cargo_env_var ( key : & str ) -> OsString {
121
+ env:: var_os ( key) . unwrap_or_else ( || {
122
+ eprintln ! (
123
+ "Environment variable ${} is not set during execution of build script" ,
124
+ key,
125
+ ) ;
126
+ process:: exit ( 1 ) ;
127
+ } )
128
+ }
You can’t perform that action at this time.
0 commit comments