Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/timw/spicy-reformat'
Browse files Browse the repository at this point in the history
* origin/topic/timw/spicy-reformat:
  Remove ubuntu 22.10 build
  Update .git-blame-ignore-revs
  Add cmake-format and typos pre-commit configs
  Reformat C++ code in Spicy style
  • Loading branch information
timwoj committed Nov 6, 2023
2 parents 84b730f + 550376b commit 8fe24f8
Show file tree
Hide file tree
Showing 102 changed files with 9,273 additions and 11,080 deletions.
8 changes: 0 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ opensuse_tumbleweed_task:
<< : *CI_TEMPLATE
<< : *SKIP_TASK_ON_PR

ubuntu2210_task:
container:
# Ubuntu 22.10 EOL: July 2023
dockerfile: ci/ubuntu-22.10/Dockerfile
<< : *RESOURCES_TEMPLATE
<< : *CI_TEMPLATE
<< : *SKIP_TASK_ON_PR

ubuntu22_task:
container:
# Ubuntu 22.04 EOL: April 2027
Expand Down
170 changes: 108 additions & 62 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,74 +1,66 @@
# Clang-format configuration for Zeek. This configuration requires
# at least clang-format 12.0.1 to format correctly.

Language: Cpp
Standard: c++17

BreakBeforeBraces: Whitesmiths

# BraceWrapping:
# AfterCaseLabel: true
# AfterClass: false
# AfterControlStatement: Always
# AfterEnum: false
# AfterFunction: true
# AfterNamespace: false
# AfterStruct: false
# AfterUnion: false
# AfterExternBlock: false
# BeforeCatch: true
# BeforeElse: true
# BeforeWhile: false
# IndentBraces: true
# SplitEmptyFunction: false
# SplitEmptyRecord: false
# SplitEmptyNamespace: false
# Copyright (c) 2020-2023 by the Zeek Project. See LICENSE for details.

---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignTrailingComments: false
AllowShortBlocksOnASingleLine: Empty
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BreakConstructorInitializers: BeforeColon
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: false
FixNamespaceComments: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentExternBlock: NoIndent
IndentPPDirectives: None
IndentWidth: 4
NamespaceIndentation: None
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInConditionalStatement: true
SpacesInContainerLiterals: false
SpacesInParentheses: false
TabWidth: 4
UseTab: AlignWithSpaces

# Setting this to a high number causes clang-format to prefer breaking somewhere else
# over breaking after the assignment operator in a line that's over the column limit
PenaltyBreakAssignment: 100

BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: 'NOLINT'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup

# Include categories go like this:
Expand Down Expand Up @@ -98,3 +90,57 @@ IncludeCategories:
Priority: 4
- Regex: '.*'
Priority: 5

IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: '^BEGIN_'
MacroBlockEnd: '^END_'
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 500
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceAfterLogicalNot: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInConditionalStatement: true
Standard: Cpp11
StatementMacros:
- STANDARD_OPERATOR_1
TabWidth: 4
UseTab: Never
---
Language: Json
...
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Reformat C++ code in Spicy style
784f552ffc9eabfb14b8429ae892ff8ff8068cab

# Add cmake-format and typos pre-commit configs
047d69658c3ddb3bd369f9ee499432f9ee158eb4
24 changes: 20 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,33 @@
#
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v13.0.0'
rev: 'v17.0.3'
hooks:
- id: clang-format
types_or:
- "c"
- "c++"
- "json"

- repo: https://github.com/maxwinterstein/shfmt-py
rev: 3.3.1.8
rev: v3.7.0.1
hooks:
- id: shfmt
args: ["-w", "-i", "4", "-ci"]

- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.31.0
- repo: https://github.com/google/yapf
rev: v0.40.2
hooks:
- id: yapf

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
exclude: '^auxil/.*$'

- repo: https://github.com/crate-ci/typos
rev: v1.16.21
hooks:
- id: typos
exclude: '^(.typos.toml|src/SmithWaterman.cc|testing/.*|auxil/.*|scripts/base/frameworks/files/magic/.*|CHANGES)$'
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.61.0-16 | 2023-11-06 13:33:30 -0700

* Remove ubuntu 22.10 build (Tim Wojtulewicz, Corelight)

* Update .git-blame-ignore-revs (Tim Wojtulewicz, Corelight)

* Add cmake-format and typos pre-commit configs (Tim Wojtulewicz, Corelight)

* Reformat C++ code in Spicy style (Tim Wojtulewicz, Corelight)

0.61.0-11 | 2023-08-03 09:35:16 -0700

* Remove usage of FindRequiredPackage (Tim Wojtulewicz, Corelight)
Expand Down
70 changes: 34 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,48 @@ set(BINPAC_SOVERSION 0)

set(ENABLE_SHARED true)

if ( ENABLE_STATIC_ONLY )
if(ENABLE_STATIC_ONLY)
set(ENABLE_STATIC true)
set(ENABLE_SHARED false)
endif ()
endif()

# Set default install paths
include(GNUInstallDirs)

########################################################################
## Dependency Configuration
# ##############################################################################
# Dependency Configuration

find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)

if (MSVC)
if(MSVC)
add_compile_options(/J) # Similar to -funsigned-char on other platforms
endif()

########################################################################
## System Introspection
# ##############################################################################
# System Introspection

configure_file(${PROJECT_SOURCE_DIR}/config.h.in
${PROJECT_BINARY_DIR}/config.h)
configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)

include_directories(BEFORE ${PROJECT_BINARY_DIR})

########################################################################
## Recurse on sub-directories
# ##############################################################################
# Recurse on sub-directories

add_subdirectory(lib)
add_subdirectory(src)

########################################################################
## Build Summary
# ##############################################################################
# Build Summary

if (CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
endif ()
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
endif()

macro(display test desc summary)
if ( ${test} )
if(${test})
set(${summary} ${desc})
else ()
else()
set(${summary} no)
endif()
endmacro()
Expand All @@ -65,23 +64,22 @@ display(ENABLE_SHARED yes shared_summary)
display(ENABLE_STATIC yes static_summary)

message(
"\n==================| BinPAC Build Summary |===================="
"\nVersion: ${BINPAC_VERSION}"
"\nSO version: ${BINPAC_SOVERSION}"
"\n"
"\nBuild Type: ${CMAKE_BUILD_TYPE}"
"\nDebug mode: ${ENABLE_DEBUG}"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
"\nShared libs: ${shared_summary}"
"\nStatic libs: ${static_summary}"
"\n"
"\nCC: ${CMAKE_C_COMPILER}"
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
"\nCPP: ${CMAKE_CXX_COMPILER}"
"\n"
"\n================================================================\n"
)
"\n==================| BinPAC Build Summary |===================="
"\nVersion: ${BINPAC_VERSION}"
"\nSO version: ${BINPAC_SOVERSION}"
"\n"
"\nBuild Type: ${CMAKE_BUILD_TYPE}"
"\nDebug mode: ${ENABLE_DEBUG}"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
"\nShared libs: ${shared_summary}"
"\nStatic libs: ${static_summary}"
"\n"
"\nCC: ${CMAKE_C_COMPILER}"
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
"\nCPP: ${CMAKE_CXX_COMPILER}"
"\n"
"\n================================================================\n")

include(UserChangedWarning)
Loading

0 comments on commit 8fe24f8

Please sign in to comment.