summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/basic/README.md
blob: 32e7ed6501d0516c86f7a56b7f4cca28ceeaabac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 -f 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
```