Skip to content

Commit

Permalink
Merge pull request #107 from Murmele/styleChecker
Browse files Browse the repository at this point in the history
add styleChecker Action
  • Loading branch information
Murmele authored May 1, 2022
2 parents ffe1b21 + 9bd7422 commit f38eb16
Show file tree
Hide file tree
Showing 372 changed files with 15,459 additions and 20,506 deletions.
178 changes: 178 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
ShortNamespaceLines: 1
SortIncludes: false
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ env:


jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '13'
exclude-regex: 'dep'

- name: Check CMake code style
run: |
pip install cmake-format==0.6.13 && \
find \( -type d -path './dep/*/*' -prune \) -o \( -name CMakeLists.txt -exec cmake-format --check {} + \)
flatpak:
name: "Flatpak"
runs-on: ubuntu-latest
Expand Down
63 changes: 35 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ set(GITTYUP_VERSION_MAJOR 1)
set(GITTYUP_VERSION_MINOR 1)
set(GITTYUP_VERSION_PATCH 0)
set(GITTYUP_VERSION
"${GITTYUP_VERSION_MAJOR}.${GITTYUP_VERSION_MINOR}.${GITTYUP_VERSION_PATCH}"
"${GITTYUP_VERSION_MAJOR}.${GITTYUP_VERSION_MINOR}.${GITTYUP_VERSION_PATCH}"
)

# Write version to file so it can be used also from external, for example
# in the github manifest
# Write version to file so it can be used also from external, for example in the
# github manifest
file(WRITE "${CMAKE_BINARY_DIR}/Version.txt" ${GITTYUP_VERSION})

set(DEV_BUILD "" CACHE STRING "Mark this build as a development build with the given description")
set(DEV_BUILD
""
CACHE STRING
"Mark this build as a development build with the given description")

if (DEV_BUILD)
if(DEV_BUILD)
set(BUILD_DESCRIPTION " (development build: ${DEV_BUILD})")
else()
set(BUILD_DESCRIPTION "")
Expand All @@ -29,10 +32,10 @@ string(TIMESTAMP GITTYUP_BUILD_DATE)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git show -s --format=%h HEAD
COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git show -s
--format=%h HEAD
OUTPUT_VARIABLE GITTYUP_BUILD_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(GITTYUP_BUILD_REVISION "unknown")
endif()
Expand All @@ -52,39 +55,43 @@ endif()

# Find Qt modules.
set(QT_MODULES
Concurrent
Core
Gui
Network
PrintSupport
Widgets
Test
)
Concurrent
Core
Gui
Network
PrintSupport
Widgets
Test)

if(UNIX)
set(QT_MODULES ${QT_MODULES} DBus)
endif()

find_package(Qt5 5.12 COMPONENTS ${QT_MODULES} LinguistTools REQUIRED)
if (FLATPAK)
find_package(Qt5 5.15 COMPONENTS XcbQpa REQUIRED)
add_compile_definitions(FLATPAK)
find_package(
Qt5 5.12
COMPONENTS ${QT_MODULES} LinguistTools
REQUIRED)
if(FLATPAK)
find_package(
Qt5 5.15
COMPONENTS XcbQpa
REQUIRED)
add_compile_definitions(FLATPAK)
endif()

set(QT_TRANSLATIONS_DIR "${Qt5_DIR}/../../../translations")
set(QT_TRANSLATIONS_DIR "/usr/share/qt/translations")

if(APPLE)
foreach(QT_MODULE ${QT_MODULES})
# FIXME: Force debug build to link against release libraries
# inside of frameworks on macOS. The Qt debug libraries are
# broken because their link dependencies are to the release
# libraries (e.g. QtGui_debug depends on QtCore). This causes
# multiple symbol definition errors at application load time.
# FIXME: Force debug build to link against release libraries inside of
# frameworks on macOS. The Qt debug libraries are broken because their link
# dependencies are to the release libraries (e.g. QtGui_debug depends on
# QtCore). This causes multiple symbol definition errors at application load
# time.
get_target_property(LOCATION Qt5::${QT_MODULE} LOCATION)
set_target_properties(Qt5::${QT_MODULE} PROPERTIES
IMPORTED_LOCATION_DEBUG ${LOCATION}
)
set_target_properties(Qt5::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG
${LOCATION})
endforeach()
endif()

Expand Down
45 changes: 45 additions & 0 deletions cl-fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Variable that will hold the name of the clang-format command
FMT=""

FOLDERS=("src" "test")

# Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent
# that the version number be part of the command. We prefer clang-format if
# that's present, otherwise we work backwards from highest version to lowest
# version but at least 13.
for clangfmt in clang-format{,-{1,2,3}{9,8,7,6,5,4,3}}; do
if which "$clangfmt" &>/dev/null; then
FMT="$clangfmt"
break
fi
done

# Check if we found a working clang-format
if [ -z "$FMT" ]; then
echo "failed to find clang-format"
exit 1
fi

function format() {
for f in $(find $@ -name '*.h' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp'); do
echo "format ${f}";
${FMT} -i ${f};
done

echo "~~~ $@ Done ~~~";
}

# Check all of the arguments first to make sure they're all directories
for dir in ${FOLDERS[@]}; do
if [ ! -d "${dir}" ]; then
echo "${dir} is not a directory";
else
format ${dir};
fi
done

echo "Start formatting cmake files"
pip install cmake-format==0.6.13
find \( -type d -path './dep/*/*' -prune \) -o \( -name CMakeLists.txt -exec cmake-format --in-place {} + \)
2 changes: 1 addition & 1 deletion dep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_subdirectory(libgit2)
add_subdirectory(cmark)
add_subdirectory(lua)
if(NOT LUA_FOUND)
add_subdirectory(lpeg)
add_subdirectory(lpeg)
endif()
add_subdirectory(scintilla)

Expand Down
20 changes: 13 additions & 7 deletions dep/cmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBCMARK libcmark)
endif()
if(NOT LIBCMARK_FOUND)
set(CMARK_TESTS OFF CACHE BOOL "" FORCE)
set(CMARK_SHARED OFF CACHE BOOL "" FORCE)
set(CMARK_TESTS
OFF
CACHE BOOL "" FORCE)
set(CMARK_SHARED
OFF
CACHE BOOL "" FORCE)

add_subdirectory(cmark)
target_include_directories(libcmark_static INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmark/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/cmark/src>
)
set(LIBCMARK_LIBRARIES libcmark_static CACHE INTERNAL "libcmark implementation" FORCE)
target_include_directories(
libcmark_static
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmark/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/cmark/src>)
set(LIBCMARK_LIBRARIES
libcmark_static
CACHE INTERNAL "libcmark implementation" FORCE)
endif()
Loading

0 comments on commit f38eb16

Please sign in to comment.