| 1 | # Developer's Guide |
| 2 | |
| 3 | ## Building on Linux |
| 4 | |
| 5 | If you want to build the `libyaml-path` library and `yamlp` filtering utility follow the these instructions: |
| 6 | |
| 7 | |
| 8 | ### 1. Get the source code |
| 9 | |
| 10 | ```sh |
| 11 | $ git clone https://github.com/OpenSCAP/yaml-filter.git |
| 12 | $ cd yaml-filter |
| 13 | ``` |
| 14 | |
| 15 | |
| 16 | ### 2. *Get the build dependencies* |
| 17 | |
| 18 | To build the library you will also need to install the build dependencies. |
| 19 | |
| 20 | The project relies on CMake (`cmake`) build system and C99 compiler (for example `gcc`). |
| 21 | |
| 22 | The only mandatroy dependency of `libyaml-path` is the YAML document parser/emitter library `libyaml`. You can also use `lcov` for coverage reports, but it is optional. |
| 23 | |
| 24 | ```sh |
| 25 | # Ubuntu |
| 26 | $ sudo apt-get install -y libyaml-0-2 |
| 27 | ``` |
| 28 | |
| 29 | ```sh |
| 30 | # Fedora |
| 31 | $ sudo dnf install -y libyaml lcov |
| 32 | ``` |
| 33 | |
| 34 | When you have all the build dependencies installed you can build the library. |
| 35 | |
| 36 | |
| 37 | ### 3. *Build the project* |
| 38 | |
| 39 | Run the following commands to build the library and filtering utility: |
| 40 | |
| 41 | ```sh |
| 42 | $ mkdir -p build |
| 43 | $ cd build/ |
| 44 | $ cmake .. |
| 45 | $ make |
| 46 | ``` |
| 47 | |
| 48 | |
| 49 | ### 3. *Run the tests* |
| 50 | |
| 51 | Now you can execute the following command to run library self-checks: |
| 52 | |
| 53 | ```sh |
| 54 | $ ctest |
| 55 | ``` |
| 56 | |
| 57 | |
| 58 | ### 4. *Install* |
| 59 | |
| 60 | Run the installation procedure by executing the following command: |
| 61 | |
| 62 | ```sh |
| 63 | $ make install |
| 64 | ``` |
| 65 | |
| 66 | You can also configure CMake to install everything into the $HOME/.local directory: |
| 67 | |
| 68 | ```sh |
| 69 | $ cd build |
| 70 | $ rm -rf * |
| 71 | $ cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local .. |
| 72 | $ make |
| 73 | $ make install |
| 74 | ``` |
| 75 | |
| 76 | |
| 77 | ### 5. *Generate code coverage report* |
| 78 | |
| 79 | You can use `lcov` for code coverage report generation. It is integrated into the project's build configuration: |
| 80 | |
| 81 | ```sh |
| 82 | $ cd build |
| 83 | $ cmake -DENABLE_COVERAGE=yes .. |
| 84 | $ make && ctest -V |
| 85 | $ make gcov |
| 86 | ``` |