@@ -638,32 +638,60 @@ fn download_file(url: &str, filename: &Path) {
638638 fs:: remove_file ( & tmpfile) . unwrap ( ) ;
639639 }
640640
641- // Try downloading with python first. Python is a V8 build dependency,
641+ // Try downloading with deno first, then python, then curl.
642+ println ! ( "Downloading {url}" ) ;
643+ let status = which ( "deno" ) . ok ( ) . and_then ( |deno| {
644+ println ! ( "Trying with Deno..." ) ;
645+ Command :: new ( deno)
646+ . arg ( "eval" )
647+ . arg (
648+ "const [url, path] = Deno.args; \
649+ const resp = await fetch(url); \
650+ if (!resp.ok) Deno.exit(1); \
651+ const file = await Deno.open(path, { write: true, create: true }); \
652+ await resp.body.pipeTo(file.writable);",
653+ )
654+ . arg ( "--allow-net" )
655+ . arg ( "--allow-write" )
656+ . arg ( "--" )
657+ . arg ( url)
658+ . arg ( & tmpfile)
659+ . status ( )
660+ . ok ( )
661+ . filter ( |s| s. success ( ) )
662+ } ) ;
663+
664+ // Try downloading with python. Python is a V8 build dependency,
642665 // so this saves us from adding a Rust HTTP client dependency.
643- println ! ( "Downloading (using Python) {url}" ) ;
644- let status = Command :: new ( python ( ) )
645- . arg ( "./tools/download_file.py" )
646- . arg ( "--url" )
647- . arg ( url)
648- . arg ( "--filename" )
649- . arg ( & tmpfile)
650- . status ( ) ;
651-
652- // Python is only a required dependency for `V8_FROM_SOURCE` builds.
653- // If python is not available, try falling back to curl.
654666 let status = match status {
655- Ok ( status) if status . success ( ) => status,
667+ Some ( status) => status,
656668 _ => {
657- println ! ( "Python downloader failed, trying with curl." ) ;
658- Command :: new ( "curl" )
659- . arg ( "-L" )
660- . arg ( "-f" )
661- . arg ( "-s" )
662- . arg ( "-o" )
663- . arg ( & tmpfile)
669+ println ! ( "Trying with Python..." ) ;
670+ let python_status = Command :: new ( python ( ) )
671+ . arg ( "./tools/download_file.py" )
672+ . arg ( "--url" )
664673 . arg ( url)
665- . status ( )
666- . unwrap ( )
674+ . arg ( "--filename" )
675+ . arg ( & tmpfile)
676+ . status ( ) ;
677+
678+ // Python is only a required dependency for `V8_FROM_SOURCE` builds.
679+ // If python is not available, try falling back to curl.
680+ match python_status {
681+ Ok ( status) if status. success ( ) => status,
682+ _ => {
683+ println ! ( "Python downloader failed, trying with curl." ) ;
684+ Command :: new ( "curl" )
685+ . arg ( "-L" )
686+ . arg ( "-f" )
687+ . arg ( "-s" )
688+ . arg ( "-o" )
689+ . arg ( & tmpfile)
690+ . arg ( url)
691+ . status ( )
692+ . unwrap ( )
693+ }
694+ }
667695 }
668696 } ;
669697
0 commit comments