-
Notifications
You must be signed in to change notification settings - Fork 3
/
remove_cmake_artefacts.sh
executable file
·153 lines (103 loc) · 2.47 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#! /bin/bash
ScriptPath=$0
Dir=$(cd $(dirname "$ScriptPath"); pwd)
Basename=$(basename "$ScriptPath")
CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build}
Directories=(
CMakeFiles
Testing
cmake
examples
projects
src
test
)
Files=(
CMakeCache.txt
CTestTestfile.cmake
DartConfiguration.tcl
Makefile
cmake_install.cmake
install_manifest.txt
)
# ##########################################################
# operating environment detection
OsName="$(uname -s)"
case "${OsName}" in
CYGWIN*|MINGW*|MSYS_NT*)
Directories+=(
ARM64
Win32
x64
)
Files+=(
"*.filters"
"*.sln"
"*.vcxproj"
)
;;
*)
;;
esac
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
case $1 in
--help)
cat << EOF
recls is a platform-independent recursive file-system search library
Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
Copyright (c) 2003-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 "$CMakeDir" ]; then
echo "$ScriptPath: CMake build directory '$CMakeDir' 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 '$CMakeDir'"
num_dirs_removed=0
num_files_removed=0
for d in ${Directories[@]}
do
fq_dir_path="$CMakeDir/$d"
[ -d "$fq_dir_path" ] || continue
echo "removing directory '$d'"
rm -dfr "$fq_dir_path"
num_dirs_removed=$((num_dirs_removed+1))
done
cd "$CMakeDir"
for f in ${Files[@]}
do
for fq_file_path in $f
do
[ -f "$fq_file_path" ] || continue
echo "removing file '$fq_file_path'"
rm -f "$fq_file_path"
num_files_removed=$((num_files_removed+1))
done
done
cd ->/dev/null
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 ############################# #