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 11#![ allow( clippy:: option_if_let_else) ]
22
33use std:: env;
4+ use std:: ffi:: OsString ;
45use std:: path:: Path ;
5- use std:: process:: { Command , ExitStatus , Stdio } ;
6+ use std:: process:: { self , Command , ExitStatus , Stdio } ;
67use std:: str;
78
89#[ cfg( all( feature = "backtrace" , not( feature = "std" ) ) ) ]
@@ -66,8 +67,8 @@ fn compile_probe() -> Option<ExitStatus> {
6667 return None ;
6768 }
6869
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" ) ;
7172 let probefile = Path :: new ( "build" ) . join ( "probe.rs" ) ;
7273
7374 // Make sure to pick up Cargo rustc configuration.
@@ -115,3 +116,13 @@ fn rustc_minor_version() -> Option<u32> {
115116 }
116117 pieces. next ( ) ?. parse ( ) . ok ( )
117118}
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