git.s-ol.nu ~forks/DiligentTools / 73001ea
Added bat script and CMake target to perform source code formatting validation Egor Yusov 1 year, 10 months ago
3 changed file(s) with 507 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ---
1 # https://clang.llvm.org/docs/ClangFormatStyleOptions.html
2
3 Language: Cpp
4 # BasedOnStyle: Microsoft
5
6 # The extra indent or outdent of access modifiers, e.g. public:.
7 AccessModifierOffset: -4
8 # class
9 # {
10 # public:
11 #
12
13
14 # If true, horizontally aligns arguments after an open bracket.
15 # This applies to round brackets (parentheses), angle brackets and square brackets.
16 AlignAfterOpenBracket: Align
17 # Align:
18 # someLongFunction(argument1,
19 # argument2);
20
21
22 # If true, aligns consecutive C/C++ preprocessor macros.
23 AlignConsecutiveMacros: true
24 # true:
25 # #define SHORT_NAME 42
26 # #define LONGER_NAME 0x007f
27 # #define EVEN_LONGER_NAME (2)
28 # #define foo(x) (x * x)
29 # #define bar(y, z) (y + z)
30
31
32 # If true, aligns consecutive assignments.
33 AlignConsecutiveAssignments: true
34 # true:
35 # int aaaa = 12;
36 # int b = 23;
37 # int ccc = 23;
38
39
40 # If true, aligns consecutive declarations.
41 AlignConsecutiveDeclarations: true
42 # true:
43 # int aaaa = 12;
44 # float b = 23;
45 # std::string ccc = 23;
46
47
48 AlignEscapedNewlines: Left
49 # Left:
50 # #define A \
51 # int aaaa; \
52 # int b; \
53 # int dddddddddd;
54
55
56 # If true, horizontally align operands of binary and ternary expressions.
57 AlignOperands: false
58
59
60 # If true, aligns trailing comments.
61 AlignTrailingComments: true
62 # true:
63 # int a; // My comment a
64 # int b = 2; // comment b
65
66
67 # If a function call or braced initializer list doesn't fit on a line,
68 # allow putting all arguments onto the next line, even if BinPackArguments is false.
69 AllowAllArgumentsOnNextLine: true
70 # true:
71 # callFunction(a,
72 # b,
73 # c,
74 # d);
75
76
77 # If a constructor definition with a member initializer list doesn't fit on a single line,
78 # allow putting all member initializers onto the next line, if 'ConstructorInitializerAllOnOneLineOrOnePerLine'
79 # is true. Note that this parameter has no effect if 'ConstructorInitializerAllOnOneLineOrOnePerLine' is false.
80 AllowAllConstructorInitializersOnNextLine: true
81 # true:
82 # MyClass::MyClass() :
83 # member0(0), member1(2) {}
84
85
86 # If the function declaration doesn't fit on a line, allow putting all parameters
87 # of a function declaration onto the next line even if BinPackParameters is false.
88 AllowAllParametersOfDeclarationOnNextLine: false
89 #false:
90 #void myFunction(int a,
91 # int b,
92 # int c);
93
94
95 AllowShortBlocksOnASingleLine: Always
96 # Always:
97 # while (true) {}
98 # while (true) {continue;}
99
100
101 AllowShortCaseLabelsOnASingleLine: true
102 # true:
103 # switch (a)
104 # {
105 # case 1: x = 1; break;
106
107
108 AllowShortFunctionsOnASingleLine: All
109 AllowShortLambdasOnASingleLine: Inline
110 AllowShortIfStatementsOnASingleLine: Always
111 AllowShortLoopsOnASingleLine: true
112
113 # The function definition return type breaking style to use.
114 # This option is deprecated and is retained for backwards compatibility.
115 AlwaysBreakAfterDefinitionReturnType: None
116
117 AlwaysBreakAfterReturnType: None
118 AlwaysBreakBeforeMultilineStrings: false
119 AlwaysBreakTemplateDeclarations: No
120
121 # If false, a function call's arguments will either be all on the same line or will have one line each.
122 BinPackArguments: true
123 # false:
124 # void f() {
125 # f(aaaaaaaaaaaaaaaaaaaa,
126 # aaaaaaaaaaaaaaaaaaaa,
127 # aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
128 # }
129
130
131 # If false, a function declaration's or function definition's parameters will
132 # either all be on the same line or will have one line each.
133 BinPackParameters: false
134 # false:
135 # void f(int aaaaaaaaaaaaaaaaaaaa,
136 # int aaaaaaaaaaaaaaaaaaaa,
137 # int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
138
139
140 # Cuatom: Configure each individual brace in BraceWrapping.
141 BreakBeforeBraces: Custom
142
143 BraceWrapping:
144 AfterCaseLabel: true
145 # true:
146 # case 1
147 # {
148 # bar();
149 # break;
150 # }
151
152
153 AfterClass: true
154 # true:
155 # class A
156 # {
157
158
159 # Only wrap braces after a multi-line control statement.
160 AfterControlStatement: Always
161 # MultiLine:
162 # if (foo && bar)
163 # {
164 # quux();
165 # }
166 # while (foo || bar)
167 # {}
168
169
170 AfterEnum: true
171 # true:
172 # enum X : int
173 # {
174 # B
175 # };
176
177
178 AfterFunction: true
179 # void foo()
180 # {
181 # bar();
182 # bar2();
183 # }
184
185
186 AfterNamespace: true
187 # true:
188 # namespace
189 # {
190 # int foo();
191
192
193 # Wrap ObjC definitions (interfaces, implementations...). @autoreleasepool and @synchronized
194 # blocks are wrapped according to AfterControlStatement flag.
195 AfterObjCDeclaration: true
196
197
198 AfterStruct: true
199 # true:
200 # struct foo
201 # {
202 # int x;
203 # };
204
205
206 AfterUnion: true
207 # true:
208 # union foo
209 # {
210 # int x;
211 # }
212
213
214 AfterExternBlock: true
215 # true:
216 # extern "C"
217 # {
218 # int foo();
219 # }
220
221
222 BeforeCatch: true
223 # true:
224 # }
225 # catch ()
226
227
228 BeforeElse: true
229 # true:
230 # }
231 # else
232
233
234 # Indent the wrapped braces themselves.
235 IndentBraces: false
236
237 # If false, empty function body can be put on a single line
238 SplitEmptyFunction: false
239
240 # If false, empty record (e.g. class, struct or union) body can be put on a single line.
241 SplitEmptyRecord: false
242
243 # If false, empty namespace body can be put on a single line.
244 SplitEmptyNamespace: false
245
246 # The way to wrap binary operators.
247 BreakBeforeBinaryOperators: None
248
249
250 BreakBeforeInheritanceComma: false
251
252 BreakInheritanceList: AfterColon
253 # AfterColon:
254 # class Foo :
255 # Base1,
256 # Base2
257 # {};
258
259
260 # If true, ternary operators will be placed after line breaks.
261 BreakBeforeTernaryOperators: false
262 # false:
263 # veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
264 # firstValue :
265 # SecondValueVeryVeryVeryVeryLong;
266
267 BreakConstructorInitializersBeforeComma: false
268
269 BreakConstructorInitializers: AfterColon
270 # Constructor() :
271 # initializer1(),
272 # initializer2()
273
274 BreakAfterJavaFieldAnnotations: false
275
276 # Allow breaking string literals when formatting.
277 BreakStringLiterals: false
278
279 # A column limit of 0 means that there is no column limit. In this case, clang-format will
280 # respect the input's line breaking decisions within statements unless they contradict other rules.
281 ColumnLimit: 0
282
283 # A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed.
284 CommentPragmas: '^ IWYU pragma:'
285
286 # If true, consecutive namespace declarations will be on the same line.
287 CompactNamespaces: false
288 # false:
289 # namespace Foo
290 # {
291 # namespace Bar
292 # {
293 # }
294 # }
295
296 # If the constructor initializers don't fit on a line, put each initializer on its own line.
297 ConstructorInitializerAllOnOneLineOrOnePerLine: true
298
299 ConstructorInitializerIndentWidth: 4
300 ContinuationIndentWidth: 4
301
302 # If true, format braced lists as best suited for C++11 braced lists.
303 Cpp11BracedListStyle: true
304 DerivePointerAlignment: false
305 DisableFormat: false
306 ExperimentalAutoDetectBinPacking: false
307 # If true, clang-format adds missing namespace end comments and fixes invalid existing ones.
308 FixNamespaceComments: true
309
310 # A vector of macros that should be interpreted as foreach loops instead of as function calls.
311 ForEachMacros:
312 - foreach
313 - Q_FOREACH
314 - BOOST_FOREACH
315
316 IncludeBlocks: Preserve
317 IncludeCategories:
318 - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
319 Priority: 2
320 SortPriority: 0
321 - Regex: '^(<|"(gtest|gmock|isl|json)/)'
322 Priority: 3
323 SortPriority: 0
324 - Regex: '.*'
325 Priority: 1
326 SortPriority: 0
327 IncludeIsMainRegex: '(Test)?$'
328
329 # Indent case labels one level from the switch statement.
330 IndentCaseLabels: true
331 # true:
332 # switch(foo)
333 # {
334 # case bar:
335
336 IndentGotoLabels: true
337
338 # The preprocessor directive indenting style to use.
339 IndentPPDirectives: AfterHash
340 # #if FOO
341 # # if BAR
342 # # include <foo>
343 # # endif
344 # #endif
345
346
347 IndentWidth: 4
348 IndentWrappedFunctionNames: false
349 JavaScriptQuotes: Leave
350 JavaScriptWrapImports: true
351
352 # If true, the empty line at the start of blocks is kept.
353 KeepEmptyLinesAtTheStartOfBlocks: true
354 MacroBlockBegin: ''
355 MacroBlockEnd: ''
356
357 # The maximum number of consecutive empty lines to keep.
358 MaxEmptyLinesToKeep: 10000
359
360 # The indentation used for namespaces.
361 NamespaceIndentation: None
362
363 ObjCBinPackProtocolList: Auto
364 ObjCBlockIndentWidth: 4
365 ObjCSpaceAfterProperty: false
366 ObjCSpaceBeforeProtocolList: true
367 PenaltyBreakAssignment: 2
368 PenaltyBreakBeforeFirstCallParameter: 19
369 PenaltyBreakComment: 300
370 PenaltyBreakFirstLessLess: 120
371 PenaltyBreakString: 1000
372 PenaltyBreakTemplateDeclaration: 10
373 PenaltyExcessCharacter: 1000000
374 PenaltyReturnTypeOnItsOwnLine: 1000
375
376 PointerAlignment: Left
377 # left:
378 # int* a;
379 # int& b;
380
381 # If true, clang-format will attempt to re-flow comments.
382 ReflowComments: false
383
384 SortIncludes: false
385 SortUsingDeclarations: false
386 SpaceAfterCStyleCast: false
387 # false:
388 # (int)i;
389
390
391 SpaceAfterLogicalNot: false
392 # false:
393 # !bar();
394
395 SpaceAfterTemplateKeyword: true
396 # true:
397 # template <typename>
398
399
400 SpaceBeforeAssignmentOperators: true
401 # true:
402 # int a =
403
404 # If true, a space will be inserted before a C++11 braced list used to
405 # initialize an object (after the preceding identifier or type).
406 SpaceBeforeCpp11BracedList: false
407 # false:
408 # vector<int>{1, 2, 3};
409
410
411 SpaceBeforeCtorInitializerColon: true
412 # true:
413 # Foo::Foo() : a(a) {}
414
415
416 SpaceBeforeInheritanceColon: true
417 # true:
418 # class Foo : Bar {}
419
420
421 # Put a space before opening parentheses only after control statement keywords (for/if/while...)
422 SpaceBeforeParens: ControlStatements
423 # ControlStatements:
424 # void f() {
425 # if (true) {
426 # f();
427 # }
428 # }
429
430
431 SpaceBeforeRangeBasedForLoopColon: true
432 # true:
433 # for (auto v : values) {}
434
435
436 SpaceInEmptyBlock: false
437 # false:
438 # void f() {}
439
440
441 SpaceInEmptyParentheses: false
442 # false:
443 # f();
444
445 SpacesBeforeTrailingComments: 1
446
447 SpacesInAngles: false
448 # false:
449 # static_cast<int>(arg);
450
451
452 SpacesInContainerLiterals: false
453 # false:
454 # var arr = [1, 2, 3];
455
456
457 SpacesInCStyleCastParentheses: false
458 # false:
459 # x = (int32)y
460
461
462 SpacesInParentheses: false
463 # false:
464 # t f(Deleted &) & = delete;
465
466 SpacesInSquareBrackets: false
467 # false:
468 # int a[5];
469
470
471 Standard: Latest
472
473 StatementMacros:
474 - Q_UNUSED
475 - QT_REQUIRE_VERSION
476 TabWidth: 4
477 UseTab: Never
478 ...
0 python ../../../DiligentCore/BuildTools/FormatValidation/clang-format-validate.py --color never ^
1 --clang-format-executable ../../../DiligentCore/BuildTools/FormatValidation/clang-format_10.0.0.exe ^
2 -r ../../AssetLoader ../../Imgui ../../NativeApp/include ../../NativeApp/src ../../TextureLoader ^
3 --exclude ../../Imgui/interface/ImGuiImplMacOS.h ^
4 --exclude ../../Imgui/interface/ImGuiImplIOS.h ^
5 --exclude ../../NativeApp/src/UWP ^
6 --exclude ../../NativeApp/include/UWP
6060 )
6161
6262 endif()
63
64
65 # Create a custom target to run source code formatting validation command
66 if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
67 add_custom_target(DiligentTools-ValidateFormatting ALL
68 COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/../DiligentCore/.clang-format" "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format"
69 )
70
71 add_custom_command(TARGET DiligentTools-ValidateFormatting
72 COMMAND validate_format_win.bat
73 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/BuildTools/FormatValidation"
74 COMMENT "Validating DiligentTools module's source code formatting..."
75 VERBATIM
76 )
77 endif()
78
79 if(TARGET DiligentTools-ValidateFormatting)
80 set_target_properties(DiligentTools-ValidateFormatting PROPERTIES
81 FOLDER DiligentTools
82 )
83 endif()