@@ -17,6 +17,20 @@ use wasmer_runtime_core::{self, backend::CompilerConfig};
17
17
#[ cfg( feature = "wasi" ) ]
18
18
use wasmer_wasi;
19
19
20
+ // stub module to make conditional compilation happy
21
+ #[ cfg( not( feature = "wasi" ) ) ]
22
+ mod wasmer_wasi {
23
+ use wasmer_runtime_core:: { import:: ImportObject , module:: Module } ;
24
+
25
+ pub fn is_wasi_module ( _module : & Module ) -> bool {
26
+ false
27
+ }
28
+
29
+ pub fn generate_import_object ( _args : Vec < Vec < u8 > > , _envs : Vec < Vec < u8 > > ) -> ImportObject {
30
+ unimplemented ! ( )
31
+ }
32
+ }
33
+
20
34
#[ derive( Debug , StructOpt ) ]
21
35
#[ structopt( name = "wasmer" , about = "Wasm execution runtime." ) ]
22
36
/// The options for the wasmer Command Line Interface
@@ -213,7 +227,6 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
213
227
} ;
214
228
215
229
// TODO: refactor this
216
- #[ cfg( not( feature = "wasi" ) ) ]
217
230
let ( abi, import_object, _em_globals) = if wasmer_emscripten:: is_emscripten_module ( & module) {
218
231
let mut emscripten_globals = wasmer_emscripten:: EmscriptenGlobals :: new ( & module) ;
219
232
(
@@ -222,34 +235,29 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
222
235
Some ( emscripten_globals) , // TODO Em Globals is here to extend, lifetime, find better solution
223
236
)
224
237
} else {
225
- (
226
- InstanceABI :: None ,
227
- wasmer_runtime_core:: import:: ImportObject :: new ( ) ,
228
- None ,
229
- )
230
- } ;
231
-
232
- #[ cfg( feature = "wasi" ) ]
233
- let ( abi, import_object) = if wasmer_wasi:: is_wasi_module ( & module) {
234
- (
235
- InstanceABI :: WASI ,
236
- wasmer_wasi:: generate_import_object (
237
- [ options. path . to_str ( ) . unwrap ( ) . to_owned ( ) ]
238
- . iter ( )
239
- . chain ( options. args . iter ( ) )
240
- . cloned ( )
241
- . map ( |arg| arg. into_bytes ( ) )
242
- . collect ( ) ,
243
- env:: vars ( )
244
- . map ( |( k, v) | format ! ( "{}={}" , k, v) . into_bytes ( ) )
245
- . collect ( ) ,
246
- ) ,
247
- )
248
- } else {
249
- (
250
- InstanceABI :: None ,
251
- wasmer_runtime_core:: import:: ImportObject :: new ( ) ,
252
- )
238
+ if cfg ! ( feature = "wasi" ) && wasmer_wasi:: is_wasi_module ( & module) {
239
+ (
240
+ InstanceABI :: WASI ,
241
+ wasmer_wasi:: generate_import_object (
242
+ [ options. path . to_str ( ) . unwrap ( ) . to_owned ( ) ]
243
+ . iter ( )
244
+ . chain ( options. args . iter ( ) )
245
+ . cloned ( )
246
+ . map ( |arg| arg. into_bytes ( ) )
247
+ . collect ( ) ,
248
+ env:: vars ( )
249
+ . map ( |( k, v) | format ! ( "{}={}" , k, v) . into_bytes ( ) )
250
+ . collect ( ) ,
251
+ ) ,
252
+ None ,
253
+ )
254
+ } else {
255
+ (
256
+ InstanceABI :: None ,
257
+ wasmer_runtime_core:: import:: ImportObject :: new ( ) ,
258
+ None ,
259
+ )
260
+ }
253
261
} ;
254
262
255
263
let mut instance = module
0 commit comments