README.md
1## Basic build
2
3Panda libraries can be built using CMake:
4```
5$ mkdir build
6$ cd build
7$ cmake ${panda_dir}
8$ make
9```
10
11Here, ${panda_dir} refers to path to panda dirrectory.
12After this step, create libraries and some debug-targets if you have installed additional libraries, like google-test, clang-format, clang-tidy, etc.
13
14## Build directory structure
15
16In the current build, create subdirectories for each project. For example, for the vixl library, create the `third_party/vixl` directory. Add the following command in root CMakeLists.txt:
17```
18add_subdirectory(third_party/vixl)
19```
20You may use built libraries in your component, e.g. target_link_libraries(tests compiler base vixl). However, for getting variables, use INTERFACE includes, e.g. target_include_directories(INTERFACE .) instead.
21
22## Run tests
23
24The tests-binary will also be generated during the build. To run tests, run the following command:
25```
26$ make test
27Running tests...
28Test project /home/igorban/src/panda_build
29 Start 1: compiler_unit_tests
301/1 Test #1: compiler_unit_tests ................... Passed 2.74 sec
31..
32```
33
34## Calculate coverage
35
36To calculate the test code coverage - just execute it:
37```
38$ make coverage
39```
40Location of the code coverage report: BUILD_DIR/compiler/coverage_report
41
42## Check style
43
44To check the style, perform the previous steps and build style-checker targets. Note that you must install clang-format and clang-tidy with libraries. For details, see scripts/bootstrap*.sh.
45```
46$ make clang_format
47 Built target clang_format_opt_tests_graph_creation_test.cpp
48 Built target clang_format_opt_opt.h
49 ...
50
51$ make clang_tidy
52 Scanning dependencies of target copy_json
53 Move compile commands to root directory
54 ...
55 Built target copy_json
56 Scanning dependencies of target clang_tidy_opt_codegen_codegen.cpp
57 ...
58```
59
60You may force fix clang-format issues using the `make clang_force_format` command.
61Run `make help | grep clang` to see all possible clang-[format|style] targets.
62For issues in opt.cpp, you may check the style through clang-format `make clang_format_opt_opt.cpp`, or through clang-tidy `make clang_tidy_opt_opt.cpp`. For the force clang-format code style, use `make clang_force_format_opt_opt.cpp`.
63For code-style check through one check system, use `make clang_tidy` or `make clang_format`.
64
65Generated files:
66* `compile_commands.json` - json nija-commands file to correct execution clang-tidy.
67* Standard cmake-files: `CMakeCache.txt`, `Makefile`, `cmake_install.cmake` and folder `CMakeFiles`.
68
69
70Discussion about format : rus-os-team/virtual-machines-and-tools/vm-investigation-and-design#24
71* Clang-tidy style file - `.clang-tidy`
72* Clang-format style file - `.clang-format`
73* Script to show diff through clang-format execution - `build/run-clang-format.py`
74