-
Notifications
You must be signed in to change notification settings - Fork 21
/
build-all
executable file
·235 lines (187 loc) · 6.12 KB
/
build-all
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
#
# Script to build all (or most) libyui subprojects in the correct order.
#
# This script is intentionally kept in the project toplevel directory
# so it is easy to discover.
#
# Author: Stefan Hundhammer <shundhammer@suse.com>
# License: GPL V2
script_name=$(basename $0)
keep_going=0
error_count=0
dry_run=0
verbose=0
# subprojects that will or will not be built
with_qt=1
with_ncurses=1
with_pkg=1
with_graph=1
with_rest_api=0
with_bindings=0
# Show usage information and exit.
function usage()
{
cat <<EOF
Usage:
$script_name [Options] [configure|build|install|clean|doc]
Build all (or most) libyui subprojects in the correct order.
Without options, this builds the 'typical' set of subprojects.
To see which ones that are, use
./$script_name -n
If invoked without any target argument, this script just executes 'make' in
each subproject that already has a build/ subdirectory. For subprojects
without such a build/ subdirectory, it behaves as if invoked with 'build'.
Notice that for installing, you need to call this with root privileges, i.e.
sudo ./$script_name install
To build with an installation prefix, set CMAKE_INSTALL_PREFIX in the
environment:
export CMAKE_INSTALL_PREFIX=/usr/local
./$script_name
Options:
Component selection:
-a, --all Build with all subprojects
-s, --small Small build: libyui, -qt, -ncurses
-b, --bindings Build with bindings
--no-bindings Build without bindings (useful for -a)
-r, --rest-api Build with rest-api
-p, --no-pkg Build without pkg
-g, --no-graph Build without graph
-q, --no-qt Build without Qt
-c, --no-ncurses Build without NCurses
Other Options:
-n, --dry-run Don't actually execute the commands, just show them
-k, --keep-going Don't stop upon error
-v, --verbose More messages
-h, --help Show this usage message
EOF
exit 2
}
# Process the command line and set some variables based on command line options.
function process_command_line()
{
# Using GNU getopt, not bash builtin getopts for long options support.
# Don't split the long options over multiple lines:
# No whitespace in the list allowed!
options=$(getopt -o asqcpgrbkvhn \
-l all,small,bindings,no-bindings,rest-api,no-pkg,no-graph,no-qt,no-ncurses,help,usage,dry-run,verbose \
-n $script_name \
-- $*)
# $? is the exit status of 'getopt'
test $? -eq 0 || usage
# Handle shell escaping (see man 1 getopt)
eval set -- "$options"
while true ; do
case "$1" in
-a | --all )
with_qt=1
with_ncurses=1
with_pkg=1
with_graph=1
with_rest_api=1
with_bindings=1
shift
;;
-s | --small )
with_qt=1
with_ncurses=1
with_pkg=0
with_graph=0
with_rest_api=0
with_bindings=0
shift
;;
-q | --no-qt ) with_qt=0 ; shift ;;
-c | --no-ncurses ) with_ncurses=0 ; shift ;;
-p | --no-pkg ) with_pkg=0 ; shift ;;
-g | --no-graph ) with_graph=0 ; shift ;;
-r | --rest-api ) with_rest_api=1 ; shift ;;
-b | --bindings ) with_bindings=1 ; shift ;;
--no-bindings ) with_bindings=0 ; shift ;;
-k | --keep-going ) keep_going=1 ; shift ;;
-v | --verbose ) verbose=1 ; shift ;;
-h | --help ) usage ; shift ;;
-n | --dry-run )
dry_run=1
echo ""
echo "*** Dry run - not executing any make commands ***"
echo ""
shift
;;
-- ) shift; break ;;
*) break ;;
esac
done
# Don't fall back to "build" here yet, this is done in build_subdir()
# for each subproject individually depending on an existing build/ subdir.
target=$1
}
# Build in one subdir / subproject
function build_subdir()
{
subdir=$1
if [ -z "$target" -a -f $subdir/build/Makefile ]; then
# Without a target explicitly specified on the command line, don't
# force removing everything that is already built in this subproject,
# just try "make" there if there already is a build/ subdirectory.
cmd="make -C $subdir/build -j$(nproc)"
else
tgt=${target:-build}
cmd="make -C $subdir -f Makefile.repo $tgt"
fi
echo "$cmd"
if [ $dry_run -eq 0 ]; then
# Execute the command
$cmd
if [ $? -ne 0 ]; then
echo "*** ERROR in $subdir"
let error_count++
test $keep_going -eq 1 || exit 1
fi
fi
}
# Dump status variables to stdout
function dump_status()
{
echo "with_qt: $with_qt"
echo "with_ncurses: $with_ncurses"
echo "with_pkg: $with_pkg"
echo "with_graph: $with_graph"
echo "with_rest_api: $with_rest_api"
echo "with_bindings: $with_bindings"
echo "keep_going: $keep_going"
echo "Target: ${target:-(auto)}"
echo ""
}
#----------------------------------------------------------------------
# main()
#----------------------------------------------------------------------
process_command_line $*
test $verbose -eq 1 && dump_status
#
# Build subprojects
#
# The libyui base lib is always built unconditionally
build_subdir libyui
if [ $with_qt -eq 1 ]; then
build_subdir libyui-qt
test $with_graph -eq 1 && build_subdir libyui-qt-graph
test $with_pkg -eq 1 && build_subdir libyui-qt-pkg
fi
if [ $with_ncurses -eq 1 ]; then
build_subdir libyui-ncurses
test $with_pkg -eq 1 && build_subdir libyui-ncurses-pkg
fi
if [ $with_rest_api -eq 1 ]; then
build_subdir libyui-rest-api
test $with_qt -eq 1 && build_subdir libyui-qt-rest-api
test $with_ncurses -eq 1 && build_subdir libyui-ncurses-rest-api
fi
test $with_bindings -eq 1 && build_subdir libyui-bindings
# error summary
if [ $error_count -gt 0 ]; then
echo ""
echo "*** $script_name: Error count: $error_count ***"
echo ""
exit 1
fi