1
1
use crate :: { BuildEnv , Platform } ;
2
- use anyhow:: Result ;
2
+ use anyhow:: { Context , Result } ;
3
3
use indicatif:: { ProgressBar , ProgressDrawTarget , ProgressStyle } ;
4
+ use log:: info;
4
5
use mvn:: Download ;
5
6
use reqwest:: blocking:: Client ;
6
7
use std:: fs:: File ;
@@ -37,7 +38,10 @@ impl<'a> Download for DownloadManager<'a> {
37
38
let len = resp. content_length ( ) . unwrap_or_default ( ) ;
38
39
pb. set_length ( len) ;
39
40
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
+ ) ;
41
45
std:: io:: copy ( & mut resp, & mut pb. wrap_write ( dest) ) ?;
42
46
pb. finish_with_message ( "📥 downloaded" ) ;
43
47
@@ -125,8 +129,14 @@ impl<'a> DownloadManager<'a> {
125
129
}
126
130
127
131
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" ) ;
130
140
}
131
141
132
142
match self . env ( ) . target ( ) . platform ( ) {
@@ -140,8 +150,8 @@ impl<'a> DownloadManager<'a> {
140
150
self . macos_sdk ( ) ?;
141
151
}
142
152
Platform :: Android => {
143
- self . android_ndk ( ) ?;
144
- self . android_jar ( ) ?;
153
+ self . android_ndk ( ) . context ( "ndk" ) ?;
154
+ self . android_jar ( ) . context ( "jar" ) ?;
145
155
}
146
156
Platform :: Ios => {
147
157
self . ios_sdk ( ) ?;
0 commit comments