Просмотр исходного кода

Update document of embed wamr and code format check (#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
Wenyong Huang 3 лет назад
Родитель
Сommit
e7079eeb17
2 измененных файлов с 33 добавлено и 4 удалено
  1. 10 3
      ci/coding_guidelines_check.py
  2. 23 1
      doc/embed_wamr.md

+ 10 - 3
ci/coding_guidelines_check.py

@@ -96,10 +96,17 @@ def run_clang_format(file_path: pathlib, root: pathlib) -> bool:
 
 def run_clang_format_diff(root: pathlib, commits: str) -> bool:
     """
-    Use `clang-format-12` and `git-clang-format-12` to check code
-    format of the PR, which specificed a commit range. It is required to
-    format code before `git commit` or when failed the PR check:
+    Use `clang-format-12` or `git-clang-format-12` to check code format of
+    the PR, with a commit range specified. It is required to format the
+    code before committing the PR, or it might fail to pass the CI check:
 
+    1. Install clang-format-12.0.0
+    Normally we can install it by `sudo apt-get install clang-format-12`,
+    or download the `clang+llvm-12.0.0-xxx-tar.xz` package from
+      https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0
+    and install it
+
+    2. Format the C/C++ source file
     ``` shell
     cd path/to/wamr/root
     clang-format-12 --style file -i path/to/file

+ 23 - 1
doc/embed_wamr.md

@@ -1,9 +1,31 @@
 Embedding WAMR guideline
 =====================================
 
-
 **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.
 
+## Embed WAMR into developer's project
+
+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:
+``` cmake
+set (WAMR_BUILD_PLATFORM "linux")
+set (WAMR_BUILD_TARGET "X86_64")
+set (WAMR_BUILD_INTERP 1)
+set (WAMR_BUILD_FAST_INTERP 1)
+set (WAMR_BUILD_AOT 1)
+set (WAMR_BUILD_LIBC_BUILTIN 1)
+set (WAMR_BUILD_LIBC_WASI 1)
+set (WAMR_BUILD_SIMD 1)
+set (WAMR_ROOT_DIR path/to/wamr/root)
+
+include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
+add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
+
+target_link_libraries (your_project vmlib)
+```
+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).
+
+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).
+
 ## The runtime initialization
 
 ``` C