-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_cmake.sh
executable file
·124 lines (75 loc) · 2.35 KB
/
build_cmake.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
#! /bin/bash
ScriptPath=$0
Dir=$(cd $(dirname "$ScriptPath"); pwd)
Basename=$(basename "$ScriptPath")
CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build}
MakeCmd=${SIS_CMAKE_COMMAND:-make}
IgnoreRemainingFlagsAndOptions=0
Targets=()
# ##########################################################
# functions
function join_by { local IFS="$1"; shift; echo "$*"; }
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
if [ $IgnoreRemainingFlagsAndOptions -ne 0 ]; then
Targets+=($1)
shift
continue
else
if [ ! ${1:0:1} = '-' ]; then
Targets+=($1)
shift
continue
fi
fi
case $1 in
--)
IgnoreRemainingFlagsAndOptions=1
;;
--help)
cat << EOF
b64 is a small and simple standalone C-language library that provides Base-64 encoding and decoding
Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
Copyright (c) 2004-2019, Matthew Wilson and Synesis Software
Executes CMake-generated artefacts to (re)build project
$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
>&2 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 1
else
cd $CMakeDir
if [ ! -f "$CMakeDir/Makefile" ]; then
>&2 echo "$ScriptPath: CMake build directory '$CMakeDir' does not contain expected file 'Makefile', 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
if [ -z "$Targets" ]; then
echo "Executing build (via command \`$MakeCmd\`)"
else
echo "Executing build (via command \`$MakeCmd\`) with specific target(s) $(join_by , "${Targets[@]}")"
fi
$MakeCmd ${Targets[*]}
status=$?
cd ->/dev/null
exit $status
fi
fi
# ############################## end of file ############################# #