From patchwork Thu May 26 11:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16061 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4A32BC326D for ; Thu, 26 May 2022 11:00:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 239B365665; Thu, 26 May 2022 13:00:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653562823; bh=MQH0YRTF3qDClE7iU422wz2lP3V+H8lW4am8/WGpPns=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Ye7HS8Z+qQVmvtaAv8YofLolzAUGGWevAGfuiuL1jdI3V/hiGIDspCLqQZY7moCO5 FNbXWLLZCrciB5JKOmza/zwW3SfA7F8PngisKtmYH2CxXvExRD8wmUh0GrWPZ/VUsF 2YUODfWqo28KV6274jU055fCmlx3JRzSEab3y1WkO/5387ifkBxxabcmgvoPVPNUvh cfufnLCe6gQZs7xPUaPV/Cw4Jr3hqz3i6LN3D2QpVv5h80e5vntqgpA5L58pckTTDI 89KxbjIBtvDc9TJx7T9ANb/3xO7epvd9znHPToHOqev/CzJX5WpkZU9oRl42QPNnzo imBKhXbChzS9A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F12F160418 for ; Thu, 26 May 2022 13:00:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JUSi0hrL"; dkim-atps=neutral Received: from pendragon.lan (unknown [37.120.212.14]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8751F6D4 for ; Thu, 26 May 2022 13:00:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653562819; bh=MQH0YRTF3qDClE7iU422wz2lP3V+H8lW4am8/WGpPns=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JUSi0hrLpDgrz0jenNWjdysHCxemSpx334ysLP7ib8QPL4Y8EBgNkQiUWyu6lIj7V uSxVTSX22CUxBp/BsS+a9wWLknkDvEqhv/glnGrU4/sAgvPMndQrDzG6YjdKiNFfkG JZc2QK0/eowzZFeCyVv1K3tjM9FRc3jU4Cp45m1c= To: libcamera-devel@lists.libcamera.org Date: Thu, 26 May 2022 14:00:08 +0300 Message-Id: <20220526110009.13874-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220526110009.13874-1-laurent.pinchart@ideasonboard.com> References: <20220526110009.13874-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] utils: checkstyle: Ensure "..." include style for internal headers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera uses the "..." include style for internal headers. Enforce it. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Paul Elder --- utils/checkstyle.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 66af96abd402..61783165bef2 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -643,7 +643,7 @@ class DPointerFormatter(Formatter): class IncludeOrderFormatter(Formatter): patterns = ('*.cpp', '*.h') - include_regex = re.compile('^#include ["<]([^">]*)[">]') + include_regex = re.compile('^#include (["<])([^">]*)([">])') @classmethod def format(cls, filename, data): @@ -657,7 +657,21 @@ class IncludeOrderFormatter(Formatter): if match: # If the current line is an #include statement, add it to the # includes group and continue to the next line. - includes.append((line, match.group(1))) + open_token = match.group(1) + file_name = match.group(2) + close_token = match.group(3) + + # Ensure the "..." include style for internal headers and the + # <...> style for all other libcamera headers. + if (file_name.startswith('libcamera/internal')): + open_token = '"' + close_token = '"' + elif (file_name.startswith('libcamera/')): + open_token = '<' + close_token = '>' + + line = f'#include {open_token}{file_name}{close_token}' + includes.append((line, file_name)) continue # The current line is not an #include statement, output the sorted