Skip to content

ClangFormat

thomaskeller79 edited this page Oct 18, 2019 · 1 revision

Clang-format hook script

We use clang-format-3.8 to automatically format source code according to our coding conventions. We highly recommend to automatically reject commits with wrong formatting via a hook script. To setup the hook:

cd </path/to/prost-repo/>scripts
./setup-hooks.sh

From now on, all commits with wrongly formatted source code will be rejected.


Applying clang-format on all source files

We also provide a script that applies clang-format-3.8 to all files in src/rddl_parser and src/search. To run it, do:

cd </path/to/prost-repo/>scripts
./clang-format-all.sh

Please be careful with the usage of this script as it applies all changes in files, i.e., your original files will be lost!


Installing clang-format-3.8

If your Linux distribution does not ship with clang-format-3.8 you can use the official PPA:

Add the PPA key:

wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -

Add the repository to /etc/apt/sources.list by appending the following line:

deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.8 main

Update and install clang-format:


sudo apt-get update
sudo apt-get install clang-format-3.8

Clone this wiki locally