@@ -27,6 +27,8 @@ pub struct WorkspaceBuilder {
2727 command_timeout : Option < Duration > ,
2828 command_no_output_timeout : Option < Duration > ,
2929 fetch_registry_index_during_builds : bool ,
30+ /// Stores the `--target` to fetch dependencies for.
31+ fetch_build_std_dependencies : Option < String > ,
3032 running_inside_docker : bool ,
3133 fast_init : bool ,
3234 rustup_profile : String ,
@@ -45,6 +47,7 @@ impl WorkspaceBuilder {
4547 command_timeout : DEFAULT_COMMAND_TIMEOUT ,
4648 command_no_output_timeout : DEFAULT_COMMAND_NO_OUTPUT_TIMEOUT ,
4749 fetch_registry_index_during_builds : true ,
50+ fetch_build_std_dependencies : None ,
4851 running_inside_docker : false ,
4952 fast_init : false ,
5053 rustup_profile : DEFAULT_RUSTUP_PROFILE . into ( ) ,
@@ -107,6 +110,18 @@ impl WorkspaceBuilder {
107110 self
108111 }
109112
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+
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 : Option < String > ,
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 ) -> Option < & str > {
320+ self . inner . fetch_build_std_dependencies . as_deref ( )
321+ }
322+
302323 pub ( crate ) fn current_container ( & self ) -> Option < & CurrentContainer > {
303324 self . inner . current_container . as_ref ( )
304325 }
0 commit comments