Skip to content

Commit c6569f5

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

File tree

5 files changed

+142
-10
lines changed

5 files changed

+142
-10
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ jobs:
3434
DEFAULT_BRANCH: "main"
3535
# disable JSCPD (copy-paste checker)
3636
VALIDATE_JSCPD: false
37+
# disable CPP
38+
VALIDATE_CPP: false

gloo/allreduce_bcube.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
#include <cstring>
1616
#include <iomanip>
1717
#include <iostream>
18+
#include <memory>
19+
#include <string>
1820
#include <unordered_map>
21+
#include <vector>
1922

2023
#include "gloo/algorithm.h"
2124
#include "gloo/common/error.h"

gloo/test/base_test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ enum Transport {
6666
};
6767

6868
// Transports that instantiated algorithms can be tested against.
69-
const std::vector<Transport> kTransportsForClassAlgorithms{
69+
const std::vector<Transport> kTransportsForClassAlgorithms = {
7070
Transport::TCP,
7171
#if GLOO_HAVE_TRANSPORT_TCP_TLS
7272
Transport::TCP_TLS,
@@ -76,7 +76,7 @@ const std::vector<Transport> kTransportsForClassAlgorithms{
7676
// Transports that function algorithms can be tested against.
7777
// This is the new style of calling collectives and must be
7878
// preferred over the instantiated style.
79-
const std::vector<Transport> kTransportsForFunctionAlgorithms{
79+
const std::vector<Transport> kTransportsForFunctionAlgorithms = {
8080
Transport::TCP,
8181
#if GLOO_HAVE_TRANSPORT_TCP_TLS
8282
Transport::TCP_TLS,

0 commit comments

Comments
 (0)