11use crate :: { BuildEnv , Platform } ;
2- use anyhow:: Result ;
2+ use anyhow:: { Context , Result } ;
33use indicatif:: { ProgressBar , ProgressDrawTarget , ProgressStyle } ;
4+ use log:: info;
45use mvn:: Download ;
56use reqwest:: blocking:: Client ;
67use std:: fs:: File ;
@@ -37,7 +38,10 @@ impl<'a> Download for DownloadManager<'a> {
3738 let len = resp. content_length ( ) . unwrap_or_default ( ) ;
3839 pb. set_length ( len) ;
3940
40- let dest = BufWriter :: new ( File :: create ( dest) ?) ;
41+ let dest = BufWriter :: new (
42+ File :: create ( dest)
43+ . with_context ( || format ! ( "While creating download output file `{dest:?}`" ) ) ?,
44+ ) ;
4145 std:: io:: copy ( & mut resp, & mut pb. wrap_write ( dest) ) ?;
4246 pb. finish_with_message ( "📥 downloaded" ) ;
4347
@@ -125,8 +129,14 @@ impl<'a> DownloadManager<'a> {
125129 }
126130
127131 pub fn prefetch ( & self ) -> Result < ( ) > {
128- for target in self . env ( ) . target ( ) . compile_targets ( ) {
129- self . rustup_target ( target. rust_triple ( ) ?) ?;
132+ // TODO: We might want to compare the targets instead, in case the user is not building for
133+ // the host but specified exactly the same triple after all.
134+ if !self . env ( ) . target ( ) . is_host ( ) {
135+ for target in self . env ( ) . target ( ) . compile_targets ( ) {
136+ self . rustup_target ( target. rust_triple ( ) ?) ?;
137+ }
138+ } else {
139+ info ! ( "Building for host, assuming everything is available" ) ;
130140 }
131141
132142 match self . env ( ) . target ( ) . platform ( ) {
@@ -140,8 +150,8 @@ impl<'a> DownloadManager<'a> {
140150 self . macos_sdk ( ) ?;
141151 }
142152 Platform :: Android => {
143- self . android_ndk ( ) ?;
144- self . android_jar ( ) ?;
153+ self . android_ndk ( ) . context ( "ndk" ) ?;
154+ self . android_jar ( ) . context ( "jar" ) ?;
145155 }
146156 Platform :: Ios => {
147157 self . ios_sdk ( ) ?;
0 commit comments