mirror of https://github.com/procxx/kepka.git
Add clang-format target to CMake and Travis
This commit is contained in:
parent
80071b61d5
commit
b3cdb38c0b
|
@ -0,0 +1,43 @@
|
||||||
|
---
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlinesLeft: false
|
||||||
|
AlignEscapedNewlines: false
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 120
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentWidth: 4
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
NamespaceIndentation: None
|
||||||
|
PointerAlignment: Right
|
||||||
|
SortIncludes: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
Standard: Cpp11
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: ForIndentation
|
||||||
|
ForEachMacros: [ for_const, foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||||
|
...
|
|
@ -3,5 +3,8 @@
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE $EXTRA_CMAKE_FLAGS -DBUILD_TESTING=ON .. || exit 1
|
cmake -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE $EXTRA_CMAKE_FLAGS -DBUILD_TESTING=ON .. || exit 1
|
||||||
|
# grep returns number of items found. each change is enclosed into <replacement>
|
||||||
|
# tag in the xml. Thus if no changes needed, 0 will be returned
|
||||||
|
cmake --build . --target clang-format-ci -- -v | grep -c "<replacement " && exit 1
|
||||||
cmake --build . -- -v || exit 1
|
cmake --build . -- -v || exit 1
|
||||||
ASAN_OPTIONS=alloc_dealloc_mismatch=0 ctest . || exit 1
|
ASAN_OPTIONS=alloc_dealloc_mismatch=0 ctest . || exit 1
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||||
docker run --rm -v $PWD:/repo -v ~/.travis:/travis berkus/docker-cpp-ci /bin/sh -c "cd /repo/_build_; conan install .. --build missing; /repo/.travis/build.sh"
|
docker run --rm -v $PWD:/repo -v ~/.travis:/travis berkus/docker-cpp-ci /bin/sh -c "cd /repo/_build_; conan install .. --build missing; /repo/.travis/build.sh" || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||||
|
@ -12,5 +12,5 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||||
export CXX=clang++
|
export CXX=clang++
|
||||||
export EXTRA_CMAKE_FLAGS=-DCMAKE_PREFIX_PATH='/usr/local/opt/qt5/;/usr/local/opt/openal-soft'
|
export EXTRA_CMAKE_FLAGS=-DCMAKE_PREFIX_PATH='/usr/local/opt/qt5/;/usr/local/opt/openal-soft'
|
||||||
conan install -s compiler=apple-clang .. --build missing
|
conan install -s compiler=apple-clang .. --build missing
|
||||||
../.travis/build.sh
|
../.travis/build.sh || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -73,3 +73,6 @@ if (CCACHE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(Telegram)
|
add_subdirectory(Telegram)
|
||||||
|
|
||||||
|
# clang-format
|
||||||
|
include(modules/clang-cxx-dev-tools.cmake)
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
# http://www.labri.fr/perso/fleury/posts/programming/using-clang-tidy-and-clang-format.html
|
||||||
|
|
||||||
|
# Additional target to perform clang-format/clang-tidy run
|
||||||
|
# Requires clang-format and clang-tidy
|
||||||
|
file(GLOB_RECURSE
|
||||||
|
ALL_CXX_SOURCE_FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Telegram/SourceFiles/*.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Telegram/SourceFiles/*.h
|
||||||
|
)
|
||||||
|
set(clang-format "clang-format")
|
||||||
|
|
||||||
|
# Adding clang-format target if executable is found
|
||||||
|
find_program(CLANG_FORMAT "clang-format")
|
||||||
|
if(CLANG_FORMAT)
|
||||||
|
add_custom_target(
|
||||||
|
clang-format
|
||||||
|
COMMAND clang-format
|
||||||
|
-i
|
||||||
|
-style=file
|
||||||
|
${ALL_CXX_SOURCE_FILES}
|
||||||
|
)
|
||||||
|
add_custom_target(
|
||||||
|
clang-format-ci
|
||||||
|
COMMAND clang-format
|
||||||
|
-output-replacements-xml
|
||||||
|
-style=file
|
||||||
|
${ALL_CXX_SOURCE_FILES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Adding clang-tidy target if executable is found
|
||||||
|
find_program(CLANG_TIDY "clang-tidy")
|
||||||
|
if(CLANG_TIDY)
|
||||||
|
add_custom_target(
|
||||||
|
clang-tidy
|
||||||
|
COMMAND /usr/bin/clang-tidy
|
||||||
|
${ALL_CXX_SOURCE_FILES}
|
||||||
|
-config=''
|
||||||
|
--
|
||||||
|
-std=c++11
|
||||||
|
${INCLUDE_DIRECTORIES}
|
||||||
|
)
|
||||||
|
endif()
|
Loading…
Reference in New Issue