Fix formatting and formatting scripts

This commit is contained in:
kas 2022-10-16 17:35:23 +02:00
parent 3ce19698df
commit 1687f44dc7
3 changed files with 14 additions and 8 deletions

View File

@ -1,9 +1,11 @@
#!/bin/bash
cd "`dirname "$0"`"
# Variable that will hold the name of the clang-format command
FMT=""
FOLDERS=("src" "test")
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
@ -23,7 +25,7 @@ if [ -z "$FMT" ]; then
fi
function format() {
for f in $(find $@ -name '*.h' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp'); do
for f in $(find $@ \( -type d -path './test/dep/*' -prune \) -o \( -name '*.h' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp' \)); do
echo "format ${f}";
${FMT} -i ${f};
done
@ -31,7 +33,6 @@ function format() {
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";
@ -42,4 +43,7 @@ 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 {} + \)
find . \
\( -type d -path './test/dep/*' -prune \) \
-o \( -type d -path './dep/*/*' -prune \) \
-o \( -name CMakeLists.txt -exec cmake-format --in-place {} + \)

1
cmake-format.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -12,9 +12,10 @@ add_library(
target_link_libraries(host conf cred Qt5::Core Qt5::Gui Qt5::Network)
target_compile_definitions(
host PRIVATE GITHUB_CLIENT_ID="${GITHUB_CLIENT_ID}"
GITHUB_CLIENT_SECRET="${GITHUB_CLIENT_SECRET}"
GITEA_CLIENT_ID="${GITEA_CLIENT_ID}"
GITEA_CLIENT_SECRET="${GITEA_CLIENT_SECRET}")
host
PRIVATE GITHUB_CLIENT_ID="${GITHUB_CLIENT_ID}"
GITHUB_CLIENT_SECRET="${GITHUB_CLIENT_SECRET}"
GITEA_CLIENT_ID="${GITEA_CLIENT_ID}"
GITEA_CLIENT_SECRET="${GITEA_CLIENT_SECRET}")
set_target_properties(host PROPERTIES AUTOMOC ON)