@@ -27,6 +27,7 @@ pub struct WorkspaceBuilder {
2727 command_timeout : Option < Duration > ,
2828 command_no_output_timeout : Option < Duration > ,
2929 fetch_registry_index_during_builds : bool ,
30+ fetch_build_std_dependencies : bool ,
3031 running_inside_docker : bool ,
3132 fast_init : bool ,
3233 rustup_profile : String ,
@@ -45,6 +46,7 @@ impl WorkspaceBuilder {
4546 command_timeout : DEFAULT_COMMAND_TIMEOUT ,
4647 command_no_output_timeout : DEFAULT_COMMAND_NO_OUTPUT_TIMEOUT ,
4748 fetch_registry_index_during_builds : true ,
49+ fetch_build_std_dependencies : false ,
4850 running_inside_docker : false ,
4951 fast_init : false ,
5052 rustup_profile : DEFAULT_RUSTUP_PROFILE . into ( ) ,
@@ -107,6 +109,19 @@ impl WorkspaceBuilder {
107109 self
108110 }
109111
112+ /// Enable or disable pre-fetching the dependencies for `-Z build-std` when preparing the sandbox (disabled by default).
113+ ///
114+ /// When this option is enabled, it is possible to use `-Zbuild-std` inside
115+ /// the sandbox to build the standard library from source even when
116+ /// networking is disabled. You will still need to run
117+ /// `toolchain.add_component("rust-src")` before entering the sandbox.
118+ #[ cfg( any( feature = "unstable" , doc) ) ]
119+ #[ cfg_attr( docs_rs, doc( cfg( feature = "unstable" ) ) ) ]
120+ pub fn fetch_build_std_dependencies ( mut self , enable : bool ) -> Self {
121+ self . fetch_build_std_dependencies = enable;
122+ self
123+ }
124+
110125 /// Enable or disable support for running Rustwide itself inside Docker (disabled by default).
111126 ///
112127 /// When support is enabled Rustwide will try to detect whether it's actually running inside a
@@ -160,6 +175,7 @@ impl WorkspaceBuilder {
160175 command_timeout : self . command_timeout ,
161176 command_no_output_timeout : self . command_no_output_timeout ,
162177 fetch_registry_index_during_builds : self . fetch_registry_index_during_builds ,
178+ fetch_build_std_dependencies : self . fetch_build_std_dependencies ,
163179 current_container : None ,
164180 rustup_profile : self . rustup_profile ,
165181 } ) ,
@@ -183,6 +199,7 @@ struct WorkspaceInner {
183199 command_timeout : Option < Duration > ,
184200 command_no_output_timeout : Option < Duration > ,
185201 fetch_registry_index_during_builds : bool ,
202+ fetch_build_std_dependencies : bool ,
186203 current_container : Option < CurrentContainer > ,
187204 rustup_profile : String ,
188205}
@@ -299,6 +316,10 @@ impl Workspace {
299316 self . inner . fetch_registry_index_during_builds
300317 }
301318
319+ pub ( crate ) fn fetch_build_std_dependencies ( & self ) -> bool {
320+ self . inner . fetch_build_std_dependencies
321+ }
322+
302323 pub ( crate ) fn current_container ( & self ) -> Option < & CurrentContainer > {
303324 self . inner . current_container . as_ref ( )
304325 }
0 commit comments