@@ -15,6 +15,8 @@ use crate::util::{profile, Cfg, Config, Rustc};
1515mod target_info;
1616pub use self :: target_info:: { FileFlavor , TargetInfo } ;
1717
18+ pub const HOST_SANDBOX_TARGET : & str = "wasm32-unknown-unknown" ;
19+
1820/// The build context, containing all information about a build task.
1921///
2022/// It is intended that this is mostly static information. Stuff that mutates
@@ -38,10 +40,13 @@ pub struct BuildContext<'a, 'cfg> {
3840 pub rustc : Rustc ,
3941 /// Build information for the host arch.
4042 pub host_config : TargetConfig ,
43+ /// Build information for the host sandbox arch (wasm).
44+ pub host_sandbox_config : TargetConfig ,
4145 /// Build information for the target.
4246 pub target_config : TargetConfig ,
4347 pub target_info : TargetInfo ,
4448 pub host_info : TargetInfo ,
49+ pub host_sandbox_info : TargetInfo ,
4550 pub units : & ' a UnitInterner < ' a > ,
4651}
4752
@@ -59,18 +64,21 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
5964 let rustc = config. load_global_rustc ( Some ( ws) ) ?;
6065
6166 let host_config = TargetConfig :: new ( config, & rustc. host ) ?;
67+ let host_sandbox_config = TargetConfig :: new ( config, HOST_SANDBOX_TARGET ) ?;
6268 let target_config = match build_config. requested_target . as_ref ( ) {
6369 Some ( triple) => TargetConfig :: new ( config, triple) ?,
6470 None => host_config. clone ( ) ,
6571 } ;
66- let ( host_info, target_info) = {
72+ let ( host_info, host_sandbox_info , target_info) = {
6773 let _p = profile:: start ( "BuildContext::probe_target_info" ) ;
6874 debug ! ( "probe_target_info" ) ;
6975 let host_info =
7076 TargetInfo :: new ( config, & build_config. requested_target , & rustc, Kind :: Host ) ?;
77+ let host_sandbox_info =
78+ TargetInfo :: new ( config, & build_config. requested_target , & rustc, Kind :: HostSandbox ) ?;
7179 let target_info =
7280 TargetInfo :: new ( config, & build_config. requested_target , & rustc, Kind :: Target ) ?;
73- ( host_info, target_info)
81+ ( host_info, host_sandbox_info , target_info)
7482 } ;
7583
7684 Ok ( BuildContext {
@@ -82,7 +90,9 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
8290 target_config,
8391 target_info,
8492 host_config,
93+ host_sandbox_config,
8594 host_info,
95+ host_sandbox_info,
8696 build_config,
8797 profiles,
8898 extra_compiler_args,
@@ -111,6 +121,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
111121 } ;
112122 let ( name, info) = match kind {
113123 Kind :: Host => ( self . host_triple ( ) , & self . host_info ) ,
124+ Kind :: HostSandbox => ( self . host_sandbox_triple ( ) , & self . host_sandbox_info ) ,
114125 Kind :: Target => ( self . target_triple ( ) , & self . target_info ) ,
115126 } ;
116127 platform. matches ( name, info. cfg ( ) )
@@ -130,6 +141,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
130141 pub fn cfg ( & self , kind : Kind ) -> & [ Cfg ] {
131142 let info = match kind {
132143 Kind :: Host => & self . host_info ,
144+ Kind :: HostSandbox => & self . host_sandbox_info ,
133145 Kind :: Target => & self . target_info ,
134146 } ;
135147 info. cfg ( )
@@ -145,6 +157,10 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
145157 & self . rustc . host
146158 }
147159
160+ pub fn host_sandbox_triple ( & self ) -> & str {
161+ HOST_SANDBOX_TARGET
162+ }
163+
148164 pub fn target_triple ( & self ) -> & str {
149165 self . build_config
150166 . requested_target
@@ -157,6 +173,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
157173 fn target_config ( & self , kind : Kind ) -> & TargetConfig {
158174 match kind {
159175 Kind :: Host => & self . host_config ,
176+ Kind :: HostSandbox => & self . host_sandbox_config ,
160177 Kind :: Target => & self . target_config ,
161178 }
162179 }
@@ -181,6 +198,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
181198 fn info ( & self , kind : Kind ) -> & TargetInfo {
182199 match kind {
183200 Kind :: Host => & self . host_info ,
201+ Kind :: HostSandbox => & self . host_sandbox_info ,
184202 Kind :: Target => & self . target_info ,
185203 }
186204 }
@@ -196,6 +214,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
196214 pub fn script_override ( & self , lib_name : & str , kind : Kind ) -> Option < & BuildOutput > {
197215 match kind {
198216 Kind :: Host => self . host_config . overrides . get ( lib_name) ,
217+ Kind :: HostSandbox => self . host_sandbox_config . overrides . get ( lib_name) ,
199218 Kind :: Target => self . target_config . overrides . get ( lib_name) ,
200219 }
201220 }
0 commit comments