Skip to content

Commit

Permalink
fix: restore clang-format-14
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gromadzki <[email protected]>
  • Loading branch information
grom72 committed Jan 29, 2025
1 parent cbffd24 commit 953d84f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Before contributing please remember to run:
```

This will check all C/C++ files in the tree for style issues. To check C++
files you have to have clang-format version 9.0, otherwise they will be
files you have to have clang-format version 14.0, otherwise they will be
skipped. If you want to run this target automatically at build time, you can
pass CSTYLEON=1 to make. If you want cstyle to be run, but not fail the build,
pass CSTYLEON=2 to make.
Expand Down
24 changes: 6 additions & 18 deletions utils/style_check.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2023, Intel Corporation
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# utils/style_check.sh -- common style checking script
#
Expand All @@ -16,8 +15,8 @@ CHECK_TYPE=$1
# When updating, please search for all references to "clang-format" and update
# them as well; at this time these are CONTRIBUTING.md src/common.inc and
# docker images.
[ -z "$clang_format_bin" ] && which clang-format-9 >/dev/null &&
clang_format_bin=clang-format-9
[ -z "$clang_format_bin" ] && which clang-format-14 >/dev/null &&
clang_format_bin=clang-format-14
[ -z "$clang_format_bin" ] && which clang-format >/dev/null &&
clang_format_bin=clang-format
[ -z "$clang_format_bin" ] && clang_format_bin=clang-format
Expand All @@ -34,22 +33,11 @@ function usage() {
#
function check_clang_version() {
set +e
which ${clang_format_bin} &> /dev/null
which ${clang_format_bin} &> /dev/null && ${clang_format_bin} --version |\
grep "version 14\.0"\
&> /dev/null
if [ $? -ne 0 ]; then
MSG="requires clang-format version >= 14.0"
if [ "x$CSTYLE_FAIL_IF_CLANG_FORMAT_MISSING" == "x1" ]; then
echo "FAIL: $MSG"
exit 1
else
echo "SKIP: $MSG"
exit 0
fi
fi

clang_version=`clang-format --version | awk '{print $3}'`

if [ $(echo "$clang_version 14.0" | tr " " "\n" | sort --version-sort | head -n 1) = $clang_version ]; then
MSG="requires clang-format version >= 14.0 (version $clang_version installed)"
MSG="requires clang-format version==14.0"
if [ "x$CSTYLE_FAIL_IF_CLANG_FORMAT_MISSING" == "x1" ]; then
echo "FAIL: $MSG"
exit 1
Expand Down

0 comments on commit 953d84f

Please sign in to comment.