/
remove_cmake_artefacts.sh
executable file
·118 lines (80 loc) · 2.26 KB
/
remove_cmake_artefacts.sh
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /bin/bash
ScriptPath=$0
Dir=$(cd $(dirname "$ScriptPath"); pwd)
Basename=$(basename "$ScriptPath")
CMakePath=$Dir/_build
Directories=(
CMakeFiles
Testing
cmake
examples
projects
src
test
)
Files=(
CMakeCache.txt
CTestTestfile.cmake
DartConfiguration.tcl
Makefile
cmake_install.cmake
install_manifest.txt
)
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
case $1 in
--help)
cat << EOF
CLASP is a small, simple C-language library for parsing command-line arguments, along with a C++ header-only API.
Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
Copyright (c) 2008-2019, Matthew Wilson and Synesis Software
Removes all known CMake artefacts
$ScriptPath [ ... flags/options ... ]
Flags/options:
behaviour:
standard flags:
--help
displays this help and terminates
EOF
exit 0
;;
*)
>&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage"
exit 1
;;
esac
shift
done
# ##########################################################
# main()
if [ ! -d "$CMakePath" ]; then
echo "$ScriptPath: CMake build directory '$CMakePath' not found so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts"
exit 0
else
echo "Removing all cmake artefacts in '$CMakePath'"
num_dirs_removed=0
num_files_removed=0
for d in ${Directories[@]}
do
fq_dir_path="$CMakePath/$d"
[ -d "$fq_dir_path" ] || continue
echo "removing directory '$d'"
rm -dfr "$fq_dir_path"
num_dirs_removed=$((num_dirs_removed+1))
done
for f in ${Files[@]}
do
fq_file_path="$CMakePath/$f"
[ -f "$fq_file_path" ] || continue
echo "removing file '$f'"
rm -f "$fq_file_path"
num_files_removed=$((num_files_removed+1))
done
if [ 0 -eq $num_dirs_removed ] && [ 0 -eq $num_files_removed ]; then
echo "nothing to do"
else
echo "removed $num_dirs_removed directories and $num_files_removed files"
fi
fi
# ############################## end of file ############################# #