summaryrefslogtreecommitdiff
path: root/Documentation/coding-style.rst
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-21 18:45:48 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-22 14:30:00 +0200
commit1369c0b7c3d6b195badd0312a675d68506e51b2e (patch)
tree163c0273816efe0ddcc5d6dd7f70416daad34765 /Documentation/coding-style.rst
parent9958387034a86c171beda8b20a5f7d94f99fb783 (diff)
utils: checkstyle: Add support for clang-format
clang-format produces better results than astyle as it can better match the libcamera coding style. Default to clang-format over astyle, fall back to astyle if clang-format isn't found, and add a --formatter command line option to select a formatter manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'Documentation/coding-style.rst')
-rw-r--r--Documentation/coding-style.rst25
1 files changed, 18 insertions, 7 deletions
diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst
index 30a1455d..51afef27 100644
--- a/Documentation/coding-style.rst
+++ b/Documentation/coding-style.rst
@@ -170,8 +170,11 @@ These rules match the `object ownership rules from the Chromium C++ Style Guide`
Tools
-----
-The 'astyle' code formatting tool can be used to reformat source files with the
-libcamera coding style, defined by the following arguments.
+The 'clang-format' code formatting tool can be used to reformat source files
+with the libcamera coding style, defined in the .clang-format file at the root
+of the source tree.
+
+Alternatively the 'astyle' tool can also be used, with the following arguments.
::
@@ -184,11 +187,15 @@ libcamera coding style, defined by the following arguments.
--align-reference=name
--max-code-length=120
-As astyle is a code formatter, it operates on full files outputs reformatted
-source code. While it can be used to reformat code before sending patches, it
-may generate unrelated changes. To avoid this, libcamera provides a
-'checkstyle.py' script wrapping astyle to only retain related changes. This
-should be used to validate modifications before submitting them for review.
+Use of astyle is discouraged as clang-format better matches the libcamera coding
+style.
+
+As both astyle and clang-format are code formatters, they operate on full files
+and output reformatted source code. While they can be used to reformat code
+before sending patches, it may generate unrelated changes. To avoid this,
+libcamera provides a 'checkstyle.py' script wrapping the formatting tools to
+only retain related changes. This should be used to validate modifications
+before submitting them for review.
The script operates on one or multiple git commits specified on the command
line. It does not modify the git tree, the index or the working directory and
@@ -277,4 +284,8 @@ diff that fixes the issues, on top of the corresponding commit. As the script is
in early development false positive are expected. The flagged issues should be
reviewed, but the diff doesn't need to be applied blindly.
+The checkstyle.py script uses clang-format by default if found, and otherwise
+falls back to astyle. The formatter can be manually selected with the
+'--formatter' argument.
+
Happy hacking, libcamera awaits your patches!