@@ -15,6 +15,8 @@ use crate::util::{profile, Cfg, Config, Rustc};
15
15
mod target_info;
16
16
pub use self :: target_info:: { FileFlavor , TargetInfo } ;
17
17
18
+ pub const HOST_SANDBOX_TARGET : & str = "wasm32-unknown-unknown" ;
19
+
18
20
/// The build context, containing all information about a build task.
19
21
///
20
22
/// It is intended that this is mostly static information. Stuff that mutates
@@ -38,10 +40,13 @@ pub struct BuildContext<'a, 'cfg> {
38
40
pub rustc : Rustc ,
39
41
/// Build information for the host arch.
40
42
pub host_config : TargetConfig ,
43
+ /// Build information for the host sandbox arch (wasm).
44
+ pub host_sandbox_config : TargetConfig ,
41
45
/// Build information for the target.
42
46
pub target_config : TargetConfig ,
43
47
pub target_info : TargetInfo ,
44
48
pub host_info : TargetInfo ,
49
+ pub host_sandbox_info : TargetInfo ,
45
50
pub units : & ' a UnitInterner < ' a > ,
46
51
}
47
52
@@ -59,18 +64,21 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
59
64
let rustc = config. load_global_rustc ( Some ( ws) ) ?;
60
65
61
66
let host_config = TargetConfig :: new ( config, & rustc. host ) ?;
67
+ let host_sandbox_config = TargetConfig :: new ( config, HOST_SANDBOX_TARGET ) ?;
62
68
let target_config = match build_config. requested_target . as_ref ( ) {
63
69
Some ( triple) => TargetConfig :: new ( config, triple) ?,
64
70
None => host_config. clone ( ) ,
65
71
} ;
66
- let ( host_info, target_info) = {
72
+ let ( host_info, host_sandbox_info , target_info) = {
67
73
let _p = profile:: start ( "BuildContext::probe_target_info" ) ;
68
74
debug ! ( "probe_target_info" ) ;
69
75
let host_info =
70
76
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 ) ?;
71
79
let target_info =
72
80
TargetInfo :: new ( config, & build_config. requested_target , & rustc, Kind :: Target ) ?;
73
- ( host_info, target_info)
81
+ ( host_info, host_sandbox_info , target_info)
74
82
} ;
75
83
76
84
Ok ( BuildContext {
@@ -82,7 +90,9 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
82
90
target_config,
83
91
target_info,
84
92
host_config,
93
+ host_sandbox_config,
85
94
host_info,
95
+ host_sandbox_info,
86
96
build_config,
87
97
profiles,
88
98
extra_compiler_args,
@@ -111,6 +121,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
111
121
} ;
112
122
let ( name, info) = match kind {
113
123
Kind :: Host => ( self . host_triple ( ) , & self . host_info ) ,
124
+ Kind :: HostSandbox => ( self . host_sandbox_triple ( ) , & self . host_sandbox_info ) ,
114
125
Kind :: Target => ( self . target_triple ( ) , & self . target_info ) ,
115
126
} ;
116
127
platform. matches ( name, info. cfg ( ) )
@@ -130,6 +141,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
130
141
pub fn cfg ( & self , kind : Kind ) -> & [ Cfg ] {
131
142
let info = match kind {
132
143
Kind :: Host => & self . host_info ,
144
+ Kind :: HostSandbox => & self . host_sandbox_info ,
133
145
Kind :: Target => & self . target_info ,
134
146
} ;
135
147
info. cfg ( )
@@ -145,6 +157,10 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
145
157
& self . rustc . host
146
158
}
147
159
160
+ pub fn host_sandbox_triple ( & self ) -> & str {
161
+ HOST_SANDBOX_TARGET
162
+ }
163
+
148
164
pub fn target_triple ( & self ) -> & str {
149
165
self . build_config
150
166
. requested_target
@@ -157,6 +173,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
157
173
fn target_config ( & self , kind : Kind ) -> & TargetConfig {
158
174
match kind {
159
175
Kind :: Host => & self . host_config ,
176
+ Kind :: HostSandbox => & self . host_sandbox_config ,
160
177
Kind :: Target => & self . target_config ,
161
178
}
162
179
}
@@ -181,6 +198,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
181
198
fn info ( & self , kind : Kind ) -> & TargetInfo {
182
199
match kind {
183
200
Kind :: Host => & self . host_info ,
201
+ Kind :: HostSandbox => & self . host_sandbox_info ,
184
202
Kind :: Target => & self . target_info ,
185
203
}
186
204
}
@@ -196,6 +214,7 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> {
196
214
pub fn script_override ( & self , lib_name : & str , kind : Kind ) -> Option < & BuildOutput > {
197
215
match kind {
198
216
Kind :: Host => self . host_config . overrides . get ( lib_name) ,
217
+ Kind :: HostSandbox => self . host_sandbox_config . overrides . get ( lib_name) ,
199
218
Kind :: Target => self . target_config . overrides . get ( lib_name) ,
200
219
}
201
220
}
0 commit comments