Change fixed clang-format version to 15

* We commit statically linked x64 binaries for clang-format-15 for windows and
  linux to make the transition easier for anyone running a linux distro that
  doesn't yet support llvm 15, or in future for distros that drop support for
  it.
This commit is contained in:
baldurk
2021-03-04 12:22:37 +00:00
parent 5e7b25efca
commit 4d94209ec1
9 changed files with 70 additions and 23 deletions
+24 -3
View File
@@ -1,5 +1,4 @@
---
Language: Cpp
# BasedOnStyle: Chromium
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
@@ -11,7 +10,8 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
@@ -21,6 +21,7 @@ AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
@@ -44,7 +45,9 @@ ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: Leave
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '<.*\.h>'
@@ -55,6 +58,7 @@ IncludeCategories:
Priority: 3
- Regex: '.*'
Priority: 4
IncludeIsMainRegex: ''
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
@@ -63,7 +67,9 @@ MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
@@ -75,18 +81,33 @@ PenaltyReturnTypeOnItsOwnLine: 2000
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
- BEGIN_ENUM_STRINGISE
- BEGIN_ENUM_CLASS_STRINGISE
- STRINGISE_ENUM
- STRINGISE_ENUM_CLASS
- STRINGISE_ENUM_NAMED
- STRINGISE_ENUM_CLASS_NAMED
- STRINGISE_BITFIELD_BIT
TabWidth: 2
UseTab: Never
---
Language: Cpp
---
Language: ObjC
...
+1 -11
View File
@@ -42,17 +42,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 5
- name: Add LLVM apt repository
run: |
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -y 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.8 main'
sudo apt-get update
curl -LO http://archive.ubuntu.com/ubuntu/pool/main/libf/libffi/libffi6_3.2.1-8_amd64.deb
sudo dpkg -i libffi6_3.2.1-8_amd64.deb
- name: Install clang-format-3.8
run: |
sudo apt-get install -y clang-format-3.8
- name: Run clang-format-3.8
- name: Run clang-format
run: |
. ./util/clang_format_all.sh
git clean -f
+1 -1
View File
@@ -41,7 +41,7 @@ Commit messages should have a first line with a **maximum of 72 characters**, th
For more information, check the section about [commit messages](CONTRIBUTING/Preparing-Commits.md#commit-messages).
Code should be formatted using **clang-format 3.8**. The reason we fix a specific version of clang-format is that unfortunately different versions can format code in different ways using the same config file, so this would cause problems with automatic verification of code formatting.
Code should be formatted using **clang-format 15.0**. The reason we fix a specific version of clang-format is that unfortunately different versions can format code in different ways using the same config file, so this would cause problems with automatic verification of code formatting.
For more information, check the section about [code formatting](CONTRIBUTING/Preparing-Commits.md#code-formatting).
+7 -5
View File
@@ -20,11 +20,13 @@ Likewise commits for code formatting or compile fixes should be squashed into th
To make things easier for everyone, I've adopted clang-format for keeping code consistently formatted.
| :warning: | | :warning: |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| :warning: | **Unfortunately clang-format output changes between versions even with the same config.** | :warning: |
| :warning: | **I have fixed the version used for RenderDoc at [clang-format-3.8](http://releases.llvm.org/download.html#3.8.1).** | :warning: |
| :warning: | **This formatting is enforced by CI checks that run on PRs, so if you aren't running the same version locally it will show up there.** | :warning: |
| :warning: | | :warning: |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| :warning: | **Unfortunately clang-format output changes between versions even with the same config.** | :warning: |
| :warning: | **I have fixed the version used for RenderDoc at [clang-format-15.0](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.7).** | :warning: |
| :warning: | **This formatting is enforced by CI checks that run on PRs, so if you aren't running the same version locally it will show up there.** | :warning: |
This version changed as of 2023-09-02, from clang-format-3.8 to clang-format-15.0. A statically linked binary of clang-format-15.0.7 for x64 windows and linux is committed to the repo under util/clangformat.
If you want to format a single file, run: `clang-format -i file.cpp`. If you want to format any changes you make before you commit them, you'll need python installed and then run: `git clang-format`. To clang-format the whole codebase, you can run the bash script `util/clang_format_all.sh` but be sure to squash any changes into the right commits.
+15 -3
View File
@@ -1,7 +1,7 @@
#!/bin/sh
CLANG_MAJOR=3
CLANG_MINOR=8
CLANG_MAJOR=15
CLANG_MINOR=0
CLANG_FORMAT_VERSION=$CLANG_MAJOR.$CLANG_MINOR
@@ -47,12 +47,24 @@ fi;
# Check if we have a valid $CLANG_FORMAT
if ! valid_clang_format; then
# If we didn't find one, bail out
SCRIPTDIR=$(dirname $(readlink -f $0));
# If we didn't find one, fall back to repo-included binary. Check it can run
if "${SCRIPTDIR}"/clangformat/clang-format-15.0.exe --version 2>&1 | grep -q 15.0.7;
then
CLANG_FORMAT="${SCRIPTDIR}"/clangformat/clang-format-15.0.exe
elif "${SCRIPTDIR}"/clangformat/clang-format-15.0 --version 2>&1 | grep -q 15.0.7;
then
CLANG_FORMAT="${SCRIPTDIR}"/clangformat/clang-format-15.0
fi
fi
if ! valid_clang_format; then
echo "Couldn't find correct clang-format version, was looking for $CLANG_FORMAT_VERSION"
echo "Renderdoc requires a very specific clang-format version to ensure there isn't any"
echo "variance between versions that can happen. You can install it as"
echo "'clang-format-$CLANG_FORMAT_VERSION' so that it doesn't interfere with any other"
echo "versions you might have installed, and this script will find it there"
echo "The repository includes a windows and linux x64 binary version, but it failed to run."
exit 1;
fi;
+8
View File
@@ -0,0 +1,8 @@
# Building static clang-format
The docker script will build and static link clang-format to make a portable static linked binary.
```
docker run --rm -v $(pwd):/script:ro -v $(pwd):/out ubuntu:jammy bash /script/build.sh
```
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
set -e
set -x
apt-get update
apt-get install -y git cmake python3 gcc g++
git clone --depth=5 https://github.com/llvm/llvm-project --branch llvmorg-15.0.7
mkdir llvm-build
cd llvm-build
cmake /llvm-project/llvm -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_BUILD_TYPE=Release
make -j8 clang-format
strip --strip-unneeded bin/clang-format
cp bin/clang-format /out
BIN
View File
Binary file not shown.
Binary file not shown.