@@ -314,8 +314,9 @@ libwasmtime_run_module (void *cookie, char *const argv[], wasm_engine_t *engine,
314
314
static void
315
315
libwasmtime_run_component (void * cookie , char * const argv [], wasm_engine_t * engine , wasm_byte_vec_t * wasm )
316
316
{
317
- const char * wasi_cli_run_interface = "wasi:cli/[email protected] " ;
318
- const char * wasi_cli_run_interface_run = "run" ;
317
+ const char * const wasi_cli_run_interface = "wasi:cli/[email protected] " ;
318
+ const char * const wasi_cli_run_interface_run = "run" ;
319
+ char * const * arg ;
319
320
wasm_byte_vec_t error_message ;
320
321
321
322
// Load needed functions
@@ -333,6 +334,7 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
333
334
void (* wasmtime_wasip2_config_inherit_stdin ) (wasmtime_wasip2_config_t * config );
334
335
void (* wasmtime_wasip2_config_inherit_stdout ) (wasmtime_wasip2_config_t * config );
335
336
void (* wasmtime_wasip2_config_inherit_stderr ) (wasmtime_wasip2_config_t * config );
337
+ void (* wasmtime_wasip2_config_arg ) (wasmtime_wasip2_config_t * config , const char * arg , size_t arg_len );
336
338
void (* wasmtime_context_set_wasip2 ) (wasmtime_context_t * context , wasmtime_wasip2_config_t * config );
337
339
wasmtime_component_linker_t * (* wasmtime_component_linker_new ) (wasm_engine_t * engine );
338
340
wasmtime_error_t * (* wasmtime_component_linker_add_wasip2 ) (wasmtime_component_linker_t * linker );
@@ -375,6 +377,7 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
375
377
wasmtime_wasip2_config_inherit_stdin = dlsym (cookie , "wasmtime_wasip2_config_inherit_stdin" );
376
378
wasmtime_wasip2_config_inherit_stdout = dlsym (cookie , "wasmtime_wasip2_config_inherit_stdout" );
377
379
wasmtime_wasip2_config_inherit_stderr = dlsym (cookie , "wasmtime_wasip2_config_inherit_stderr" );
380
+ wasmtime_wasip2_config_arg = dlsym (cookie , "wasmtime_wasip2_config_arg" );
378
381
wasmtime_context_set_wasip2 = dlsym (cookie , "wasmtime_context_set_wasip2" );
379
382
wasmtime_component_linker_new = dlsym (cookie , "wasmtime_component_linker_new" );
380
383
wasmtime_component_linker_add_wasip2 = dlsym (cookie , "wasmtime_component_linker_add_wasip2" );
@@ -391,7 +394,7 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
391
394
if (wasm_engine_delete == NULL || wasm_byte_vec_delete == NULL || wasmtime_store_new == NULL
392
395
|| wasmtime_store_delete == NULL || wasmtime_store_context == NULL || wasmtime_component_new == NULL
393
396
|| wasmtime_wasip2_config_new == NULL || wasmtime_wasip2_config_inherit_stdin == NULL
394
- || wasmtime_wasip2_config_inherit_stdout == NULL || wasmtime_wasip2_config_inherit_stderr == NULL
397
+ || wasmtime_wasip2_config_inherit_stdout == NULL || wasmtime_wasip2_config_inherit_stderr == NULL || wasmtime_wasip2_config_arg == NULL
395
398
|| wasmtime_context_set_wasip2 == NULL || wasmtime_component_linker_new == NULL || wasmtime_component_linker_add_wasip2 == NULL
396
399
|| wasmtime_component_linker_instantiate == NULL || wasmtime_component_instance_get_export_index == NULL
397
400
|| wasmtime_component_instance_get_func == NULL || wasmtime_component_func_call == NULL || wasmtime_component_export_index_delete == NULL
@@ -422,7 +425,10 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
422
425
wasmtime_wasip2_config_inherit_stdin (wasi_config );
423
426
wasmtime_wasip2_config_inherit_stdout (wasi_config );
424
427
wasmtime_wasip2_config_inherit_stderr (wasi_config );
425
- // TODO: argv
428
+
429
+ for (arg = argv ; * arg != NULL ; ++ arg )
430
+ wasmtime_wasip2_config_arg (wasi_config , * arg , strlen (* arg ));
431
+
426
432
wasmtime_context_set_wasip2 (context , wasi_config );
427
433
428
434
// Get wasi exposing linker
0 commit comments