Skip to content

How to format code

Artem Tamazov edited this page Apr 19, 2021 · 9 revisions

Run this script from the root of MIOpen tree (where the .clang-format file resides) prior committing your edits to avoid formatting failures:

#!/bin/bash
find . -iname '*.h' \
    -o -iname '*.hpp' \
    -o -iname '*.cpp' \
    -o -iname '*.h.in' \
    -o -iname '*.hpp.in' \
    -o -iname '*.cpp.in' \
    -o -iname '*.cl' \
| grep -v -E '(build/)|(install/)' \
| xargs -n 1 -P $(nproc) -t clang-format-3.8 -style=file -i 2>/dev/null

The script reformats source files, when necessary. Please do not forget to commit reformatted source files after that.

Note: | grep -v -E '(build/)|(install/)' is used to avoid formatting within ./build/ and ./install/ (I use these for building etc.); please fix this line according to your needs.

--atamazov

Clone this wiki locally