From 26e4a873ff016820586f88cc5fefbeb17b0066bb Mon Sep 17 00:00:00 2001 From: shining Date: Wed, 26 Feb 2020 10:50:33 +0800 Subject: [PATCH] Update the Developer_Guide doc Add the static code analysis doc into the Developer_Guide en version. Update the Developer_Guide cn version to use the output dir instead of the out dir. The output dir is the new output dir which is out dir in the past. --- doc/cn/Developer_Guide.md | 4 ++-- doc/en/Developer_Guide.md | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/cn/Developer_Guide.md b/doc/cn/Developer_Guide.md index 7a07e51494..ef8afa2039 100644 --- a/doc/cn/Developer_Guide.md +++ b/doc/cn/Developer_Guide.md @@ -71,11 +71,11 @@ make 静态源码检查之前,需要先编译出OpenArkCompiler。此后,以检查src/maple_driver源码为例,在openarkcompiler目录下执行以下命令: ``` -cp out/compile_commands.json ./ +cp output/compile_commands.json ./ ./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py -clang-tidy-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-tidy' -clang-apply-replacements-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-apply-replacements' src/maple_driver/ ``` 命令说明: -- `cp out/compile_commands.json ./` 将out目录之下的compile_commands.json复制到当前目录之下,它是clang-tidy运行所需要的编译命令; +- `cp output/compile_commands.json ./` 将output目录之下的compile_commands.json复制到当前目录之下,它是clang-tidy运行所需要的编译命令; - `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py` 调用clang-tidy进行批量检查的脚本run-clang-tidy.py,其中 `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/`目录是之前配置的clang编译器的发行包主目录; `-clang-tidy-binary` 是指明clang-tidy的具体位置; `-clang-apply-replacements-binary` 是指明run-clang-tidy.py所依赖的clang-apply-replacements的位置; `src/maple_driver/` 是要进行源码检查的目录。 diff --git a/doc/en/Developer_Guide.md b/doc/en/Developer_Guide.md index b366eb323d..569757600e 100644 --- a/doc/en/Developer_Guide.md +++ b/doc/en/Developer_Guide.md @@ -1,6 +1,6 @@ # Developer Guide -By referring to this document, you can download the OpenArkCompiler source code to compile it. +By referring to this document, you can download the OpenArkCompiler source code to compile it. At the same time, this document also provide the guide of static code analysis to developers. ## Prerequisites @@ -64,3 +64,19 @@ make cd samples/helloworld/ make ``` + +## Static code analysis + +This part will guide you to do the static code analysis by using the clang-tidy. After the code is changed, the static code analysis will check the coding specifications to improve the code quality. + +Before the static code analysis, we need compiled the OpenArkCompiler. After that, using the code of src/maple_driver as the tested directory, run the following commands in the openarkcompiler directory: + +``` +cp output/compile_commands.json ./ +./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py -clang-tidy-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-tidy' -clang-apply-replacements-binary='./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-apply-replacements' src/maple_driver/ +``` +Command description: + +- `cp output/compile_commands.json ./`: Copy the compile_commands.json in the output directory to the openarkcompiler directory, it is required by the clang-tidy, it contains the compile commands of OpenArkCompiler. + +- `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/share/clang/run-clang-tidy.py`: Call the run-clang-tidy.py which is the parallel clang-tidy runner. The `./tools/clang_llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/` directory is the directory of the release package of clang compiler. The `-clang-tidy-binary` set the path of clang-tidy binary. The `-clang-apply-replacements-binary` set the path of the clang-apply-replacements binary which is requried by the run-clang-tidy.py. The `src/maple_driver/` is the tested code directory. -- Gitee