@@ -190,83 +190,6 @@ impl ConfigInfo {
190
190
command
191
191
}
192
192
193
- fn download_gccjit (
194
- & self ,
195
- output_dir : & Path ,
196
- libgccjit_so_name : & str ,
197
- commit : & str ,
198
- ) -> Result < ( ) , String > {
199
- // Download time!
200
- let tempfile_name = format ! ( "{}.download" , libgccjit_so_name) ;
201
- let tempfile = output_dir. join ( & tempfile_name) ;
202
- let is_in_ci = std:: env:: var ( "GITHUB_ACTIONS" ) . is_ok ( ) ;
203
-
204
- let url = format ! (
205
- "https://github.com/antoyo/gcc/releases/download/master-{}/libgccjit.so" ,
206
- commit,
207
- ) ;
208
-
209
- println ! ( "Downloading `{}`..." , url) ;
210
- // Try curl. If that fails and we are on windows, fallback to PowerShell.
211
- let mut ret = run_command_with_output (
212
- & [
213
- & "curl" ,
214
- & "--speed-time" ,
215
- & "30" ,
216
- & "--speed-limit" ,
217
- & "10" , // timeout if speed is < 10 bytes/sec for > 30 seconds
218
- & "--connect-timeout" ,
219
- & "30" , // timeout if cannot connect within 30 seconds
220
- & "-o" ,
221
- & tempfile_name,
222
- & "--retry" ,
223
- & "3" ,
224
- & "-SRfL" ,
225
- if is_in_ci { & "-s" } else { & "--progress-bar" } ,
226
- & url. as_str ( ) ,
227
- ] ,
228
- Some ( & output_dir) ,
229
- ) ;
230
- if ret. is_err ( ) && cfg ! ( windows) {
231
- eprintln ! ( "Fallback to PowerShell" ) ;
232
- ret = run_command_with_output (
233
- & [
234
- & "PowerShell.exe" ,
235
- & "/nologo" ,
236
- & "-Command" ,
237
- & "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" ,
238
- & format ! (
239
- "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
240
- url,
241
- tempfile_name,
242
- ) . as_str ( ) ,
243
- ] ,
244
- Some ( & output_dir) ,
245
- ) ;
246
- }
247
- ret?;
248
-
249
- let libgccjit_so = output_dir. join ( libgccjit_so_name) ;
250
- // If we reach this point, it means the file was correctly downloaded, so let's
251
- // rename it!
252
- std:: fs:: rename ( & tempfile, & libgccjit_so) . map_err ( |err| {
253
- format ! (
254
- "Failed to rename `{}` into `{}`: {:?}" ,
255
- tempfile. display( ) ,
256
- libgccjit_so. display( ) ,
257
- err,
258
- )
259
- } ) ?;
260
-
261
- println ! ( "Downloaded libgccjit.so version {} successfully!" , commit) ;
262
- // We need to create a link named `libgccjit.so.0` because that's what the linker is
263
- // looking for.
264
- create_symlink (
265
- & libgccjit_so,
266
- output_dir. join ( & format ! ( "{}.0" , libgccjit_so_name) ) ,
267
- )
268
- }
269
-
270
193
fn download_gccjit_if_needed ( & mut self ) -> Result < ( ) , String > {
271
194
let output_dir = Path :: new (
272
195
std:: env:: var ( "CARGO_TARGET_DIR" )
@@ -313,7 +236,38 @@ impl ConfigInfo {
313
236
let libgccjit_so_name = "libgccjit.so" ;
314
237
let libgccjit_so = output_dir. join ( libgccjit_so_name) ;
315
238
if !libgccjit_so. is_file ( ) && !self . no_download {
316
- self . download_gccjit ( & output_dir, libgccjit_so_name, commit) ?;
239
+ // Download time!
240
+ let tempfile_name = format ! ( "{}.download" , libgccjit_so_name) ;
241
+ let tempfile = output_dir. join ( & tempfile_name) ;
242
+ let is_in_ci = std:: env:: var ( "GITHUB_ACTIONS" ) . is_ok ( ) ;
243
+
244
+ let url = format ! (
245
+ "https://github.com/antoyo/gcc/releases/download/master-{}/libgccjit.so" ,
246
+ commit,
247
+ ) ;
248
+
249
+ println ! ( "Downloading `{}`..." , url) ;
250
+ download_gccjit ( url, & output_dir, tempfile_name, !is_in_ci) ?;
251
+
252
+ let libgccjit_so = output_dir. join ( libgccjit_so_name) ;
253
+ // If we reach this point, it means the file was correctly downloaded, so let's
254
+ // rename it!
255
+ std:: fs:: rename ( & tempfile, & libgccjit_so) . map_err ( |err| {
256
+ format ! (
257
+ "Failed to rename `{}` into `{}`: {:?}" ,
258
+ tempfile. display( ) ,
259
+ libgccjit_so. display( ) ,
260
+ err,
261
+ )
262
+ } ) ?;
263
+
264
+ println ! ( "Downloaded libgccjit.so version {} successfully!" , commit) ;
265
+ // We need to create a link named `libgccjit.so.0` because that's what the linker is
266
+ // looking for.
267
+ create_symlink (
268
+ & libgccjit_so,
269
+ output_dir. join ( & format ! ( "{}.0" , libgccjit_so_name) ) ,
270
+ ) ?;
317
271
}
318
272
319
273
self . gcc_path = output_dir. display ( ) . to_string ( ) ;
@@ -547,3 +501,49 @@ impl ConfigInfo {
547
501
) ;
548
502
}
549
503
}
504
+
505
+ fn download_gccjit (
506
+ url : String ,
507
+ output_dir : & Path ,
508
+ tempfile_name : String ,
509
+ with_progress_bar : bool ,
510
+ ) -> Result < ( ) , String > {
511
+ // Try curl. If that fails and we are on windows, fallback to PowerShell.
512
+ let mut ret = run_command_with_output (
513
+ & [
514
+ & "curl" ,
515
+ & "--speed-time" ,
516
+ & "30" ,
517
+ & "--speed-limit" ,
518
+ & "10" , // timeout if speed is < 10 bytes/sec for > 30 seconds
519
+ & "--connect-timeout" ,
520
+ & "30" , // timeout if cannot connect within 30 seconds
521
+ & "-o" ,
522
+ & tempfile_name,
523
+ & "--retry" ,
524
+ & "3" ,
525
+ & "-SRfL" ,
526
+ if with_progress_bar { & "--progress-bar" } else { & "-s" } ,
527
+ & url. as_str ( ) ,
528
+ ] ,
529
+ Some ( & output_dir) ,
530
+ ) ;
531
+ if ret. is_err ( ) && cfg ! ( windows) {
532
+ eprintln ! ( "Fallback to PowerShell" ) ;
533
+ ret = run_command_with_output (
534
+ & [
535
+ & "PowerShell.exe" ,
536
+ & "/nologo" ,
537
+ & "-Command" ,
538
+ & "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;" ,
539
+ & format ! (
540
+ "(New-Object System.Net.WebClient).DownloadFile('{}', '{}')" ,
541
+ url,
542
+ tempfile_name,
543
+ ) . as_str ( ) ,
544
+ ] ,
545
+ Some ( & output_dir) ,
546
+ ) ;
547
+ }
548
+ ret
549
+ }
0 commit comments