@@ -3,7 +3,6 @@ use std::ffi::OsString;
3
3
use std:: fs:: { self , File } ;
4
4
use std:: io:: { BufRead , BufReader , BufWriter , ErrorKind , Write } ;
5
5
use std:: path:: { Path , PathBuf } ;
6
- use std:: process:: Command ;
7
6
use std:: sync:: OnceLock ;
8
7
9
8
use xz2:: bufread:: XzDecoder ;
@@ -16,12 +15,6 @@ use crate::{Config, t};
16
15
17
16
static SHOULD_FIX_BINS_AND_DYLIBS : OnceLock < bool > = OnceLock :: new ( ) ;
18
17
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
-
25
18
fn extract_curl_version ( out : String ) -> semver:: Version {
26
19
// The output should look like this: "curl <major>.<minor>.<patch> ..."
27
20
out. lines ( )
@@ -169,23 +162,18 @@ impl Config {
169
162
];
170
163
}
171
164
" ;
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 ( ) ;
182
170
nix_deps_dir
183
171
} ) ;
184
172
if !nix_build_succeeded {
185
173
return ;
186
174
}
187
175
188
- let mut patchelf = Command :: new ( nix_deps_dir. join ( "bin/patchelf" ) ) ;
176
+ let mut patchelf = command ( nix_deps_dir. join ( "bin/patchelf" ) ) ;
189
177
patchelf. args ( & [
190
178
OsString :: from ( "--add-rpath" ) ,
191
179
OsString :: from ( t ! ( fs:: canonicalize( nix_deps_dir) ) . join ( "lib" ) ) ,
@@ -196,8 +184,8 @@ impl Config {
196
184
let dynamic_linker = t ! ( fs:: read_to_string( dynamic_linker_path) ) ;
197
185
patchelf. args ( [ "--set-interpreter" , dynamic_linker. trim_end ( ) ] ) ;
198
186
}
199
-
200
- let _ = try_run ( self , patchelf. arg ( fname ) ) ;
187
+ patchelf . arg ( fname ) ;
188
+ let _ = patchelf. run_capture_stdout_exec_ctx ( self ) ;
201
189
}
202
190
203
191
fn download_file ( & self , url : & str , dest_path : & Path , help_on_error : & str ) {
@@ -271,17 +259,20 @@ impl Config {
271
259
if self . build . contains ( "windows-msvc" ) {
272
260
eprintln ! ( "Fallback to PowerShell" ) ;
273
261
for _ in 0 ..3 {
274
- if try_run ( self , Command :: new ( "PowerShell.exe" ) . args ( [
262
+ let powershell = command ( "PowerShell.exe" ) . args ( [
275
263
"/nologo" ,
276
264
"-Command" ,
277
265
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" ,
278
266
& format ! (
279
267
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
280
268
url, tempfile. to_str( ) . expect( "invalid UTF-8 not supported with powershell downloads" ) ,
281
269
) ,
282
- ] ) ) . is_err ( ) {
270
+ ] ) . run_capture_stdout_exec_ctx ( self ) ;
271
+
272
+ if powershell. is_failure ( ) {
283
273
return ;
284
274
}
275
+
285
276
eprintln ! ( "\n spurious failure, trying again" ) ;
286
277
}
287
278
}
0 commit comments