From e7079eeb17eaba22d6e87469f34e06cf84ef7787 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Wed, 23 Mar 2022 11:01:57 +0800 Subject: [PATCH] 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 --- ci/coding_guidelines_check.py | 13 ++++++++++--- doc/embed_wamr.md | 24 +++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/ci/coding_guidelines_check.py b/ci/coding_guidelines_check.py index c3fd820e4..062614597 100644 --- a/ci/coding_guidelines_check.py +++ b/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 diff --git a/doc/embed_wamr.md b/doc/embed_wamr.md index 3c1223fa6..b78a0be64 100644 --- a/doc/embed_wamr.md +++ b/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