blob: df1135e0ae64cf561c4849148fa28ccf57a7d941 [file] [log] [blame]
Salome Thirot0ea1daf2021-04-23 13:16:16 +01001############
2clang-format
3############
4
5This tool uses clang-format and the script clang-format-diff.py provided
6in the clang tools to apply style checking on all staged files. You can
7use it before committing to check for any style that does not comply
8with the TF-M coding guidelines.
9
10*************
11How to use it
12*************
13
14Using the configuration script
15==============================
16
17 - Install clang-format on your system, the tool is available as part of the
18 clang suite, but can also be installed standalone from a packet manager.
19 - After that the only thing the user needs to do is run the
20 run-clang-format.sh script while in the TF-M root folder. If any
21 dependency is missing, it will call the setup script to install it.
22
23Without using the configuration script
24======================================
25
26 - Make sure clang-format is installed in your system
27 - Copy the .clang-format file to the root of the tf-m directory -
28 - Download clang-format-diff from the llvm `github repository`_
29 - Run
30
31.. code-block:: bash
32
33 git diff -U0 --no-color HEAD^ | <path/to/clang-format-diff.py> -p1 -style file> <out_file>
34
35If clang-format makes any correction, a diff file will be created in the
36tfm root directory, simply run ``git apply <diff_file>`` to apply them.
37
38.. _github repository: https://github.com/llvm/llvm-project/blob/main/clang/tools/clang-format/clang-format-diff.py
39
40*Copyright (c) 2021, Arm Limited. All rights reserved.*
41*SPDX-License-Identifier: BSD-3-Clause*