From 6aaca42c18798471313f2e5d9c2c9327fba6133b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 14 Mar 2023 11:01:04 -0700 Subject: util/check_clang_format: Format C++ files BRANCH=none BUG=none TEST=./util/check_clang_format.py Change-Id: Ie270a1683ff62b7cb7d95e972b2fe51119be9885 Signed-off-by: Tom Hughes Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4338477 Reviewed-by: Jeremy Bettis Reviewed-by: Jack Rosenthal --- util/check_clang_format.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/util/check_clang_format.py b/util/check_clang_format.py index 5862c02a3d..529a37302d 100755 --- a/util/check_clang_format.py +++ b/util/check_clang_format.py @@ -3,7 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Validate all C source is formatted with clang-format. +"""Validate all C/C++ source is formatted with clang-format. This isn't very useful to users to call directly, but it is run it the CQ. Most users will likely find out they forgot to clang-format by @@ -21,7 +21,7 @@ from chromite.lib import commandline def main(argv=None): - """Find all C files and runs clang-format on them.""" + """Find all C/C++ files and runs clang-format on them.""" parser = commandline.ArgumentParser() parser.add_argument( "--fix", @@ -59,7 +59,11 @@ def main(argv=None): continue if "third_party" in path.parts: continue - if path.name.endswith(".c") or path.name.endswith(".h"): + if ( + path.name.endswith(".c") + or path.name.endswith(".cc") + or path.name.endswith(".h") + ): cmd.append(path) logging.debug("Running %s", " ".join(shlex.quote(str(x)) for x in cmd)) @@ -72,7 +76,7 @@ def main(argv=None): stdin=subprocess.DEVNULL, ) if result.stderr: - logging.error("All C source must be formatted with clang-format!") + logging.error("All C/C++ source must be formatted with clang-format!") for line in result.stderr.splitlines(): logging.error("%s", line) return 1 -- cgit v1.2.1