From nobody Sat Feb 7 18:16:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+88360+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88360+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1648850352; cv=none; d=zohomail.com; s=zohoarc; b=mltI7tcfY/ab9tzlFhljltR3AzlBYUzWiwWr3a8IFV4+GcBFWgZ0DDpbHvEdudKcmENoR3V48Dj/vHzwV+djGtJu5hNmOUGCFMgfiDdCoiWRQFLwDTZKz1m9WJKCkeX0jx4HeeD536tVv3nMkgJUsRT8e7jDT7VRT6tk5ncR73A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648850352; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=CmZc/ifS43XbAkuotc6iWRTVnrP4uZMtfTWWBiIDMJg=; b=V+m2XdpmaKAfGEmC66OXk4wNP/LdZEeRZpt8sdOk+T97ugLl8bNzHQEcsa5Ppo5IKWaSRbyt73RAYgUKKApj0CXeCBOQ4Im5Plr+LpraYYY5sko/v4Hco1wgZImxAML4yxcc0vUWHdsv/aUxjOW3RtTMGAgVKHeVB3iLrWdy06I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88360+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1648850352580101.39516898395925; Fri, 1 Apr 2022 14:59:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id MaykYY1788612xyCqI3wEdNH; Fri, 01 Apr 2022 14:59:12 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web08.5049.1648850351552106771 for ; Fri, 01 Apr 2022 14:59:11 -0700 X-Received: from localhost.localdomain (unknown [47.202.59.224]) by linux.microsoft.com (Postfix) with ESMTPSA id 3046820DEEC8; Fri, 1 Apr 2022 14:59:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3046820DEEC8 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Sean Brogan , Bret Barkelew , Jiewen Yao Subject: [edk2-devel] [PATCH v3 2/4] .pytool/Plugin/UncrustifyCheck: Add ignore file support Date: Fri, 1 Apr 2022 17:58:30 -0400 Message-Id: <20220401215832.2523-3-mikuback@linux.microsoft.com> In-Reply-To: <20220401215832.2523-1-mikuback@linux.microsoft.com> References: <20220401215832.2523-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: k9zZ23sjhj5Ym1V6LmQ4fFI9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648850352; bh=jOBB08Rg9CiMLx/wtMPyE6NTNsVZVId/IpNpb6tvWmw=; h=Cc:Date:From:Reply-To:Subject:To; b=PfoZU14qIhAWDxePVZuYcKXP6AKWkSWp88q9wftoLqalNCH6EO/7EqVShLDxGU+2qPV Zg4+c8T61spUugn50WzQuW9E1wWUknigwLJSKIpPjL0Sz0fHn1GH/CNRxyMHYnSXeRZN9 wMJaLEDByTf3s8u7IDpB534ohc969d96UL0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648850353303100001 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3880 Currently UncrustifyCheck.py provides the following exclusion options: 1. Override the type of files UncrustifyCheck operates against by default (.c and .h files). Using the "IgnoreStandardPaths" configuration option. 2. By default, UncrustifyCheck skips files in git submodules and ignored by git (the "SkipGitExclusions" configuration option can override this behavior). The goal of UncrustifyCheck is to provide consistent formatting across the codebase. In some rare circumstances, maintainers might need to exclude a specific file (or file pattern) within their package. For example, a small set of auto-generated files from another repository. This change adds a new configuration option that can be specified in a package CI YAML file to describe a list of files within the package that should be ignored by UncrustifyCheck. The configuration option is called "IgnoreFiles" and it uses similar syntax to git ignore to ignore a list of files. Cc: Michael D Kinney Cc: Liming Gao Cc: Sean Brogan Cc: Bret Barkelew Signed-off-by: Michael Kubacki Reviewed-by: Jiewen Yao Reviewed-by: Sean Brogan --- .pytool/Plugin/UncrustifyCheck/Readme.md | 7 +++++ .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 33 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/.pytool/Plugin/UncrustifyCheck/Readme.md b/.pytool/Plugin/Uncr= ustifyCheck/Readme.md index 0c46fd241a7a..efe7a573e4fa 100644 --- a/.pytool/Plugin/UncrustifyCheck/Readme.md +++ b/.pytool/Plugin/UncrustifyCheck/Readme.md @@ -41,6 +41,7 @@ The plugin can be configured with a few optional configur= ation options. "AdditionalIncludePaths": [], # Additional paths to check formatting= (wildcards supported). "AuditOnly": False, # Don't fail the build if there are er= rors. Just log them. "ConfigFilePath": "", # Custom path to an Uncrustify config = file. + "IgnoreFiles": [], # A list of file patterns to ignore. "IgnoreStandardPaths": [], # Standard Plugin defined paths that s= hould be ignored. "OutputFileDiffs": True, # Output chunks of formatting diffs in= the test case log. # This can significantly slow down the= plugin on very large packages. @@ -67,6 +68,12 @@ the test as skipped. This allows visibility into the fai= lures without breaking t =20 When specified in the config file, this is a package relative path to the = Uncrustify configuration file. =20 +### `IgnoreFiles` + +This option supports .gitignore file and folder matching strings including= wildcards. + +The files specified by this configuration option will not be processed by = Uncrustify. + ### `IgnoreStandardPaths` =20 This plugin by default will check the below standard paths. A package conf= iguration file can specify any of these paths diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Pl= ugin/UncrustifyCheck/UncrustifyCheck.py index 6920580646de..f0455afeec24 100644 --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py @@ -13,11 +13,13 @@ import os import pathlib import shutil import timeit +from collections.abc import Callable from edk2toolext.environment import version_aggregator from edk2toolext.environment.plugin_manager import PluginManager from edk2toolext.environment.plugintypes.ci_build_plugin import ICiBuildPl= ugin from edk2toolext.environment.plugintypes.uefi_helper_plugin import HelperF= unctions from edk2toolext.environment.var_dict import VarDict +from edk2toollib.gitignore_parser import parse_gitignore_lines from edk2toollib.log.junit_report_format import JunitReportTestCase from edk2toollib.uefi.edk2.path_utilities import Edk2Path from edk2toollib.utility_functions import RunCmd @@ -273,6 +275,24 @@ class UncrustifyCheck(ICiBuildPlugin): f"-c {self._app_config_file} -F {self._app_input_file_path} --= if-changed --suffix {UncrustifyCheck.FORMATTED_FILE_EXTENSION}", outstream= =3Doutput) self._app_output =3D output.getvalue().strip().splitlines() =20 + def _get_files_ignored_in_config(self) -> Callable[[str], bool]: + """" + Returns a function that returns true if a given file string path i= s ignored in the plugin configuration file and false otherwise. + """ + ignored_files =3D [] + if "IgnoreFiles" in self._package_config: + ignored_files =3D self._package_config["IgnoreFiles"] + + # Pass "Package configuration file" as the source file path since + # the actual configuration file name is unknown to this plugin and + # this provides a generic description of the file that provided + # the ignore file content. + # + # This information is only used for reporting (not used here) and + # the ignore lines are being passed directly as they are given to + # this plugin. + return parse_gitignore_lines(ignored_files, "Package configuration= file", self._abs_workspace_path) + def _get_git_ignored_paths(self) -> List[str]: """" Returns a list of file absolute path strings to all files ignored = in this git repository. @@ -465,6 +485,19 @@ class UncrustifyCheck(ICiBuildPlugin): self._abs_file_paths_to_format.extend( [str(path.resolve()) for path in pathlib.Path(self._abs_pa= ckage_path).rglob(path)]) =20 + # Remove files ignore in the plugin configuration file + plugin_ignored_files =3D list(filter(self._get_files_ignored_in_co= nfig(), self._abs_file_paths_to_format)) + + if plugin_ignored_files: + logging.info( + f"{self._package_name} file count before plugin ignore fil= e exclusion: {len(self._abs_file_paths_to_format)}") + for path in plugin_ignored_files: + if path in self._abs_file_paths_to_format: + logging.info(f" File ignored in plugin config file: {= path}") + self._abs_file_paths_to_format.remove(path) + logging.info( + f"{self._package_name} file count after plugin ignore file= exclusion: {len(self._abs_file_paths_to_format)}") + if not "SkipGitExclusions" in self._package_config or not self._pa= ckage_config["SkipGitExclusions"]: # Remove files ignored by git logging.info( --=20 2.28.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#88360): https://edk2.groups.io/g/devel/message/88360 Mute This Topic: https://groups.io/mt/90190227/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-