Commit 1d979adde53c3a473c274c39af7f1925ba07e45d

Authored by Jay Berkenbilt
1 parent 21612165

Bump minimum clang-format version to 16

Also enforce in format-code.
.clang-format
1 1 # -*- yaml -*-
2   -# This configuration works with clang-format-15.
  2 +# This configuration requires at least clang-format 15.
  3 +# See ./format-code for comments about the minimum version.
3 4 # See https://clang.llvm.org/docs/ClangFormatStyleOptions.html
4 5 ---
5 6 Language: Cpp
... ...
format-code
... ... @@ -19,6 +19,19 @@
19 19  
20 20 # Please see "Code Formatting" in the manual for additional notes.
21 21  
  22 +# If a newer version of clang-format causes changes to the output that
  23 +# are improvements, bump the minimum required version of clang-format
  24 +# here, and update manual/contributing.rst. There's a comment there
  25 +# that refers to this comment. See also .clang-format.
  26 +min_version=16
  27 +
  28 +clang_version=$(clang-format --version | \
  29 + awk '{for (i=1; i<=NF; i++) if ($i == "version") {print int($(i+1)); exit}}')
  30 +if [ "$clang_version" -lt "$min_version" ]; then
  31 + echo "clang-format version >= $min_version is required"
  32 + exit 2
  33 +fi
  34 +
22 35 cd $(dirname $0)
23 36 for i in $(find . -name 'build*' -prune -o '(' \
24 37 -name '*.hh' -o -name '*.h' -o -name '*.cc' -o -name '*.c' \
... ...
manual/contributing.rst
... ... @@ -20,11 +20,14 @@ https://github.com/qpdf/qpdf/discussions.
20 20 Code Formatting
21 21 ---------------
22 22  
23   -The qpdf source code is formatting using clang-format ≥ version 15
24   -with a :file:`.clang-format` file at the top of the source tree. The
  23 +.. The minimum clang-format version is also in format-code. There is a
  24 + comment there that references this file.
  25 +
  26 +The qpdf source code is formatted using clang-format with a
  27 +:file:`.clang-format` file at the top of the source tree. The
25 28 :file:`format-code` script reformats all the source code in the
26   -repository. You must have ``clang-format`` in your path, and it must be
27   -at least version 15.
  29 +repository. You must have ``clang-format`` in your path, and it must
  30 +be at least version 16.
28 31  
29 32 For emacs users, the :file:`.dir-locals.el` file configures emacs
30 33 ``cc-mode`` for an indentation style that is similar to but not
... ...