@@ -27,6 +27,8 @@ pub struct WorkspaceBuilder {
27
27
command_timeout : Option < Duration > ,
28
28
command_no_output_timeout : Option < Duration > ,
29
29
fetch_registry_index_during_builds : bool ,
30
+ /// Stores the `--target` to fetch dependencies for.
31
+ fetch_build_std_dependencies : Option < String > ,
30
32
running_inside_docker : bool ,
31
33
fast_init : bool ,
32
34
rustup_profile : String ,
@@ -45,6 +47,7 @@ impl WorkspaceBuilder {
45
47
command_timeout : DEFAULT_COMMAND_TIMEOUT ,
46
48
command_no_output_timeout : DEFAULT_COMMAND_NO_OUTPUT_TIMEOUT ,
47
49
fetch_registry_index_during_builds : true ,
50
+ fetch_build_std_dependencies : None ,
48
51
running_inside_docker : false ,
49
52
fast_init : false ,
50
53
rustup_profile : DEFAULT_RUSTUP_PROFILE . into ( ) ,
@@ -107,6 +110,18 @@ impl WorkspaceBuilder {
107
110
self
108
111
}
109
112
113
+ /// Enable or disable pre-fetching the dependencies for `-Z build-std` when preparing the sandbox (disabled by default).
114
+ ///
115
+ /// When this option is enabled, it is possible to use `-Zbuild-std` inside
116
+ /// the sandbox to build the standard library from source even when
117
+ /// networking is disabled.
118
+ #[ cfg( any( feature = "unstable" , doc) ) ]
119
+ #[ cfg_attr( docs_rs, doc( cfg( feature = "unstable" ) ) ) ]
120
+ pub fn fetch_build_std_dependencies ( mut self , target : String ) -> Self {
121
+ self . fetch_build_std_dependencies = Some ( target) ;
122
+ self
123
+ }
124
+
110
125
/// Enable or disable support for running Rustwide itself inside Docker (disabled by default).
111
126
///
112
127
/// When support is enabled Rustwide will try to detect whether it's actually running inside a
@@ -160,6 +175,7 @@ impl WorkspaceBuilder {
160
175
command_timeout : self . command_timeout ,
161
176
command_no_output_timeout : self . command_no_output_timeout ,
162
177
fetch_registry_index_during_builds : self . fetch_registry_index_during_builds ,
178
+ fetch_build_std_dependencies : self . fetch_build_std_dependencies ,
163
179
current_container : None ,
164
180
rustup_profile : self . rustup_profile ,
165
181
} ) ,
@@ -183,6 +199,7 @@ struct WorkspaceInner {
183
199
command_timeout : Option < Duration > ,
184
200
command_no_output_timeout : Option < Duration > ,
185
201
fetch_registry_index_during_builds : bool ,
202
+ fetch_build_std_dependencies : Option < String > ,
186
203
current_container : Option < CurrentContainer > ,
187
204
rustup_profile : String ,
188
205
}
@@ -299,6 +316,10 @@ impl Workspace {
299
316
self . inner . fetch_registry_index_during_builds
300
317
}
301
318
319
+ pub ( crate ) fn fetch_build_std_dependencies ( & self ) -> Option < & str > {
320
+ self . inner . fetch_build_std_dependencies . as_deref ( )
321
+ }
322
+
302
323
pub ( crate ) fn current_container ( & self ) -> Option < & CurrentContainer > {
303
324
self . inner . current_container . as_ref ( )
304
325
}
0 commit comments