-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean_cmake.sh
More file actions
executable file
·111 lines (70 loc) · 2.43 KB
/
Copy pathclean_cmake.sh
File metadata and controls
executable file
·111 lines (70 loc) · 2.43 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /bin/bash
ScriptPath=$0
Dir=$(cd "$(dirname "$ScriptPath")" && pwd)
Basename=$(basename "$ScriptPath")
CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build}
if [[ -n "$MSYSTEM" ]]; then
DefaultMakeCmd=mingw32-make.exe
else
DefaultMakeCmd=make
fi
MakeCmd=${SIS_CMAKE_MAKE_COMMAND:-${SIS_CMAKE_COMMAND:-$DefaultMakeCmd}}
ProjectNameFile="$Dir/.sis/project_name.txt"
ProjectName=$(tr -d '[:space:]' < "$ProjectNameFile")
# ##########################################################
# colours
if [ -n "${TERM:-}" ] && [ -t 1 ] && command -v tput >/dev/null 2>&1; then
SisClr_Blue=${FG_BLUE:-$(tput setaf 4)}
SisClr_Red=${FG_RED:-$(tput setaf 1)}
SisClr_Bold=${FD_BOLD:-$(tput bold)}
SisClr_None=${FD_NONE:-$(tput sgr0)}
else
SisClr_Blue=
SisClr_Red=
SisClr_Bold=
SisClr_None=
fi
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
case $1 in
--help)
[ -f "$Dir/.sis/script_info_lines.txt" ] && cat "$Dir/.sis/script_info_lines.txt"
cat << EOF
Executes CMake-generated artefacts to clean project
$ScriptPath [ ... flags/options ... ]
Flags/options:
behaviour:
standard flags:
--help
displays this help and terminates
EOF
exit 0
;;
*)
>&2 echo "$ScriptPath: ${SisClr_Red}${SisClr_Bold}unrecognised argument '$1'${SisClr_None}; use --help for usage"
exit 1
;;
esac
shift
done
# ##########################################################
# main()
if [ ! -d "$CMakeDir" ]; then
>&2 echo "$ScriptPath: ${SisClr_Red}${SisClr_Bold}CMake build directory '$CMakeDir' not found${SisClr_None} so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts"
exit 1
else
cd $CMakeDir
if [ ! -f "$CMakeDir/Makefile" ]; then
>&2 echo "$ScriptPath: ${SisClr_Red}${SisClr_Bold}CMake build directory '$CMakeDir' does not contain expected file 'Makefile'${SisClr_None}, so a clean cannot be performed. It is recommended that you remove all CMake artefacts using script 'remove_cmake_artefacts.sh' followed by regeneration via 'prepare_cmake.sh'"
cd ->/dev/null
exit 1
else
echo "Cleaning ${SisClr_Blue}${SisClr_Bold}${ProjectName}${SisClr_None} (via command \`${SisClr_Blue}${SisClr_Bold}$MakeCmd clean${SisClr_None}\`)"
$MakeCmd clean
status=$?
cd ->/dev/null
exit $status
fi
fi
# ############################## end of file ############################# #