-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_setup.bash
More file actions
97 lines (74 loc) · 2.47 KB
/
project_setup.bash
File metadata and controls
97 lines (74 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
PROJECT_HOME=$(cd "$(dirname "${BASH_SOURCE[0]}")" || return; pwd);
function build_project()
{
cmake -S "${PROJECT_HOME}" -B "${PROJECT_HOME}/build" "$@";
cd "${PROJECT_HOME}/build" || return;
make -j $(( $(grep -c ^processor /proc/cpuinfo) / 2 ));
cd ..;
}
function run_cppcheck()
{
cppcheck --enable=all --project=build/compile_commands.json --check-config -iForeignModules/* --std=c++20 --suppress=missingIncludeSystem -ibuild/* .;
}
function rebuild_project()
{
cd "${PROJECT_HOME}" || return;
rm -rf "${PROJECT_HOME}/build";
mkdir -p "${PROJECT_HOME}/build";
build_project "$@";
}
function _run_clang_tidy()
{
echo "Checking file $($1)"
}
function run_clang_tidy()
{
local paths=$(find "${PROJECT_HOME}" \
\( -name "*.cpp" -o -name "*.c" -o -name "*.cc" -o -name "*.hpp" \) \
-not \( -path "${PROJECT_HOME}/ForeignModules/*" -prune \) \
-not \( -path "${PROJECT_HOME}/build/*" -prune \) \
-print );
for path in $paths; do
[[ $# != 0 ]] && [[ ! "${path}" =~ $1 ]] && continue
printf "\033[1;34m\nChecking path '$path':\n\033[0m"
clang-tidy-14 -p "${PROJECT_HOME}/build" -config-file="${PROJECT_HOME}/.clang-tidy" -extra-arg=-std=c++20 -header-filter=".*" $path &> .cltid__
local output=$(cat .cltid__ | wc -l)
if [[ $output == 3 ]]
then
printf "\033[1;32mOK\033[0m\n"
else
cat .cltid__
fi
rm .cltid__
done
}
function apply_clang_format()
{
local paths=$(find "${PROJECT_HOME}" \
\( -name "*.cpp" -o -name "*.c" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" \) \
-not \( -path "${PROJECT_HOME}/ForeignModules/*" -prune \) \
-not \( -path "${PROJECT_HOME}/build/*" -prune \) \
-print );
for path in $paths; do
clang-format -n $path &> .clfor__
local output=$(cat .clfor__ | wc -l)
if [[ $output != 0 ]]
then
printf "Changed file \033[1;33m$path\033[0m\n"
clang-format -i $path
fi
rm .clfor__
done
}
function run_tests()
{
ctest --test-dir "${PROJECT_HOME}/build" --output-on-failure
}
function download_dependencies
{
cd "${PROJECT_HOME}"/ForeignModules || return
git clone --recursive "git@github.com:google/googletest.git"
git clone --recursive "https://github.com/fmtlib/fmt.git"
cd ..
}