Skip to content

CXX-3198 upgrade to ClangFormat 19 and replace clang_format.py with clang-format-all.sh #1299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
275 changes: 267 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,14 +1,146 @@
---
Language: Cpp
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseArrows: false
AlignCaseColons: false
AlignConsecutiveTableGenBreakingDAGArgColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenCondOperatorColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenDefinitionColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
BasedOnStyle: Google
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AttributeMacros:
- BSONCXX_ABI_CDECL
- BSONCXX_ABI_EXPORT
- BSONCXX_ABI_NO_EXPORT
- BSONCXX_DEPRECATED
- BSONCXX_ENUM
- BSONCXX_PRAGMA
- BSONCXX_RETURNS
- MONGOCXX_ABI_CDECL
- MONGOCXX_ABI_EXPORT
- MONGOCXX_ABI_NO_EXPORT
- MONGOCXX_DEPRECATED
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 100
CommentPragmas: '^\s*(@(addtogroup|copydoc|defgroup|fn|ref)|- )'
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakAfterReturnType: None
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakFunctionDefinitionParameters: false
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
BreakTemplateDeclarations: Yes
ColumnLimit: 100
CommentPragmas: '^\s*(@(addtogroup|copydoc|defgroup|fn|ref)|- )'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
IncludeBlocks: Regroup
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros: []
IfMacros: []
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '".*"' # relative headers
Priority: 10
Expand All @@ -32,9 +164,136 @@ IncludeCategories:
Priority: 41
- Regex: '.*' # all other headers (third party)
Priority: 90
IndentWidth: 4
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: true
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MainIncludeChar: Quote
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 5000
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Left
RawStringFormats: []
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
Standard: Cpp11
UseTab: Never
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: true
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
ExceptDoubleParentheses: false
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementAttributeLikeMacros: []
StatementMacros:
- BSONCXX_DISABLE_WARNING
- BSONCXX_FORCE_SEMICOLON
- BSONCXX_IF_CLANG
- BSONCXX_IF_GCC
- BSONCXX_IF_GNU_LIKE
- BSONCXX_IF_MSVC
- BSONCXX_POP_WARNINGS
- BSONCXX_PUSH_WARNINGS
- BSONCXX_SUPPRESS_DEPRECATION_WARNINGS_BEGIN
- BSONCXX_SUPPRESS_DEPRECATION_WARNINGS_END
TableGenBreakInsideDAGArg: DontBreak
TabWidth: 8
TypenameMacros:
- BSONCXX_ABI_EXPORT_CDECL
- BSONCXX_ABI_EXPORT_CDECL_TESTING
- BSONCXX_ABI_EXPORT_TESTING
- MONGOCXX_ABI_EXPORT_CDECL
- MONGOCXX_ABI_EXPORT_CDECL_TESTING
- MONGOCXX_ABI_EXPORT_TESTING
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros: []
...
42 changes: 42 additions & 0 deletions .evergreen/config_generator/components/funcs/install_uv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec

from shrub.v3.evg_command import EvgCommandType, expansions_update


class InstallUV(Function):
name = 'install-uv'
commands = [
bash_exec(
command_type=EvgCommandType.SETUP,
script='''\
set -o errexit
set -o pipefail

if [[ ! -n "${MONGO_CXX_DRIVER_CACHE_DIR}" ]]; then
echo "MONGO_CXX_DRIVER_CACHE_DIR is not defined!" 1>&2
exit 1
fi

uv_install_dir="${MONGO_CXX_DRIVER_CACHE_DIR}/uv-0.5.9"
mkdir -p "$uv_install_dir"

if ! command -V "$uv_install_dir/uv" 2>/dev/null; then
env \\
UV_INSTALL_DIR="$uv_install_dir" \\
UV_NO_MODIFY_PATH=1 \\
mongo-cxx-driver/.evergreen/scripts/uv-installer.sh
fi

printf "UV_INSTALL_DIR: %s\\n" "$uv_install_dir" >|expansions.uv.yml
''',
),
expansions_update(
command_type=EvgCommandType.SETUP,
file='expansions.uv.yml',
),
]


def functions():
return InstallUV.defn()
43 changes: 43 additions & 0 deletions .evergreen/config_generator/components/funcs/set_cache_dir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec

from shrub.v3.evg_command import EvgCommandType, expansions_update


class SetCacheDir(Function):
name = 'set-cache-dir'
commands = [
bash_exec(
command_type=EvgCommandType.SETUP,
script='''\
if [[ -n "$XDG_CACHE_DIR" ]]; then
cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification.
elif [[ -n "$LOCALAPPDATA" ]]; then
cache_dir="$LOCALAPPDATA" # Windows.
elif [[ -n "$USERPROFILE" ]]; then
cache_dir="$USERPROFILE/.cache" # Windows (fallback).
elif [[ -d "$HOME/Library/Caches" ]]; then
cache_dir="$HOME/Library/Caches" # MacOS.
elif [[ -n "$HOME" ]]; then
cache_dir="$HOME/.cache" # Linux-like.
elif [[ -d ~/.cache ]]; then
cache_dir="~/.cache" # Linux-like (fallback).
else
cache_dir="$(pwd)/.cache" # EVG task directory (fallback).
fi

mkdir -p "$cache_dir/mongo-cxx-driver" || exit
cache_dir="$(cd "$cache_dir/mongo-cxx-driver" && pwd)" || exit

printf "MONGO_CXX_DRIVER_CACHE_DIR: %s\\n" "$cache_dir" >|expansions.set-cache-dir.yml
''',
),
expansions_update(
command_type=EvgCommandType.SETUP,
file='expansions.set-cache-dir.yml'
),
]


def functions():
return SetCacheDir.defn()
Loading