Skip to content

Commit

Permalink
Introduce clang-format
Browse files Browse the repository at this point in the history
Create .clang-format file as well as mark exceptions for generated
files.

Also, update BIN2H in Utilities so that it will automatically add
"// clang-format off" at the beginning of generated files.
  • Loading branch information
brakhane committed Jul 25, 2024
1 parent 14bd8e3 commit 715fd1f
Show file tree
Hide file tree
Showing 35 changed files with 101 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
BasedOnStyle: WebKit

AlignAfterOpenBracket: DontAlign
# AlignConsecutiveDeclarations: true
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
BreakBeforeBraces: Custom
# Allman style (wrap before any brace) *except* before lambda bodies
BreakBeforeBinaryOperators: None
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: false
ColumnLimit: 0
IncludeCategories: # only used when SortIncludes is active
- Regex: '^"stdafx.h"'
Priority: -1
- Regex: '<.*'
Priority: 1
- Regex: '^"wi.*"'
Priority: 2
IndentWidth: 4
# FixNamespaceComments: true # maybe?
MaxEmptyLinesToKeep: 3
NamespaceIndentation: All
# SpacesBeforeTrailingComments: 1
# SeparateDefinitionBlocks: Always # maybe?
SortIncludes: Never # maybe?
SpaceInEmptyBlock: false
SpaceAfterTemplateKeyword: false
SpacesInLineCommentPrefix:
Minimum: 0 # maybe 1?
Maximum: -1
TabWidth: 4
UseTab: Always
1 change: 1 addition & 0 deletions Editor/FontAwesomeV6.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
const uint8_t font_awesome_v6[] = {
0,1,0,0,0,10,0,128,0,3,0,32,79,83,47,50,97,75,98,74,0,0,1,40,0,0,0,96,99,109,97,112,
85,100,88,117,0,0,23,64,0,0,72,110,103,108,121,102,15,69,38,190,0,0,117,108,0,5,45,12,104,101,97,100,
Expand Down
1 change: 1 addition & 0 deletions Editor/IconDefinitions.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
#pragma once
#include "IconsFontAwesome6.h" // icon descriptions, source: https://github.com/juliettef/IconFontCppHeaders

Expand Down
1 change: 1 addition & 0 deletions Editor/IconsFontAwesome6.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
// Generated by https://github.com/juliettef/IconFontCppHeaders script GenerateIconFontCppHeaders.py for languages C and C++
// from https://github.com/FortAwesome/Font-Awesome/raw/6.x/metadata/icons.yml
// for use with https://github.com/FortAwesome/Font-Awesome/blob/6.x/webfonts/fa-regular-400.ttf, https://github.com/FortAwesome/Font-Awesome/blob/6.x/webfonts/fa-solid-900.ttf
Expand Down
1 change: 1 addition & 0 deletions Editor/dummy_direction.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
static const float3 vertices[609] = {
float3(0.550000f,0.000000f,0.000000f),
float3(0.545295f,-0.000000f,0.071789f),
Expand Down
1 change: 1 addition & 0 deletions Editor/dummy_female.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
static const float3 vertices[16592] = {
float3(-0.027344f,1.655921f,-0.039425f),
float3(-0.019501f,1.657624f,-0.034160f),
Expand Down
1 change: 1 addition & 0 deletions Editor/dummy_male.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
static const float3 vertices[20621] = {
float3(0.029937f,0.978897f,-0.081632f),
float3(0.067000f,0.980649f,-0.094412f),
Expand Down
1 change: 1 addition & 0 deletions Editor/dummy_pickup.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
static const float3 vertices[2210] = {
float3(0.536435f,-0.085426f,-0.086257f),
float3(0.532677f,-0.133048f,-0.032462f),
Expand Down
1 change: 1 addition & 0 deletions Editor/dummy_soldier.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
static const float3 vertices[35319] = {
float3(-0.128795f,1.239626f,-0.183225f),
float3(-0.128795f,1.239832f,-0.184724f),
Expand Down
1 change: 1 addition & 0 deletions Editor/dummy_waypoint.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
static const float3 vertices[1091] = {
float3(0.000000f,-0.052334f,0.163862f),
float3(0.000000f,-0.041118f,0.192681f),
Expand Down
2 changes: 1 addition & 1 deletion Editor/json.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
Expand Down Expand Up @@ -26,7 +27,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef INCLUDE_NLOHMANN_JSON_HPP_
#define INCLUDE_NLOHMANN_JSON_HPP_

Expand Down
1 change: 1 addition & 0 deletions Editor/resource.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Editor.rc
Expand Down
1 change: 1 addition & 0 deletions Editor/tiny_gltf.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
//
// Header-only tiny glTF 2.0 loader and serializer.
//
Expand Down
1 change: 1 addition & 0 deletions Editor/tiny_obj_loader.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
/*
The MIT License (MIT)

Expand Down
1 change: 1 addition & 0 deletions Editor/ufbx.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
#ifndef UFBX_UFBX_C_INCLUDED
#define UFBX_UFBX_C_INCLUDED

Expand Down
1 change: 1 addition & 0 deletions Editor/ufbx.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
#ifndef UFBX_UFBX_H_INCLUDED
#define UFBX_UFBX_H_INCLUDED

Expand Down
1 change: 1 addition & 0 deletions Editor/xatlas.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
/*
MIT License

Expand Down
1 change: 1 addition & 0 deletions Editor/xatlas.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
/*
MIT License

Expand Down
3 changes: 3 additions & 0 deletions Example_ImGui/ImGui/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
1 change: 1 addition & 0 deletions Example_ImGui/resource.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Tests.rc
Expand Down
3 changes: 3 additions & 0 deletions Example_ImGui_Docking/ImGui/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
1 change: 1 addition & 0 deletions Template_Windows/resource.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by TemplateWindows.rc
Expand Down
3 changes: 3 additions & 0 deletions WickedEngine/Jolt/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
3 changes: 3 additions & 0 deletions WickedEngine/LUA/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
3 changes: 3 additions & 0 deletions WickedEngine/Utility/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
1 change: 1 addition & 0 deletions WickedEngine/logo.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
const uint8_t wicked_engine_logo[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/offlineshadercompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ int main(int argc, char* argv[])
std::cout << "[Wicked Engine Offline Shader Compiler] Creating ShaderDump...\n";
timer.record();
std::string ss;
ss += "// clang-format off\n";
ss += "namespace wiShaderDump {\n";
for (auto& x : results)
{
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/sdl2.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
// From https://github.com/xyproto/sdl2-examples/blob/master/include/sdl2.h
// MIT License

Expand Down
3 changes: 3 additions & 0 deletions WickedEngine/shaders/compressonator/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
3 changes: 3 additions & 0 deletions WickedEngine/shaders/ffx-fsr/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
3 changes: 3 additions & 0 deletions WickedEngine/shaders/ffx-fsr2/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
3 changes: 3 additions & 0 deletions WickedEngine/shaders/ffx-shadows-dnsr/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# no formatting for vendored files
DisableFormat: true
SortIncludes: Never
1 change: 1 addition & 0 deletions WickedEngine/waterripple.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
const uint8_t waterriple[] = {
128,128,0,0,0,0,0,0,128,128,0,0,0,0,0,0,128,128,0,0,0,0,0,0,128,128,0,0,0,0,0,0,
128,128,0,0,0,0,0,0,128,128,0,0,0,0,0,0,128,128,0,0,0,0,0,0,128,128,0,0,0,0,0,0,
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/wiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ namespace wi::helper
bool Bin2H(const uint8_t* data, size_t size, const std::string& dst_filename, const char* dataName)
{
std::string ss;
ss += "// clang-format off\n";
ss += "const uint8_t ";
ss += dataName ;
ss += "[] = {";
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/wiSheenLUT.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// clang-format off
const uint8_t sheenLUTdata[] = {255, 220, 162, 121, 90, 65, 47, 34, 23, 16, 10, 6, 4, 2, 1, 0, 255, 221, 163, 119, 88, 64, 47, 33, 23, 16, 10, 7, 4, 2, 1, 0, 255, 219, 159, 119, 88, 65, 47, 33, 23, 16, 10, 7, 4, 2, 1, 0, 255, 220, 161, 120, 88, 65, 47, 33, 24, 16, 11, 6, 4, 2, 1, 0, 255, 216, 160, 122, 92, 69, 51, 37, 27, 19, 13, 8, 5, 3, 1, 0, 255, 198, 155, 123, 98, 78, 61, 47, 37, 28, 20, 15, 10, 7, 4, 2, 233, 184, 147, 122, 100, 84, 68, 56, 45, 36, 28, 22, 16, 11, 8, 4, 211, 171, 142, 121, 101, 86, 72, 61, 51, 42, 34, 28, 22, 16, 12, 8, 196, 163, 136, 118, 102, 88, 76, 65, 56, 48, 40, 33, 27, 21, 17, 12, 185, 154, 132, 116, 101, 89, 78, 68, 59, 52, 45, 38, 32, 26, 21, 16, 175, 148, 128, 114, 100, 89, 80, 71, 63, 55, 48, 42, 36, 30, 25, 20, 166, 142, 125, 111, 99, 89, 81, 72, 65, 58, 51, 45, 39, 34, 29, 24, 161, 138, 122, 109, 99, 89, 81, 74, 67, 60, 54, 48, 43, 37, 33, 28, 155, 134, 120, 108, 98, 90, 82, 75, 68, 62, 56, 51, 46, 41, 36, 31, 150, 131, 117, 107, 97, 90, 82, 75, 69, 63, 58, 53, 48, 43, 39, 34, 147, 128, 116, 105, 97, 89, 82, 76, 70, 65, 60, 55, 50, 46, 41, 37, 253, 253, 253, 253, 0, 0, 0, 0, 19, 4, 29, 66, 0, 4, 0, 128, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221,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