Skip to content

Commit 738ca6d

Browse files
c-p-i-ofacebook-github-bot
authored andcommitted
Formatting changes + fix windows OSS build (#406)
Summary: Add .clang-format. This is copied from https://github.com/pytorch/pytorch/blob/main/.clang-format Reviewed By: wconstab, fduwjj Differential Revision: D69275930
1 parent b67ecd8 commit 738ca6d

File tree

18 files changed

+463
-560
lines changed

18 files changed

+463
-560
lines changed

.github/config/lint/.clang-format

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakStringLiterals: false
38+
ColumnLimit: 120
39+
CommentPragmas: '^ IWYU pragma:'
40+
CompactNamespaces: false
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
ConstructorInitializerIndentWidth: 4
43+
ContinuationIndentWidth: 4
44+
Cpp11BracedListStyle: true
45+
DerivePointerAlignment: false
46+
DisableFormat: false
47+
ForEachMacros:
48+
- FOR_EACH_RANGE
49+
- FOR_EACH
50+
IncludeCategories:
51+
- Regex: '^<.*\.h(pp)?>'
52+
Priority: 1
53+
- Regex: '^<.*'
54+
Priority: 2
55+
- Regex: '.*'
56+
Priority: 3
57+
IndentCaseLabels: true
58+
IndentWidth: 2
59+
IndentWrappedFunctionNames: false
60+
KeepEmptyLinesAtTheStartOfBlocks: false
61+
MacroBlockBegin: ''
62+
MacroBlockEnd: ''
63+
Macros:
64+
- >-
65+
PyObject_HEAD_INIT(type)={
66+
/* this is not exactly match with PyObject_HEAD_INIT in Python source code
67+
* but it is enough for clang-format */
68+
{ 0xFFFFFFFF },
69+
(type)
70+
},
71+
- >-
72+
PyVarObject_HEAD_INIT(type, size)={
73+
{
74+
/* manually expand PyObject_HEAD_INIT(type) above
75+
* because clang-format do not support recursive expansion */
76+
{ 0xFFFFFFFF },
77+
(type)
78+
},
79+
(size)
80+
},
81+
MaxEmptyLinesToKeep: 1
82+
NamespaceIndentation: None
83+
PenaltyBreakBeforeFirstCallParameter: 1
84+
PenaltyBreakComment: 300
85+
PenaltyBreakFirstLessLess: 120
86+
PenaltyBreakString: 1000
87+
PenaltyExcessCharacter: 1000000
88+
PenaltyReturnTypeOnItsOwnLine: 2000000
89+
PointerAlignment: Left
90+
PPIndentWidth: 0
91+
ReflowComments: true
92+
SortIncludes: true
93+
SpaceAfterCStyleCast: false
94+
SpaceBeforeAssignmentOperators: true
95+
SpaceBeforeParens: ControlStatements
96+
SpaceInEmptyParentheses: false
97+
SpacesBeforeTrailingComments: 1
98+
SpacesInAngles: false
99+
SpacesInContainerLiterals: true
100+
SpacesInCStyleCastParentheses: false
101+
SpacesInParentheses: false
102+
SpacesInSquareBrackets: false
103+
Standard: c++17
104+
StatementMacros:
105+
- C10_DEFINE_bool
106+
- C10_DEFINE_int
107+
- C10_DEFINE_int32
108+
- C10_DEFINE_int64
109+
- C10_DEFINE_string
110+
- C10_DEFINE_REGISTRY_WITHOUT_WARNING
111+
- C10_REGISTER_CREATOR
112+
- DEFINE_BINARY
113+
- PyObject_HEAD
114+
- PyObject_VAR_HEAD
115+
- PyException_HEAD
116+
- TORCH_DECLARE_bool
117+
118+
TabWidth: 8
119+
UseTab: Never
120+
---
121+
Language: ObjC
122+
ColumnLimit: 120
123+
AlignAfterOpenBracket: Align
124+
ObjCBlockIndentWidth: 2
125+
ObjCSpaceAfterProperty: false
126+
ObjCSpaceBeforeProtocolList: false
127+
...

.github/workflows/build-windows.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ jobs:
4949
cd libuv-v1.38.0
5050
mkdir -p build
5151
cd build
52-
mkdir -p ${{ env.gtest_lib_path }}
52+
mkdir -p ${{ env.libuv_path }}
5353
cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.libuv_path }}
5454
msbuild INSTALL.vcxproj
5555
- name: Install googletest
5656
run: |
5757
conda activate py376_build
58-
curl https://codeload.github.com/google/googletest/tar.gz/release-1.10.0 --output `
59-
googletest-release-1.10.0.tar.gz
60-
tar xzvf googletest-release-1.10.0.tar.gz
61-
cd googletest-release-1.10.0
58+
curl -L https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz `
59+
--output googletest-1.15.2.tar.gz
60+
tar xzvf googletest-1.15.2.tar.gz
61+
cd googletest-1.15.2
6262
mkdir -p build
6363
cd build
6464
if (Test-Path -Path ${{ env.gtest_lib_path }}) {
6565
echo "Directory already exists"
6666
} else {
67-
mkdir ${{ env.gtest_lib_path }}
67+
mkdir -p ${{ env.gtest_lib_path }}
6868
}
6969
cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.gtest_lib_path }} -Dgtest_force_shared_crt=ON
7070
msbuild INSTALL.vcxproj
@@ -76,9 +76,9 @@ jobs:
7676
mkdir -p build
7777
cd build
7878
cmake .. -DBUILD_TEST=ON -Dlibuv_ROOT=${{ env.libuv_path }} `
79-
-DGTEST_LIBRARY=${{ env.gtest_lib_path }}/lib/gtestd.lib `
79+
-DGTEST_LIBRARY=${{ env.gtest_lib_path }}/lib/gtest.lib `
8080
-DGTEST_INCLUDE_DIR=${{ env.gtest_lib_path }}/include `
81-
-DGTEST_MAIN_LIBRARY=${{ env.gtest_lib_path }}/lib/gtest_maind.lib
81+
-DGTEST_MAIN_LIBRARY=${{ env.gtest_lib_path }}/lib/gtest_main.lib
8282
msbuild ALL_BUILD.vcxproj
8383
- name: Test
8484
run: |

.github/workflows/super-linter.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ jobs:
2727
- name: Super-linter
2828
uses: super-linter/[email protected] # x-release-please-version
2929
env:
30-
LINTER_RULES_PATH: .github/config/lint
30+
LINTER_RULES_PATH: gloo
3131
# To report GitHub Actions status checks
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333
VALIDATE_ALL_CODEBASE: false
3434
DEFAULT_BRANCH: "main"
3535
# disable JSCPD (copy-paste checker)
3636
VALIDATE_JSCPD: false
37+
# disable CPP
38+
VALIDATE_CPP: false

gloo/.clang-format

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakStringLiterals: false
38+
ColumnLimit: 120
39+
CommentPragmas: '^ IWYU pragma:'
40+
CompactNamespaces: false
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
ConstructorInitializerIndentWidth: 4
43+
ContinuationIndentWidth: 4
44+
Cpp11BracedListStyle: true
45+
DerivePointerAlignment: false
46+
DisableFormat: false
47+
ForEachMacros:
48+
- FOR_EACH_RANGE
49+
- FOR_EACH
50+
IncludeCategories:
51+
- Regex: '^<.*\.h(pp)?>'
52+
Priority: 1
53+
- Regex: '^<.*'
54+
Priority: 2
55+
- Regex: '.*'
56+
Priority: 3
57+
IndentCaseLabels: true
58+
IndentWidth: 2
59+
IndentWrappedFunctionNames: false
60+
KeepEmptyLinesAtTheStartOfBlocks: false
61+
MacroBlockBegin: ''
62+
MacroBlockEnd: ''
63+
Macros:
64+
- >-
65+
PyObject_HEAD_INIT(type)={
66+
/* this is not exactly match with PyObject_HEAD_INIT in Python source code
67+
* but it is enough for clang-format */
68+
{ 0xFFFFFFFF },
69+
(type)
70+
},
71+
- >-
72+
PyVarObject_HEAD_INIT(type, size)={
73+
{
74+
/* manually expand PyObject_HEAD_INIT(type) above
75+
* because clang-format do not support recursive expansion */
76+
{ 0xFFFFFFFF },
77+
(type)
78+
},
79+
(size)
80+
},
81+
MaxEmptyLinesToKeep: 1
82+
NamespaceIndentation: None
83+
PenaltyBreakBeforeFirstCallParameter: 1
84+
PenaltyBreakComment: 300
85+
PenaltyBreakFirstLessLess: 120
86+
PenaltyBreakString: 1000
87+
PenaltyExcessCharacter: 1000000
88+
PenaltyReturnTypeOnItsOwnLine: 2000000
89+
PointerAlignment: Left
90+
PPIndentWidth: 0
91+
ReflowComments: true
92+
SortIncludes: true
93+
SpaceAfterCStyleCast: false
94+
SpaceBeforeAssignmentOperators: true
95+
SpaceBeforeParens: ControlStatements
96+
SpaceInEmptyParentheses: false
97+
SpacesBeforeTrailingComments: 1
98+
SpacesInAngles: false
99+
SpacesInContainerLiterals: true
100+
SpacesInCStyleCastParentheses: false
101+
SpacesInParentheses: false
102+
SpacesInSquareBrackets: false
103+
Standard: c++17
104+
StatementMacros:
105+
- C10_DEFINE_bool
106+
- C10_DEFINE_int
107+
- C10_DEFINE_int32
108+
- C10_DEFINE_int64
109+
- C10_DEFINE_string
110+
- C10_DEFINE_REGISTRY_WITHOUT_WARNING
111+
- C10_REGISTER_CREATOR
112+
- DEFINE_BINARY
113+
- PyObject_HEAD
114+
- PyObject_VAR_HEAD
115+
- PyException_HEAD
116+
- TORCH_DECLARE_bool
117+
118+
TabWidth: 8
119+
UseTab: Never
120+
---
121+
Language: ObjC
122+
ColumnLimit: 120
123+
AlignAfterOpenBracket: Align
124+
ObjCBlockIndentWidth: 2
125+
ObjCSpaceAfterProperty: false
126+
ObjCSpaceBeforeProtocolList: false
127+
...

gloo/.yaml-lint.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
# 120 chars should be enough, but don't fail if a line is longer
6+
line-length:
7+
max: 120
8+
level: warning
9+
comments:
10+
min-spaces-from-content: 2

0 commit comments

Comments
 (0)