mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 07:49:50 -05:00
Improve clang-format performance
This commit is contained in:
parent
7ff8720a39
commit
c198541b6f
@ -15,48 +15,45 @@
|
|||||||
|
|
||||||
set(EXCLUDED_DIRS
|
set(EXCLUDED_DIRS
|
||||||
# third-party directories
|
# third-party directories
|
||||||
src/thirdparty/
|
src/thirdparty
|
||||||
src/zxcvbn/
|
src/zxcvbn
|
||||||
# objective-c directories
|
# objective-c directories
|
||||||
src/touchid/
|
src/touchid
|
||||||
src/autotype/mac/
|
src/autotype/mac
|
||||||
src/gui/osutils/macutils/)
|
src/gui/osutils/macutils)
|
||||||
|
|
||||||
set(EXCLUDED_FILES
|
set(EXCLUDED_FILES
|
||||||
# third-party files
|
# third-party files
|
||||||
streams/qtiocompressor.cpp
|
src/streams/qtiocompressor.\\*
|
||||||
streams/qtiocompressor.h
|
src/gui/KMessageWidget.\\*
|
||||||
gui/KMessageWidget.h
|
src/gui/MainWindowAdaptor.\\*
|
||||||
gui/KMessageWidget.cpp
|
tests/modeltest.\\*
|
||||||
gui/MainWindowAdaptor.h
|
|
||||||
gui/MainWindowAdaptor.cpp
|
|
||||||
tests/modeltest.cpp
|
|
||||||
tests/modeltest.h
|
|
||||||
# objective-c files
|
# objective-c files
|
||||||
core/ScreenLockListenerMac.h
|
src/core/ScreenLockListenerMac.\\*)
|
||||||
core/ScreenLockListenerMac.cpp)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE ALL_SOURCE_FILES RELATIVE ${CMAKE_SOURCE_DIR} src/*.cpp src/*.h tests/*.cpp tests/*.h)
|
set(FIND_EXCLUDE_DIR_EXPR "")
|
||||||
foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
|
foreach(EXCLUDE ${EXCLUDED_DIRS})
|
||||||
foreach(EXCLUDED_DIR ${EXCLUDED_DIRS})
|
list(APPEND FIND_EXCLUDE_DIR_EXPR -o -path "${EXCLUDE}" -prune)
|
||||||
string(FIND ${SOURCE_FILE} ${EXCLUDED_DIR} SOURCE_FILE_EXCLUDED)
|
|
||||||
if(NOT ${SOURCE_FILE_EXCLUDED} EQUAL -1)
|
|
||||||
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
foreach(EXCLUDED_FILE ${EXCLUDED_FILES})
|
|
||||||
if(${SOURCE_FILE} MATCHES ".*${EXCLUDED_FILE}$")
|
|
||||||
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(FIND_EXCLUDE_FILE_EXPR "")
|
||||||
|
foreach(EXCLUDE ${EXCLUDED_FILES})
|
||||||
|
if(FIND_EXCLUDE_FILE_EXPR)
|
||||||
|
list(APPEND FIND_EXCLUDE_FILE_EXPR -o)
|
||||||
|
endif()
|
||||||
|
list(APPEND FIND_EXCLUDE_FILE_EXPR -path "${EXCLUDE}")
|
||||||
|
endforeach()
|
||||||
|
if(FIND_EXCLUDE_FILE_EXPR)
|
||||||
|
set(FIND_EXCLUDE_FILE_EXPR -a -not "\\(" ${FIND_EXCLUDE_FILE_EXPR} "\\)")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_target(format)
|
add_custom_target(format)
|
||||||
foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET format
|
TARGET format
|
||||||
PRE_BUILD
|
PRE_BUILD
|
||||||
COMMAND echo Formatting ${SOURCE_FILE}
|
COMMAND find src tests "\\(" -name "\\*.h" -o -name "\\*.cpp" ${FIND_EXCLUDE_DIR_EXPR} "\\)"
|
||||||
COMMAND clang-format -style=file -i \"${SOURCE_FILE}\"
|
${FIND_EXCLUDE_FILE_EXPR} -type f -print0 | xargs -0 -P0 -n10 clang-format -style=file -i
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
||||||
endforeach()
|
COMMENT "Formatting source files..."
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
Loading…
Reference in New Issue
Block a user