embed the .aot file into the host binary as C-array
This commit is contained in:
@ -7,29 +7,21 @@
|
||||
#include "bh_read_file.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
#include "../__WASM_ARRAY_FILE__"
|
||||
|
||||
#define STACK_SIZE (8 * 1024)
|
||||
#define HEAP_SIZE (8 * 1024)
|
||||
|
||||
// TODO: Set this up so the lsp actually finds the includes...
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc != 2) {
|
||||
printf("Missing .wasm or .aot file argument!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strstr(argv[1], ".wasm") && !strstr(argv[1], ".aot")) {
|
||||
printf("Only .wasm or .aot files are supported!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8 *buffer;
|
||||
// uint8 *buffer;
|
||||
// uint32 size;
|
||||
char error_buf[128];
|
||||
wasm_module_t module;
|
||||
wasm_module_inst_t module_inst;
|
||||
wasm_function_inst_t func;
|
||||
wasm_exec_env_t exec_env;
|
||||
uint32 size;
|
||||
uint32 stack_size = 8 * 1024;
|
||||
uint32 heap_size = 8 * 1024;
|
||||
|
||||
@ -46,14 +38,18 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
/* read WASM file into a memory buffer */
|
||||
printf("Instantiating module from file '%s'\n", argv[1]);
|
||||
buffer = bh_read_file_to_buffer(argv[1], &size);
|
||||
// printf("Instantiating module from file '%s'\n", argv[1]);
|
||||
// buffer = bh_read_file_to_buffer(argv[1], &size);
|
||||
|
||||
/* add line below if we want to export native functions to WASM app */
|
||||
// wasm_runtime_register_natives(...);
|
||||
|
||||
/* parse the WASM file from buffer and create a WASM module */
|
||||
module = wasm_runtime_load(buffer, size, error_buf, sizeof(error_buf));
|
||||
// module = wasm_runtime_load(buffer, size, error_buf, sizeof(error_buf));
|
||||
|
||||
printf("Instantiating module from buffer\n");
|
||||
module = wasm_runtime_load(__WASM_ARRAY__, __WASM_ARRAY_LEN__, error_buf,
|
||||
sizeof(error_buf));
|
||||
|
||||
/* create an instance of the WASM module (WASM linear memory is ready) */
|
||||
module_inst = wasm_runtime_instantiate(module, stack_size, heap_size,
|
||||
|
||||
Reference in New Issue
Block a user