Progressia/docs/DevelopmentSetupGuide.md
OLEGSHA ae4e265a90
Squash improve-ide-compat into main
Fixes GH-5

- cppcheck replaced with clang-tidy
- clang-tidy lint warnings fixed
- Reworked build tools from scratch to make IDE setup easier
- Added 1.5 IDE setup guides
2023-11-10 21:30:55 +01:00

2.9 KiB
Raw Blame History

Development setup guide

This document provides instructions for setting up a development environment for Progressia. See also Building Guide and IDE setup guides.

To make development easier, contributors should be using a few tools. Included with the project are configurations and scripts for these tools:

  • clang-tidy performs static code analysis for C++
  • clang-format formats C++ source code
  • Vulkan validation layers checks for errors in Vulkan API usage at runtime (see below for details)
  • memcheck (part of valgrind) performs runtime memory error detection on Linux

Additionally, a git pre-commit hook prevents committing code that is formatted incorrectly, does not compile or produces warnings.

Basic setup

Follow Building Guide instructions before proceeding.

Debian/Ubuntu:

# Install clang-tidy and clang-format-diff
sudo apt update && sudo apt install -y \
    clang-tidy clang-format

# Enable DEV_MODE (sets up git pre-commit hook)
cmake -S . -B build -DDEV_MODE=ON

Fedora:

# Install clang-tidy and clang-format-diff
sudo dnf install -y \
    clang-tools-extra clang

# Enable DEV_MODE (sets up git pre-commit hook)
cmake -S . -B build -DDEV_MODE=ON

Windows: see IDE setup guides.

Pre-commit git hook

A git pre-commit hook is installed to correct formatting and check for compilation/linting issues. This check can be bypassed with git commit --no-verify in case of dire need.

The hook runs tools/pre-commit.py, which formats modified files and ensures that cmake --build build executes without errors. Several git operations are performed by pre-commit.py; run tools/pre-commit.py restore to restore the state of the repository in case the hook crashes.

The list of directories with source code to format and the list of source code filename extensions are hard-coded into the Python script.

Vulkan validation layers

LunarG validation layers are extremely useful when debugging Vulkan code. The official Vulkan tutorial has detailed instructions for all platforms.

Use CMake option VULKAN_ERROR_CHECKING to enable the use of validation layers.

Debian/Ubuntu users can install this dependency using APT:

apt install vulkan-validationlayers-dev

Fedora users can install this dependency using dnf:

dnf install vulkan-validation-layers-devel

Windows users can install this dependency when installing LunarG distribution.

memcheck

tools/valgrind-memcheck-suppressions.supp contains useful suppressions for memcheck.