Patch Detail
Show a patch.
GET /api/1.1/patches/13557/?format=api
{ "id": 13557, "url": "https://patchwork.libcamera.org/api/1.1/patches/13557/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13557/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210827144753.419929-1-kieran.bingham@ideasonboard.com>", "date": "2021-08-27T14:47:53", "name": "[libcamera-devel] clang-format: Support multiple versions", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "27f76fde45962e5f98e4afdaa3b6ce41817d884d", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": { "id": 11, "url": "https://patchwork.libcamera.org/api/1.1/users/11/?format=api", "username": "kbingham", "first_name": "Kieran", "last_name": "Bingham", "email": "kieran.bingham@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/13557/mbox/", "series": [ { "id": 2411, "url": "https://patchwork.libcamera.org/api/1.1/series/2411/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2411", "date": "2021-08-27T14:47:53", "name": "[libcamera-devel] clang-format: Support multiple versions", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2411/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13557/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13557/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 A6C17BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Aug 2021 14:47:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 11F6B68895;\n\tFri, 27 Aug 2021 16:47:59 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 07C8160256\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Aug 2021 16:47:57 +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 8446C5A1;\n\tFri, 27 Aug 2021 16:47:56 +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=\"WpJVNEgu\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630075676;\n\tbh=8DgES/Uoi1tNrVO2nIRDbJ60Dj3CmjIYjyA+3zM3hbQ=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=WpJVNEguDL/su+BWRSOjuBiOEN6/sX5w7fvQE/lutEGThgaW0gzGxd/EN86Ra6qMc\n\tRvH43KEu1+1Ra1c+jRwwx6nqklHY0NP9Lkdw8k4W9e/fmW+lwDwJSTiDLDPu+t991O\n\tFwJCVrtBeK0QXQQ7HwR9KVn+bmIWijtVclBBv5ps=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Date": "Fri, 27 Aug 2021 15:47:53 +0100", "Message-Id": "<20210827144753.419929-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] clang-format: Support multiple versions", "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": "The .clang-format file can use CaseSensitive on Regex rules for Include\nCategories. With this we can distinguish between QT headers which\ncommence with a 'Q' verses system headers including <queue>.\n\nThis requires clang-format-12 to support that rule, and clang-format is\nnot very amicable to .clang-format files with unsupported entries, and\nwill fail to run on previous versions if we add that option directly.\n\nThis causes the checkstyle utility to become unusable for users of\nclang-format versions prior to 12.\n\nUnfortunately, clang-format does not provide a way to specify a specific\nfile to use for the rules to apply when formatting, so we can not easily\ncall clang-format with a file specific to its versioned needs.\n\nImplement a means of identifying the version of clang-format, and use\nthat information to search for the most recent supportable\n.clang-format-$(version) file, which can then be symlinked to the fixed\nfile location used by clang format (.clang-format).\n\n .clang-format-12: is added with CaseSensitive:true for QT headers\n .clang-format-7: is moved from the current .clang-format implementation\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nNote there are few things I dislike about this, hence RFC:\n\n - We leave our tree without a .clang-format until checkstyle runs..\n - We run the unlinking and symlinking on every invocation of checkstyle\n - The 'autogenerated' file in place of a git tracked one causes\n issues on rebase. Could be an issue for bisects...?\n\n .clang-format-12 | 169 +++++++++++++++++++++++++++++++\n .clang-format => .clang-format-7 | 0\n utils/checkstyle.py | 49 ++++++++-\n 3 files changed, 217 insertions(+), 1 deletion(-)\n create mode 100644 .clang-format-12\n rename .clang-format => .clang-format-7 (100%)", "diff": "diff --git a/.clang-format-12 b/.clang-format-12\nnew file mode 100644\nindex 000000000000..98e9fad472fc\n--- /dev/null\n+++ b/.clang-format-12\n@@ -0,0 +1,169 @@\n+# SPDX-License-Identifier: GPL-2.0-only\n+#\n+# clang-format configuration file. Intended for clang-format >= 12.\n+#\n+# For more information, see:\n+#\n+# Documentation/process/clang-format.rst\n+# https://clang.llvm.org/docs/ClangFormat.html\n+# https://clang.llvm.org/docs/ClangFormatStyleOptions.html\n+#\n+---\n+Language: Cpp\n+AccessModifierOffset: -8\n+AlignAfterOpenBracket: Align\n+AlignConsecutiveAssignments: false\n+AlignConsecutiveDeclarations: false\n+AlignEscapedNewlines: Right\n+AlignOperands: true\n+AlignTrailingComments: false\n+AllowAllParametersOfDeclarationOnNextLine: false\n+AllowShortBlocksOnASingleLine: false\n+AllowShortCaseLabelsOnASingleLine: false\n+AllowShortFunctionsOnASingleLine: InlineOnly\n+AllowShortIfStatementsOnASingleLine: false\n+AllowShortLoopsOnASingleLine: false\n+AlwaysBreakAfterDefinitionReturnType: None\n+AlwaysBreakAfterReturnType: None\n+AlwaysBreakBeforeMultilineStrings: false\n+AlwaysBreakTemplateDeclarations: MultiLine\n+BinPackArguments: true\n+BinPackParameters: true\n+BraceWrapping:\n+ AfterClass: true\n+ AfterControlStatement: false\n+ AfterEnum: false\n+ AfterFunction: true\n+ AfterNamespace: false\n+ AfterObjCDeclaration: false\n+ AfterStruct: false\n+ AfterUnion: false\n+ AfterExternBlock: false\n+ BeforeCatch: false\n+ BeforeElse: false\n+ IndentBraces: false\n+ SplitEmptyFunction: true\n+ SplitEmptyRecord: true\n+ SplitEmptyNamespace: true\n+BreakBeforeBinaryOperators: None\n+BreakBeforeBraces: Custom\n+BreakBeforeInheritanceComma: false\n+BreakInheritanceList: BeforeColon\n+BreakBeforeTernaryOperators: true\n+BreakConstructorInitializers: BeforeColon\n+BreakAfterJavaFieldAnnotations: false\n+BreakStringLiterals: false\n+ColumnLimit: 0\n+CommentPragmas: '^ IWYU pragma:'\n+CompactNamespaces: false\n+ConstructorInitializerAllOnOneLineOrOnePerLine: false\n+ConstructorInitializerIndentWidth: 8\n+ContinuationIndentWidth: 8\n+Cpp11BracedListStyle: false\n+DerivePointerAlignment: false\n+DisableFormat: false\n+ExperimentalAutoDetectBinPacking: false\n+FixNamespaceComments: true\n+ForEachMacros:\n+ - 'udev_list_entry_foreach'\n+SortIncludes: true\n+IncludeBlocks: Regroup\n+IncludeCategories:\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\n+IndentWidth: 8\n+IndentWrappedFunctionNames: false\n+JavaScriptQuotes: Leave\n+JavaScriptWrapImports: true\n+KeepEmptyLinesAtTheStartOfBlocks: false\n+MacroBlockBegin: ''\n+MacroBlockEnd: ''\n+MaxEmptyLinesToKeep: 1\n+NamespaceIndentation: None\n+ObjCBinPackProtocolList: Auto\n+ObjCBlockIndentWidth: 8\n+ObjCSpaceAfterProperty: true\n+ObjCSpaceBeforeProtocolList: true\n+\n+# Taken from git's rules\n+PenaltyBreakAssignment: 10\n+PenaltyBreakBeforeFirstCallParameter: 30\n+PenaltyBreakComment: 10\n+PenaltyBreakFirstLessLess: 0\n+PenaltyBreakString: 10\n+PenaltyBreakTemplateDeclaration: 10\n+PenaltyExcessCharacter: 100\n+PenaltyReturnTypeOnItsOwnLine: 60\n+\n+PointerAlignment: Right\n+ReflowComments: false\n+SortIncludes: true\n+SortUsingDeclarations: true\n+SpaceAfterCStyleCast: false\n+SpaceAfterTemplateKeyword: false\n+SpaceBeforeAssignmentOperators: true\n+SpaceBeforeCpp11BracedList: false\n+SpaceBeforeCtorInitializerColon: true\n+SpaceBeforeInheritanceColon: true\n+SpaceBeforeParens: ControlStatements\n+SpaceBeforeRangeBasedForLoopColon: true\n+SpaceInEmptyParentheses: false\n+SpacesBeforeTrailingComments: 1\n+SpacesInAngles: false\n+SpacesInContainerLiterals: false\n+SpacesInCStyleCastParentheses: false\n+SpacesInParentheses: false\n+SpacesInSquareBrackets: false\n+Standard: Cpp11\n+TabWidth: 8\n+UseTab: Always\n+...\ndiff --git a/.clang-format b/.clang-format-7\nsimilarity index 100%\nrename from .clang-format\nrename to .clang-format-7\ndiff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex ececb46eaacc..279ace8346b4 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -16,6 +16,7 @@\n import argparse\n import difflib\n import fnmatch\n+import glob\n import os.path\n import re\n import shutil\n@@ -566,9 +567,55 @@ class Formatter(metaclass=ClassRegistry):\n return patterns\n \n \n-class CLangFormatter(Formatter):\n+# Identify the version of clang-format running, and match it against locally\n+# available versioned configuration files of the form:\n+# .clang-format-$(version)\n+#\n+# The highest supported local configuration file is linked as .clang-format by\n+# ClangFormatLinker.relink() for use by the ClangFormatter.\n+#\n+class ClangFormatLinker():\n+ def version():\n+ version_regex = re.compile('[^0-9]*([0-9]+).*')\n+ ret = subprocess.run(['clang-format', '--version'], stdout=subprocess.PIPE)\n+ version = ret.stdout.decode('utf-8')\n+ search = version_regex.search(version)\n+ if search:\n+ version = search.group(1)\n+ return int(version)\n+\n+ # Lowest supported version\n+ return 7\n+\n+ def supported():\n+ version = ClangFormatLinker.version()\n+\n+ # Match the highest supported version\n+ clang_files = glob.glob('.clang-format-[0-9]*')\n+ clang_files = sorted(clang_files, reverse=True,\n+ key=lambda s: [int(re.sub(\"[^0-9]\", \"\", s))])\n+ for f in clang_files:\n+ file_version = int(re.sub(\"[^0-9]\", \"\", f))\n+ if file_version <= version:\n+ return f\n+\n+ return None\n+\n+ def relink():\n+ supported = ClangFormatLinker.supported()\n+ if not supported:\n+ return\n+\n+ if os.path.exists('.clang-format'):\n+ os.unlink('.clang-format')\n+ os.symlink(supported, '.clang-format')\n+\n+\n+class ClangFormatter(Formatter):\n patterns = ('*.c', '*.cpp', '*.h')\n \n+ ClangFormatLinker.relink()\n+\n @classmethod\n def format(cls, filename, data):\n ret = subprocess.run(['clang-format', '-style=file',\n", "prefixes": [ "libcamera-devel" ] }