mirror of
https://github.com/polybar/polybar.git
synced 2024-11-11 13:50:56 -05:00
fix(cmake): Tidy and format commands
This commit is contained in:
parent
19868041e1
commit
0128014d44
4 changed files with 76 additions and 20 deletions
21
.clang-tidy
21
.clang-tidy
|
@ -1,6 +1,23 @@
|
|||
---
|
||||
Checks: 'clang-analyzer-core-*,clang-analyzer-nullability-*,clang-analyzer-unix-*,cppcoreguidelines-*,modernize-*,performance-*,readability-*'
|
||||
WarningsAsErrors: ''
|
||||
Checks: '-*,performance-faster-string-find,performance-for-range-copy,readability-*,modernize-*,-modernize-raw-string-literal,-modernize-use-bool-literals,-readability-implicit-bool-cast,-readability-else-after-return,-readability-named-parameter'
|
||||
CheckOptions:
|
||||
- key: modernize-loop-convert.NamingStyle
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.GlobalConstantPrefix
|
||||
value: 'g_'
|
||||
- key: readability-identifier-naming.ClassCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.ClassConstantCase
|
||||
value: UPPER_CASE
|
||||
- key: readability-identifier-naming.ClassMethodCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.MemberCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.ProtectedMemberPrefix
|
||||
value: 'm_'
|
||||
- key: readability-identifier-naming.PrivateMemberPrefix
|
||||
value: 'm_'
|
||||
HeaderFilterRegex: ''
|
||||
WarningsAsErrors: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
...
|
||||
|
|
|
@ -24,27 +24,24 @@ add_custom_target(uninstall COMMAND ${CMAKE_COMMAND}
|
|||
-P ${PROJECT_BINARY_DIR}/cmake/uninstall.cmake)
|
||||
|
||||
# }}}
|
||||
# Target: clang-format {{{
|
||||
# Target: codeformat (clang-format) {{{
|
||||
|
||||
find_program(CLANG_FORMAT "clang-format")
|
||||
|
||||
if(CLANG_FORMAT)
|
||||
file(GLOB_RECURSE HEADERS ${PROJECT_SOURCE_DIR}/include/*.hpp)
|
||||
file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
|
||||
add_custom_target(clang-format COMMAND ${CLANG_FORMAT}
|
||||
-i -style=file ${HEADERS} ${SOURCES})
|
||||
endif()
|
||||
|
||||
find_program(CLANG_TIDY "clang-tidy")
|
||||
add_custom_target(codeformat)
|
||||
add_custom_command(TARGET codeformat COMMAND
|
||||
${PROJECT_SOURCE_DIR}/common/clang-format.sh ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
# }}}
|
||||
# Target: clang-tidy {{{
|
||||
# Target: codecheck (clang-tidy) {{{
|
||||
|
||||
if(CLANG_TIDY)
|
||||
add_custom_target(clang-tidy
|
||||
COMMAND ${CLANG_TIDY} -p
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src/main.cpp)
|
||||
endif()
|
||||
add_custom_target(codecheck)
|
||||
add_custom_command(TARGET codecheck COMMAND
|
||||
${PROJECT_SOURCE_DIR}/common/clang-tidy.sh ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
# }}}
|
||||
# Target: codecheck-fix (clang-tidy + clang-format) {{{
|
||||
|
||||
add_custom_target(codecheck-fix)
|
||||
add_custom_command(TARGET codecheck-fix COMMAND
|
||||
${PROJECT_SOURCE_DIR}/common/clang-tidy.sh ${PROJECT_BINARY_DIR} -fix ${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
# }}}
|
||||
|
|
19
common/clang-format.sh
Executable file
19
common/clang-format.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
main() {
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "$0 DIR..." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
search="${*:-.}"
|
||||
|
||||
[ -d "$search" ] || search="$(dirname "$search")"
|
||||
|
||||
# shellcheck disable=2086
|
||||
find $search -regex ".*.[c|h]pp" \
|
||||
-exec printf "\033[32;1m** \033[0mFormatting %s\n" {} \; \
|
||||
-exec clang-format -style=file -i {} \;
|
||||
}
|
||||
|
||||
main "$@"
|
23
common/clang-tidy.sh
Executable file
23
common/clang-tidy.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
main() {
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "$0 [build_path] [-fix] DIR..." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="-p $1"; shift
|
||||
|
||||
if [ "$1" = "-fix" ]; then
|
||||
args="${args} -fix"; shift
|
||||
fi
|
||||
|
||||
# shellcheck disable=2086
|
||||
find "${@:-.}" -regex ".*.[c|h]pp" \
|
||||
-exec printf "\033[32;1m** \033[0mProcessing %s\n" {} \; \
|
||||
-exec clang-tidy $args {} \; \
|
||||
-exec printf "\033[32;1m** \033[0mFormatting %s\n" {} \; \
|
||||
-exec clang-format -style=file -i {} \;
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in a new issue