Commit 1d979adde53c3a473c274c39af7f1925ba07e45d
1 parent
21612165
Bump minimum clang-format version to 16
Also enforce in format-code.
Showing
3 changed files
with
22 additions
and
5 deletions
.clang-format
| 1 | # -*- yaml -*- | 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 | # See https://clang.llvm.org/docs/ClangFormatStyleOptions.html | 4 | # See https://clang.llvm.org/docs/ClangFormatStyleOptions.html |
| 4 | --- | 5 | --- |
| 5 | Language: Cpp | 6 | Language: Cpp |
format-code
| @@ -19,6 +19,19 @@ | @@ -19,6 +19,19 @@ | ||
| 19 | 19 | ||
| 20 | # Please see "Code Formatting" in the manual for additional notes. | 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 | cd $(dirname $0) | 35 | cd $(dirname $0) |
| 23 | for i in $(find . -name 'build*' -prune -o '(' \ | 36 | for i in $(find . -name 'build*' -prune -o '(' \ |
| 24 | -name '*.hh' -o -name '*.h' -o -name '*.cc' -o -name '*.c' \ | 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,11 +20,14 @@ https://github.com/qpdf/qpdf/discussions. | ||
| 20 | Code Formatting | 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 | :file:`format-code` script reformats all the source code in the | 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 | For emacs users, the :file:`.dir-locals.el` file configures emacs | 32 | For emacs users, the :file:`.dir-locals.el` file configures emacs |
| 30 | ``cc-mode`` for an indentation style that is similar to but not | 33 | ``cc-mode`` for an indentation style that is similar to but not |