@@ -3,7 +3,6 @@ use std::ffi::OsString;
33use std:: fs:: { self , File } ;
44use std:: io:: { BufRead , BufReader , BufWriter , ErrorKind , Write } ;
55use std:: path:: { Path , PathBuf } ;
6- use std:: process:: Command ;
76use std:: sync:: OnceLock ;
87
98use xz2:: bufread:: XzDecoder ;
@@ -16,12 +15,6 @@ use crate::{Config, t};
1615
1716static SHOULD_FIX_BINS_AND_DYLIBS : OnceLock < bool > = OnceLock :: new ( ) ;
1817
19- /// `Config::try_run` wrapper for this module to avoid warnings on `try_run`, since we don't have access to a `builder` yet.
20- fn try_run ( config : & Config , cmd : & mut Command ) -> Result < ( ) , ( ) > {
21- #[ expect( deprecated) ]
22- config. try_run ( cmd)
23- }
24-
2518fn extract_curl_version ( out : String ) -> semver:: Version {
2619 // The output should look like this: "curl <major>.<minor>.<patch> ..."
2720 out. lines ( )
@@ -169,23 +162,18 @@ impl Config {
169162 ];
170163 }
171164 " ;
172- nix_build_succeeded = try_run (
173- self ,
174- Command :: new ( "nix-build" ) . args ( [
175- Path :: new ( "-E" ) ,
176- Path :: new ( NIX_EXPR ) ,
177- Path :: new ( "-o" ) ,
178- & nix_deps_dir,
179- ] ) ,
180- )
181- . is_ok ( ) ;
165+ nix_build_succeeded = command ( "nix-build" )
166+ . allow_failure ( )
167+ . args ( [ Path :: new ( "-E" ) , Path :: new ( NIX_EXPR ) , Path :: new ( "-o" ) , & nix_deps_dir] )
168+ . run_capture_stdout_exec_ctx ( self )
169+ . is_success ( ) ;
182170 nix_deps_dir
183171 } ) ;
184172 if !nix_build_succeeded {
185173 return ;
186174 }
187175
188- let mut patchelf = Command :: new ( nix_deps_dir. join ( "bin/patchelf" ) ) ;
176+ let mut patchelf = command ( nix_deps_dir. join ( "bin/patchelf" ) ) ;
189177 patchelf. args ( & [
190178 OsString :: from ( "--add-rpath" ) ,
191179 OsString :: from ( t ! ( fs:: canonicalize( nix_deps_dir) ) . join ( "lib" ) ) ,
@@ -196,8 +184,8 @@ impl Config {
196184 let dynamic_linker = t ! ( fs:: read_to_string( dynamic_linker_path) ) ;
197185 patchelf. args ( [ "--set-interpreter" , dynamic_linker. trim_end ( ) ] ) ;
198186 }
199-
200- let _ = try_run ( self , patchelf. arg ( fname ) ) ;
187+ patchelf . arg ( fname ) ;
188+ let _ = patchelf. run_capture_stdout_exec_ctx ( self ) ;
201189 }
202190
203191 fn download_file ( & self , url : & str , dest_path : & Path , help_on_error : & str ) {
@@ -271,17 +259,20 @@ impl Config {
271259 if self . build . contains ( "windows-msvc" ) {
272260 eprintln ! ( "Fallback to PowerShell" ) ;
273261 for _ in 0 ..3 {
274- if try_run ( self , Command :: new ( "PowerShell.exe" ) . args ( [
262+ let powershell = command ( "PowerShell.exe" ) . args ( [
275263 "/nologo" ,
276264 "-Command" ,
277265 "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" ,
278266 & format ! (
279267 "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
280268 url, tempfile. to_str( ) . expect( "invalid UTF-8 not supported with powershell downloads" ) ,
281269 ) ,
282- ] ) ) . is_err ( ) {
270+ ] ) . run_capture_stdout_exec_ctx ( self ) ;
271+
272+ if powershell. is_failure ( ) {
283273 return ;
284274 }
275+
285276 eprintln ! ( "\n spurious failure, trying again" ) ;
286277 }
287278 }
0 commit comments