README.md
1## Basic build using CMake
2
3Panda libraries can be built using CMake:
4```
5$ mkdir build
6$ cd build
7$ cmake ${panda_dir}
8$ make
9```
10
11Where ${panda_dir} is a path to panda dirrectory.
12These steps will 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 directory structure, each project has its own subdirectory. For example, the vixl library is located inside the `third_party/vixl` folder. The root CMakeLists.txt has an entry for this directory:
17```
18add_subdirectory(third_party/vixl)
19```
20You may use built libraries in your component (e.g., `target_link_libraries(tests compiler base vixl)`), but for getting variables please use the INTERFACE includes (e.g. `target_include_directories(INTERFACE .)`).
21
22
23## Check style
24
25To check style, build the project and then also build style-checker targets (you must install clang-format and clang-tidy with libraries - look at scripts/bootstrap*.sh):
26```
27$ make clang_format
28 Built target clang_format_opt_tests_graph_creation_test.cpp
29 Built target clang_format_opt_opt.h
30 ...
31
32$ make clang_tidy
33 Scanning dependencies of target copy_json
34 Move compile commands to root directory
35 ...
36 Built target copy_json
37 Scanning dependencies of target clang_tidy_opt_codegen_codegen.cpp
38 ...
39```
40
41You may force fixes for clang-format issues, with the `make clang_force_format` command.
42Run `make help | grep clang` to see all possible clang-[format|style] targets.
43For example, to check style issues in the opt.cpp file, you can use corresponding clang-format target (`make clang_format_opt_opt.cpp`) or the clang-tidy one (`make clang_tidy_opt_opt.cpp`). To force clang-format code style - `make clang_force_format_opt_opt.cpp`.
44To check code-style through just one check-system - use `make clang_tidy` or `make clang_format`.
45
46Generated files:
47* `compile_commands.json` - json nija-commands file to correct execution clang-tidy.
48* Standard cmake-files: `CMakeCache.txt`, `Makefile`, `cmake_install.cmake` and `CMakeFiles` folder.
49
50[Coding style](../docs/coding-style.md)
51
52* Clang-tidy style file - `.clang-tidy`
53* Clang-format style file - `.clang-format`
54* Script to show diff through clang-format execution - `scripts/run-clang-format.py`
55
56## Use wrappers instead of standard CMake funcions
57
58In order to make possible importing prebuilt targets without recompiling them use the following wrappers instead of standard CMake functions:
59
60* panda_add_executable
61* panda_add_library
62* panda_target_link_libraries
63* panda_target_include_directories
64* panda_target_compile_options
65* panda_target_compile_definitions
66* panda_target_sources
67
68If you create a target using panda_add_executable or panda_add_library it is necessary to use other wrappers for this target(panda_target_link_libraries, panda_target_include_directories, etc) otherwise if PANDA_USE_PREBUILT_TARGETS is true then you will get a CMake error.
69
70## Do not add new test to target "tests" dependencies directly
71
72You have to add your new test to dependencies of existing test group "core_tests" or to common group for all tests in plugin("ecmascript_tests", "ets_tests", etc).
73
74