Skip to content

Commit f1ad6b6

Browse files
authored
CXX-3198 upgrade to ClangFormat 19 and replace clang_format.py with clang-format-all.sh (#1299)
* uv: add clang-format 19.1 * uv: sync lockfile * Use a dedicated cache directory for the C++ Driver * evg: add install_uv.py * evg: replace etc/clang_format.py with etc/clang-format-all.sh * format: dump ClangFormat 19 config (Google style) * format: restore old config options * format: remove Google-specific options * Format all files * format: teach ClangFormat about our macros * format: set ReferenceAlignment: Left * Remove manual line break comments * format: increase penalty for breaking namespace qualifiers * Clone uv-installer.sh script for uv 0.5.9 * Add checksums for uv 0.5.9
1 parent 99dc81f commit f1ad6b6

File tree

96 files changed

+2892
-1443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2892
-1443
lines changed

.clang-format

Lines changed: 267 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,146 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -1
4+
AlignAfterOpenBracket: Align
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionPointers: false
12+
PadOperators: true
13+
AlignConsecutiveBitFields:
14+
Enabled: false
15+
AcrossEmptyLines: false
16+
AcrossComments: false
17+
AlignCompound: false
18+
AlignFunctionPointers: false
19+
PadOperators: false
20+
AlignConsecutiveDeclarations:
21+
Enabled: false
22+
AcrossEmptyLines: false
23+
AcrossComments: false
24+
AlignCompound: false
25+
AlignFunctionPointers: false
26+
PadOperators: false
27+
AlignConsecutiveMacros:
28+
Enabled: false
29+
AcrossEmptyLines: false
30+
AcrossComments: false
31+
AlignCompound: false
32+
AlignFunctionPointers: false
33+
PadOperators: false
34+
AlignConsecutiveShortCaseStatements:
35+
Enabled: false
36+
AcrossEmptyLines: false
37+
AcrossComments: false
38+
AlignCaseArrows: false
39+
AlignCaseColons: false
40+
AlignConsecutiveTableGenBreakingDAGArgColons:
41+
Enabled: false
42+
AcrossEmptyLines: false
43+
AcrossComments: false
44+
AlignCompound: false
45+
AlignFunctionPointers: false
46+
PadOperators: false
47+
AlignConsecutiveTableGenCondOperatorColons:
48+
Enabled: false
49+
AcrossEmptyLines: false
50+
AcrossComments: false
51+
AlignCompound: false
52+
AlignFunctionPointers: false
53+
PadOperators: false
54+
AlignConsecutiveTableGenDefinitionColons:
55+
Enabled: false
56+
AcrossEmptyLines: false
57+
AcrossComments: false
58+
AlignCompound: false
59+
AlignFunctionPointers: false
60+
PadOperators: false
61+
AlignEscapedNewlines: Left
62+
AlignOperands: Align
63+
AlignTrailingComments:
64+
Kind: Always
65+
OverEmptyLines: 0
66+
AllowAllArgumentsOnNextLine: true
67+
AllowAllParametersOfDeclarationOnNextLine: true
68+
AllowBreakBeforeNoexceptSpecifier: Never
69+
AllowShortBlocksOnASingleLine: Never
70+
AllowShortCaseExpressionOnASingleLine: true
71+
AllowShortCaseLabelsOnASingleLine: false
72+
AllowShortCompoundRequirementOnASingleLine: true
73+
AllowShortEnumsOnASingleLine: true
174
AllowShortFunctionsOnASingleLine: Empty
2-
AllowShortIfStatementsOnASingleLine: false
75+
AllowShortIfStatementsOnASingleLine: Never
76+
AllowShortLambdasOnASingleLine: All
377
AllowShortLoopsOnASingleLine: false
4-
BasedOnStyle: Google
78+
AlwaysBreakAfterDefinitionReturnType: None
79+
AlwaysBreakBeforeMultilineStrings: true
80+
AttributeMacros:
81+
- BSONCXX_ABI_CDECL
82+
- BSONCXX_ABI_EXPORT
83+
- BSONCXX_ABI_NO_EXPORT
84+
- BSONCXX_DEPRECATED
85+
- BSONCXX_ENUM
86+
- BSONCXX_PRAGMA
87+
- BSONCXX_RETURNS
88+
- MONGOCXX_ABI_CDECL
89+
- MONGOCXX_ABI_EXPORT
90+
- MONGOCXX_ABI_NO_EXPORT
91+
- MONGOCXX_DEPRECATED
592
BinPackArguments: false
693
BinPackParameters: false
7-
ColumnLimit: 100
8-
CommentPragmas: '^\s*(@(addtogroup|copydoc|defgroup|fn|ref)|- )'
94+
BitFieldColonSpacing: Both
95+
BraceWrapping:
96+
AfterCaseLabel: false
97+
AfterClass: false
98+
AfterControlStatement: Never
99+
AfterEnum: false
100+
AfterExternBlock: false
101+
AfterFunction: false
102+
AfterNamespace: false
103+
AfterObjCDeclaration: false
104+
AfterStruct: false
105+
AfterUnion: false
106+
BeforeCatch: false
107+
BeforeElse: false
108+
BeforeLambdaBody: false
109+
BeforeWhile: false
110+
IndentBraces: false
111+
SplitEmptyFunction: true
112+
SplitEmptyRecord: true
113+
SplitEmptyNamespace: true
114+
BreakAdjacentStringLiterals: true
115+
BreakAfterAttributes: Leave
116+
BreakAfterJavaFieldAnnotations: false
117+
BreakAfterReturnType: None
118+
BreakArrays: true
119+
BreakBeforeBinaryOperators: None
120+
BreakBeforeConceptDeclarations: Always
121+
BreakBeforeBraces: Attach
122+
BreakBeforeInlineASMColon: OnlyMultiline
123+
BreakBeforeTernaryOperators: true
124+
BreakConstructorInitializers: BeforeColon
125+
BreakFunctionDefinitionParameters: false
126+
BreakInheritanceList: BeforeColon
127+
BreakStringLiterals: true
128+
BreakTemplateDeclarations: Yes
129+
ColumnLimit: 100
130+
CommentPragmas: '^\s*(@(addtogroup|copydoc|defgroup|fn|ref)|- )'
131+
CompactNamespaces: false
132+
ConstructorInitializerIndentWidth: 4
133+
ContinuationIndentWidth: 4
9134
Cpp11BracedListStyle: true
10135
DerivePointerAlignment: false
11-
IncludeBlocks: Regroup
136+
DisableFormat: false
137+
EmptyLineAfterAccessModifier: Never
138+
EmptyLineBeforeAccessModifier: LogicalBlock
139+
ExperimentalAutoDetectBinPacking: false
140+
FixNamespaceComments: true
141+
ForEachMacros: []
142+
IfMacros: []
143+
IncludeBlocks: Regroup
12144
IncludeCategories:
13145
- Regex: '".*"' # relative headers
14146
Priority: 10
@@ -32,9 +164,136 @@ IncludeCategories:
32164
Priority: 41
33165
- Regex: '.*' # all other headers (third party)
34166
Priority: 90
35-
IndentWidth: 4
167+
IncludeIsMainRegex: '([-_](test|unittest))?$'
168+
IncludeIsMainSourceRegex: ''
169+
IndentAccessModifiers: false
170+
IndentCaseBlocks: false
171+
IndentCaseLabels: true
172+
IndentExternBlock: AfterExternBlock
173+
IndentGotoLabels: true
174+
IndentPPDirectives: None
175+
IndentRequiresClause: true
176+
IndentWidth: 4
177+
IndentWrappedFunctionNames: false
178+
InsertBraces: false
179+
InsertNewlineAtEOF: false
180+
InsertTrailingCommas: None
181+
IntegerLiteralSeparator:
182+
Binary: 0
183+
BinaryMinDigits: 0
184+
Decimal: 0
185+
DecimalMinDigits: 0
186+
Hex: 0
187+
HexMinDigits: 0
188+
JavaScriptQuotes: Leave
189+
JavaScriptWrapImports: true
190+
KeepEmptyLines:
191+
AtEndOfFile: false
192+
AtStartOfBlock: false
193+
AtStartOfFile: true
194+
LambdaBodyIndentation: Signature
195+
LineEnding: DeriveLF
196+
MacroBlockBegin: ''
197+
MacroBlockEnd: ''
198+
MainIncludeChar: Quote
36199
MaxEmptyLinesToKeep: 1
37200
NamespaceIndentation: None
201+
ObjCBinPackProtocolList: Never
202+
ObjCBlockIndentWidth: 2
203+
ObjCBreakBeforeNestedBlockParam: true
204+
ObjCSpaceAfterProperty: false
205+
ObjCSpaceBeforeProtocolList: true
206+
PackConstructorInitializers: NextLine
207+
PenaltyBreakAssignment: 2
208+
PenaltyBreakBeforeFirstCallParameter: 1
209+
PenaltyBreakComment: 300
210+
PenaltyBreakFirstLessLess: 120
211+
PenaltyBreakOpenParenthesis: 0
212+
PenaltyBreakScopeResolution: 5000
213+
PenaltyBreakString: 1000
214+
PenaltyBreakTemplateDeclaration: 10
215+
PenaltyExcessCharacter: 1000000
216+
PenaltyIndentedWhitespace: 0
217+
PenaltyReturnTypeOnItsOwnLine: 200
218+
PointerAlignment: Left
219+
PPIndentWidth: -1
220+
QualifierAlignment: Left
221+
RawStringFormats: []
222+
ReferenceAlignment: Pointer
223+
ReflowComments: true
224+
RemoveBracesLLVM: false
225+
RemoveParentheses: Leave
226+
RemoveSemicolon: false
227+
RequiresClausePosition: OwnLine
228+
RequiresExpressionIndentation: OuterScope
229+
SeparateDefinitionBlocks: Leave
230+
ShortNamespaceLines: 1
231+
SkipMacroDefinitionBody: false
232+
SortIncludes: CaseSensitive
233+
SortJavaStaticImport: Before
234+
SortUsingDeclarations: LexicographicNumeric
235+
SpaceAfterCStyleCast: false
236+
SpaceAfterLogicalNot: false
237+
SpaceAfterTemplateKeyword: true
238+
SpaceAroundPointerQualifiers: Default
38239
SpaceBeforeAssignmentOperators: true
39-
Standard: Cpp11
40-
UseTab: Never
240+
SpaceBeforeCaseColon: false
241+
SpaceBeforeCpp11BracedList: false
242+
SpaceBeforeCtorInitializerColon: true
243+
SpaceBeforeInheritanceColon: true
244+
SpaceBeforeJsonColon: false
245+
SpaceBeforeParens: ControlStatements
246+
SpaceBeforeParensOptions:
247+
AfterControlStatements: true
248+
AfterForeachMacros: true
249+
AfterFunctionDefinitionName: false
250+
AfterFunctionDeclarationName: false
251+
AfterIfMacros: true
252+
AfterOverloadedOperator: false
253+
AfterPlacementOperator: true
254+
AfterRequiresInClause: false
255+
AfterRequiresInExpression: false
256+
BeforeNonEmptyParentheses: false
257+
SpaceBeforeRangeBasedForLoopColon: true
258+
SpaceBeforeSquareBrackets: false
259+
SpaceInEmptyBlock: false
260+
SpacesBeforeTrailingComments: 2
261+
SpacesInAngles: Never
262+
SpacesInContainerLiterals: true
263+
SpacesInLineCommentPrefix:
264+
Minimum: 1
265+
Maximum: -1
266+
SpacesInParens: Never
267+
SpacesInParensOptions:
268+
ExceptDoubleParentheses: false
269+
InCStyleCasts: false
270+
InConditionalStatements: false
271+
InEmptyParentheses: false
272+
Other: false
273+
SpacesInSquareBrackets: false
274+
Standard: Cpp11
275+
StatementAttributeLikeMacros: []
276+
StatementMacros:
277+
- BSONCXX_DISABLE_WARNING
278+
- BSONCXX_FORCE_SEMICOLON
279+
- BSONCXX_IF_CLANG
280+
- BSONCXX_IF_GCC
281+
- BSONCXX_IF_GNU_LIKE
282+
- BSONCXX_IF_MSVC
283+
- BSONCXX_POP_WARNINGS
284+
- BSONCXX_PUSH_WARNINGS
285+
- BSONCXX_SUPPRESS_DEPRECATION_WARNINGS_BEGIN
286+
- BSONCXX_SUPPRESS_DEPRECATION_WARNINGS_END
287+
TableGenBreakInsideDAGArg: DontBreak
288+
TabWidth: 8
289+
TypenameMacros:
290+
- BSONCXX_ABI_EXPORT_CDECL
291+
- BSONCXX_ABI_EXPORT_CDECL_TESTING
292+
- BSONCXX_ABI_EXPORT_TESTING
293+
- MONGOCXX_ABI_EXPORT_CDECL
294+
- MONGOCXX_ABI_EXPORT_CDECL_TESTING
295+
- MONGOCXX_ABI_EXPORT_TESTING
296+
UseTab: Never
297+
VerilogBreakBetweenInstancePorts: true
298+
WhitespaceSensitiveMacros: []
299+
...
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from config_generator.etc.function import Function
2+
from config_generator.etc.utils import bash_exec
3+
4+
from shrub.v3.evg_command import EvgCommandType, expansions_update
5+
6+
7+
class InstallUV(Function):
8+
name = 'install-uv'
9+
commands = [
10+
bash_exec(
11+
command_type=EvgCommandType.SETUP,
12+
script='''\
13+
set -o errexit
14+
set -o pipefail
15+
16+
if [[ ! -n "${MONGO_CXX_DRIVER_CACHE_DIR}" ]]; then
17+
echo "MONGO_CXX_DRIVER_CACHE_DIR is not defined!" 1>&2
18+
exit 1
19+
fi
20+
21+
uv_install_dir="${MONGO_CXX_DRIVER_CACHE_DIR}/uv-0.5.9"
22+
mkdir -p "$uv_install_dir"
23+
24+
if ! command -V "$uv_install_dir/uv" 2>/dev/null; then
25+
env \\
26+
UV_INSTALL_DIR="$uv_install_dir" \\
27+
UV_NO_MODIFY_PATH=1 \\
28+
mongo-cxx-driver/.evergreen/scripts/uv-installer.sh
29+
fi
30+
31+
printf "UV_INSTALL_DIR: %s\\n" "$uv_install_dir" >|expansions.uv.yml
32+
''',
33+
),
34+
expansions_update(
35+
command_type=EvgCommandType.SETUP,
36+
file='expansions.uv.yml',
37+
),
38+
]
39+
40+
41+
def functions():
42+
return InstallUV.defn()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from config_generator.etc.function import Function
2+
from config_generator.etc.utils import bash_exec
3+
4+
from shrub.v3.evg_command import EvgCommandType, expansions_update
5+
6+
7+
class SetCacheDir(Function):
8+
name = 'set-cache-dir'
9+
commands = [
10+
bash_exec(
11+
command_type=EvgCommandType.SETUP,
12+
script='''\
13+
if [[ -n "$XDG_CACHE_DIR" ]]; then
14+
cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification.
15+
elif [[ -n "$LOCALAPPDATA" ]]; then
16+
cache_dir="$LOCALAPPDATA" # Windows.
17+
elif [[ -n "$USERPROFILE" ]]; then
18+
cache_dir="$USERPROFILE/.cache" # Windows (fallback).
19+
elif [[ -d "$HOME/Library/Caches" ]]; then
20+
cache_dir="$HOME/Library/Caches" # MacOS.
21+
elif [[ -n "$HOME" ]]; then
22+
cache_dir="$HOME/.cache" # Linux-like.
23+
elif [[ -d ~/.cache ]]; then
24+
cache_dir="~/.cache" # Linux-like (fallback).
25+
else
26+
cache_dir="$(pwd)/.cache" # EVG task directory (fallback).
27+
fi
28+
29+
mkdir -p "$cache_dir/mongo-cxx-driver" || exit
30+
cache_dir="$(cd "$cache_dir/mongo-cxx-driver" && pwd)" || exit
31+
32+
printf "MONGO_CXX_DRIVER_CACHE_DIR: %s\\n" "$cache_dir" >|expansions.set-cache-dir.yml
33+
''',
34+
),
35+
expansions_update(
36+
command_type=EvgCommandType.SETUP,
37+
file='expansions.set-cache-dir.yml'
38+
),
39+
]
40+
41+
42+
def functions():
43+
return SetCacheDir.defn()

0 commit comments

Comments
 (0)