{"id":13278,"url":"https://patchwork.libcamera.org/api/patches/13278/?format=json","web_url":"https://patchwork.libcamera.org/patch/13278/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210810101748.2029495-1-kieran.bingham@ideasonboard.com>","date":"2021-08-10T10:17:48","name":"[libcamera-devel,v3] clang-format: Regroup sort orders","commit_ref":"0e1ff86e78ae1813b29972ce4a682ad99dbb41e3","pull_url":null,"state":"accepted","archived":false,"hash":"d78764d87aa487e58d1f151208f711af8ad5aab2","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13278/mbox/","series":[{"id":2330,"url":"https://patchwork.libcamera.org/api/series/2330/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2330","date":"2021-08-10T10:17:48","name":"[libcamera-devel,v3] clang-format: Regroup sort orders","version":3,"mbox":"https://patchwork.libcamera.org/series/2330/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13278/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13278/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2B0D7BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Aug 2021 10:17:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EA0876884D;\n\tTue, 10 Aug 2021 12:17:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 508B0687F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Aug 2021 12:17:52 +0200 (CEST)","from Monstersaurus.local\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DFF5B3F0;\n\tTue, 10 Aug 2021 12:17:51 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"fFiMsAC1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628590672;\n\tbh=5zRpiZsIMgUQOsmKiW/gH8cuXENdjM1FHujZtvk4pqw=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=fFiMsAC12BL3mJw3EWszGAWp/iFAKaOzokOsyFyNwnRVZRH980aXA1mpWVMeN3GvQ\n\tZAWahGSjcp9B4fnYkZF5xOhtIz7xfvzOlZk++9wa0pdWV3h5ZhRLvbPJAlGvTwq6pg\n\tpMgW0O6W3BXPKYj+RyNtZqWlE6SApTcS1LWbZi6Q=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 10 Aug 2021 11:17:48 +0100","Message-Id":"<20210810101748.2029495-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.30.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3] clang-format: Regroup sort orders","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Utilise the clang-format header sort to provide a regex based pattern\nmatch for our header inclusion coding style.\n\nThe rules are updated to match as close as possible the existing\npractices and the documentation is updated accordingly.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\n\nv3:\n - Merge C++ back with C and system headers\n - Add some explicit pre-matching for known external headers that are\n   not system headers.\n\n .clang-format                  | 53 ++++++++++++++++++++++++++++++++--\n Documentation/coding-style.rst | 17 +++++++++--\n 2 files changed, 64 insertions(+), 6 deletions(-)","diff":"diff --git a/.clang-format b/.clang-format\nindex 3a8a896e373d..ff60b928affc 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -66,10 +66,57 @@ ExperimentalAutoDetectBinPacking: false\n FixNamespaceComments: true\n ForEachMacros:\n   - 'udev_list_entry_foreach'\n-IncludeBlocks: Preserve\n+SortIncludes: true\n+IncludeBlocks: Regroup\n IncludeCategories:\n-  - Regex: '.*'\n-    Priority: 1\n+  # Headers matching the name of the component are matched automatically.\n+  # Priority 1\n+  # Other library headers (explicit overrides to match before system headers)\n+  - Regex:           '(<jpeglib.h>|<libudev.h>|<tiffio.h>|<xf86drm.h>|<xf86drmMode.h>|<yaml.h>)'\n+    Priority:        9\n+  # Qt includes (match before C++ standard library)\n+  - Regex:           '<Q([A-Za-z0-9\\-_])+>'\n+    Priority:        9\n+    CaseSensitive:   true\n+  # Headers in <> with an extension. (+system libraries)\n+  - Regex:           '<([A-Za-z0-9\\-_])+\\.h>'\n+    Priority:        2\n+  # System headers \n+  - Regex:           '<sys/.*>'\n+    Priority:        2\n+  # C++ standard library includes (no extension)\n+  - Regex:           '<([A-Za-z0-9\\-_/])+>'\n+    Priority:        2\n+  # Linux headers, as a second group/subset of system headers\n+  - Regex:           '<linux/.*>'\n+    Priority:        3\n+  # Headers for libcamera Base support\n+  - Regex:           '<libcamera/base/private.h>'\n+    Priority:        4\n+  - Regex:           '<libcamera/base/.*\\.h>'\n+    Priority:        5\n+  # Public API Headers for libcamera, which are not in a subdir (i.e. ipa/,internal/)\n+  - Regex:           '<libcamera/([A-Za-z0-9\\-_])+.h>'\n+    Priority:        6\n+  # IPA Interfaces\n+  - Regex:           '<libcamera/ipa/.*\\.h>'\n+    Priority:        7\n+  # libcamera Internal headers in \"\"  \n+  - Regex:           '\"libcamera/internal/.*\\.h\"'\n+    Priority:        8\n+  # Other libraries headers with one group per library (.h or .hpp)\n+  - Regex:           '<.*/.*\\.hp*>'\n+    Priority:        9\n+  # local modular includes \"path/file.h\" (.h or .hpp)\n+  - Regex:           '\"(.*/)+.*\\.hp*\"'\n+    Priority:        10\n+  # Other local headers \"file.h\" with extension (.h or .hpp)\n+  - Regex:           '\".*.hp*\"'\n+    Priority:        11\n+  # Any unmatched line, separated from the last group\n+  - Regex:\t     '\"*\"'\n+    Priority:        100\n+\n IncludeIsMainRegex: '(_test)?$'\n IndentCaseLabels: false\n IndentPPDirectives: None\ndiff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst\nindex 5db7f480af05..ef3a0d1714ab 100644\n--- a/Documentation/coding-style.rst\n+++ b/Documentation/coding-style.rst\n@@ -70,19 +70,30 @@ macro. For .cpp files, if the file implements an API declared in a header file,\n that header file shall be included first in order to ensure it is\n self-contained.\n \n+While the following list is extensive, it documents the expected behaviour\n+defined by the clang-format configuration and tooling should assist with\n+ordering.\n+\n The headers shall be grouped and ordered as follows:\n \n 1. The header declaring the API being implemented (if any)\n 2. The C and C++ system and standard library headers\n-3. Other libraries' headers, with one group per library\n-4. Other project's headers\n+3. Linux kernel headers\n+4. The libcamera base private header if required\n+5. The libcamera base library headers\n+6. The libcamera public API headers\n+7. The libcamera IPA interfaces\n+8. The internal libcamera headers\n+9. Other libraries' headers, with one group per library\n+10. Local headers grouped by subdirectory\n+11. Any local headers\n \n Groups of headers shall be separated by a single blank line. Headers within\n each group shall be sorted alphabetically.\n \n System and library headers shall be included with angle brackets. Project\n headers shall be included with angle brackets for the libcamera public API\n-headers, and with double quotes for other libcamera headers.\n+headers, and with double quotes for internal libcamera headers.\n \n \n C++ Specific Rules\n","prefixes":["libcamera-devel","v3"]}