Skip to content

Commit e7079ee

Browse files
authored
Update document of embed wamr and code format check (bytecodealliance#1054)
Update document embed wamr, add how to embed wamr in cmake and makefile Update document coding guideline check, add how to install clang-format-12
1 parent f8ee05d commit e7079ee

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

ci/coding_guidelines_check.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,17 @@ def run_clang_format(file_path: pathlib, root: pathlib) -> bool:
9696

9797
def run_clang_format_diff(root: pathlib, commits: str) -> bool:
9898
"""
99-
Use `clang-format-12` and `git-clang-format-12` to check code
100-
format of the PR, which specificed a commit range. It is required to
101-
format code before `git commit` or when failed the PR check:
99+
Use `clang-format-12` or `git-clang-format-12` to check code format of
100+
the PR, with a commit range specified. It is required to format the
101+
code before committing the PR, or it might fail to pass the CI check:
102102
103+
1. Install clang-format-12.0.0
104+
Normally we can install it by `sudo apt-get install clang-format-12`,
105+
or download the `clang+llvm-12.0.0-xxx-tar.xz` package from
106+
https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0
107+
and install it
108+
109+
2. Format the C/C++ source file
103110
``` shell
104111
cd path/to/wamr/root
105112
clang-format-12 --style file -i path/to/file

doc/embed_wamr.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
Embedding WAMR guideline
22
=====================================
33

4-
54
**Note**: All the embedding APIs supported by the runtime are defined under folder [core/iwasm/include](../core/iwasm/include). The API details are available in the header files.
65

6+
## Embed WAMR into developer's project
7+
8+
WAMR is designed to be easy embeddable in any project, a typical way of building WAMR is to use cmake, developer can configure features by setting cmake variables and then include the script `runtime_lib.cmake` under folder [build-scripts](../build-scripts) in his CMakeList.txt, for example:
9+
``` cmake
10+
set (WAMR_BUILD_PLATFORM "linux")
11+
set (WAMR_BUILD_TARGET "X86_64")
12+
set (WAMR_BUILD_INTERP 1)
13+
set (WAMR_BUILD_FAST_INTERP 1)
14+
set (WAMR_BUILD_AOT 1)
15+
set (WAMR_BUILD_LIBC_BUILTIN 1)
16+
set (WAMR_BUILD_LIBC_WASI 1)
17+
set (WAMR_BUILD_SIMD 1)
18+
set (WAMR_ROOT_DIR path/to/wamr/root)
19+
20+
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
21+
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
22+
23+
target_link_libraries (your_project vmlib)
24+
```
25+
Examples can be found in [CMakeLists.txt of linux platform](../product-mini/platforms/linux/CMakeLists.txt) and [other platforms](../product-mini/platforms). The available features to configure can be found in [Build WAMR vmcore](./build_wamr.md#wamr-vmcore-cmake-building-configurations).
26+
27+
Developer can also use Makefile to embed WAMR, by defining macros and including directories, and adding the source files, examples can be found in [makefile of alios-things platform](../product-mini/platforms/alios-things/aos.mk) and [makefile of nuttx platform](../product-mini/platforms/nuttx/wamr.mk).
28+
729
## The runtime initialization
830

931
``` C

0 commit comments

Comments
 (0)