Add a basic sample to show how native runtime invokes wasm apps in WAMR and how wasm apps invoke native functions. (#207)
* Add printingAdd print time for wamrc, fix posix mmap bug time for wamrc, fixed a posix mmap bug. Change-Id: Ib6517b8a69cf022a1a6a74efa1f98155aec143bc * Add a basic sample to show how native runtime invokes wasm app in WAMR, and how wasm app invokes native functions. Change-Id: I700ae413ad5e9ea04540d5187952305e1ee92d73
This commit is contained in:
51
samples/basic/README.md
Normal file
51
samples/basic/README.md
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
|
||||
The "basic" sample project
|
||||
==============
|
||||
|
||||
This sample demonstrates a few basic usages of embedding WAMR:
|
||||
- initialize runtime
|
||||
- load wasm app and instantiate the module
|
||||
- call wasm function and pass arguments
|
||||
- export native functions to the WASM apps
|
||||
- wasm function calls native function and pass arguments
|
||||
- deinitialize runtime
|
||||
|
||||
Build this sample
|
||||
==============
|
||||
Execute the ```build.sh``` script then all binaries including wasm application files would be generated in 'out' directory.
|
||||
|
||||
```
|
||||
$ ./build.sh
|
||||
```
|
||||
|
||||
Run the sample
|
||||
==========================
|
||||
Enter the out directory.
|
||||
```
|
||||
$ cd ./out/
|
||||
$
|
||||
$ ./basic wasm-apps/testapp.wasm
|
||||
calling into WASM function: generate_float
|
||||
Native finished calling wasm function generate_float(), returned a float value: 102009.921875f
|
||||
calling into WASM function: float_to_string
|
||||
calling into native function: intToStr
|
||||
calling into native function: get_pow
|
||||
calling into native function: intToStr
|
||||
Native finished calling wasm function: float_to_string, returned a formatted string: 102009.921
|
||||
```
|
||||
Or execute the ```run.sh``` script in ```samples/basic``` folder.
|
||||
```
|
||||
$ ./run.sh
|
||||
calling into WASM function: generate_float
|
||||
Native finished calling wasm function generate_float(), returned a float value: 102009.921875f
|
||||
calling into WASM function: float_to_string
|
||||
calling into native function: intToStr
|
||||
calling into native function: get_pow
|
||||
calling into native function: intToStr
|
||||
Native finished calling wasm function: float_to_string, returned a formatted string: 102009.921
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user