-
Notifications
You must be signed in to change notification settings - Fork 2
/
autogen.sh
executable file
·551 lines (474 loc) · 18.5 KB
/
autogen.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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#! /bin/sh
#====================================================================
# A few helper functions
#====================================================================
# Usage function
usage()
{
cat << EOF
usage: $0 [OPTIONS]
This script builds [and runs the test suite of] SciCell++
OPTIONS:
-h Show this message
-t Indicates to generate a 'STATIC' or 'SHARED' version of library files
-b Build version 'DEBUG' or 'RELEASE'
-c Configuration file for additional building tools
-n Number of processors to build the framework
-d Number of processors to run demos (set to '0' to skip demos testing)
-i Interative mode, launches the interactive mode to prompt for FULL configuration options (any other parameters are ignored)
-r Generate code coverage report
-v Verbose
EOF
}
# An small function 'borrowed' from the oomph-lib installation
# script...
OptionPrompt()
{
printf "%s " "$1"
}
# Another small function 'borrowed' from the oomph-lib installation
# script...
OptionRead()
{
read Opt
if test "$Opt" = "" ; then
Opt=$1
fi
echo $Opt
}
#====================================================================
# Variables (and default values)
#====================================================================
build_dir=build
src_dir=src
external_src_dir=external_src
# The name of the library
lib_name=SciCell++
# The extension of the library is given by the choosing of STATIC or
# SHARED library
#lib_ext=*
# The type of the library is given by the choosing of STATIC or SHARED
# library
lib_type=STATIC
# The version of the library is given by whether the user choose to
# build the DEBUG or the RELEASE version of the library
lib_build=DEBUG
# Indicates the configuration file with variables for paths for
# external libraries
configuration_file=./configs/current
# Indicates the number of processors to build the library
default_number_of_processors_to_build_library=4
number_of_processors_to_build_library=$default_number_of_processors_to_build_library
# Indicates whether to build/compile test demos
build_test_demos=TRUE
# Indicates the number of processors to build the demos
default_number_of_processors_to_run_demos=4
number_of_processors_to_run_demos=$default_number_of_processors_to_run_demos
test_results_directory=test_results
# Prompts for FULL configuration
full_configuration=FALSE
# Indicates whether to output building information (currently not in use)
verbose=FALSE
#====================================================================
# Parse arguments
# ====================================================================
# A letter followed by a ':' indicates that it requires an argument
# value. Example: 't:' indicates that 't' is followed by an argument
# value. 'h', 'i', 'r' and 'v' do not require arguments.
while getopts “ht:b:c:n:d:irv” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
t)
lib_type=$OPTARG
;;
b)
lib_build=$OPTARG
;;
c)
configuration_file=$OPTARG
;;
n)
number_of_processors_to_build_library=$OPTARG
;;
d)
number_of_processors_to_run_demos=$OPTARG
;;
i)
full_configuration=TRUE
;;
v)
verbose=TRUE
;;
?)
echo ""
echo "============================================================= "
echo ""
echo "ERROR: No recognized parameter"
echo ""
echo "============================================================= "
echo ""
usage
exit 1
;;
esac
done
#====================================================================
# The building script
#====================================================================
echo " "
echo "============================================================= "
echo " "$lib_name" installation script"
echo "============================================================= "
echo " "
echo ""
echo "============================================================= "
echo ""
echo "This script allows you to install and/or run test for "$lib_name
echo ""
echo "============================================================= "
echo ""
echo ""
echo "SciCell++ Copyright (C) 2022 Julio César Pérez Sansalvador This"
echo "program comes with ABSOLUTELY NO WARRANTY."
echo "This is free software, and you are welcome to redistribute it"
echo "under GNU GENERAL PUBLIC LICENSE conditions."
echo ""
echo ""
#====================================================================
# Library type
#====================================================================
# Check whether FULL CONFIGURATION was requested
if test "$full_configuration" = "TRUE" ; then
# Answer's default value
static_or_shared='a'
echo "Which library type do you want to build?"
OptionPrompt "The a)STATIC or the b)SHARED type library? [a/b -- default: a]"
static_or_shared=`OptionRead`
if test "$static_or_shared" = "b" -o "$static_or_shared" = "B" ; then
lib_type=SHARED
#lib_ext=.so
else
lib_type=STATIC
#lib_ext=.a
fi
echo ""
echo "============================================================= "
echo ""
fi
#====================================================================
# Build version
#====================================================================
# Check whether FULL CONFIGURATION was requested
if test "$full_configuration" = "TRUE" ; then
# Answer's default value
debug_or_release='a'
echo "Which library version do you want to build?"
OptionPrompt "The a)DEBUG or the b)RELEASE version of the library ? [a/b -- default: a]"
debug_or_release=`OptionRead`
if test "$debug_or_release" = "b" -o "$debug_or_release" = "B" ; then
lib_build=RELEASE
else
lib_build=DEBUG
fi
echo ""
echo "============================================================= "
echo ""
fi
#====================================================================
# Configuration file for extra configuration
#====================================================================
# Check whether FULL CONFIGURATION was requested
if test "$full_configuration" = "TRUE" ; then
# Default configuration file
default_config_file="./configs/current"
# Answer's default value
your_config_file=""
echo "Specify the path config file with extra configuration flags:"
OptionPrompt "[default: ${default_config_file}]"
your_config_file=`OptionRead`
if test "$your_config_file" = ""; then
configuration_file=${default_config_file}
else
configuration_file=${your_config_file}
fi
echo ""
echo "============================================================= "
echo ""
fi
#====================================================================
# Number of processors to build framework
#====================================================================
# Check whether FULL CONFIGURATION was requested
if test "$full_configuration" = "TRUE" ; then
echo "How many processor should use to build $lib_name?"
OptionPrompt "[1] [2] [4] [8] [16] [default: $default_number_of_processors_to_build_library]"
number_of_processors_to_build_library=`OptionRead`
if test "$number_of_processors_to_build_library" != 1 -a "$number_of_processors_to_build_library" != 2 -a "$number_of_processors_to_build_library" != 4 -a "$number_of_processors_to_build_library" != 8 -a "$number_of_processors_to_build_library" != 16; then
number_of_processors_to_build_library=$default_number_of_processors_to_build_library
echo "Setting the number of processors to build library to [$default_number_of_processors_to_build_library]"
echo "We do not currently support the number of processors you"
echo "specified!"
fi
echo ""
echo "============================================================= "
echo ""
fi
#====================================================================
# Build demos
#====================================================================
# Check whether FULL CONFIGURATION was requested
if test "$full_configuration" = "TRUE" ; then
# Answer's default value
build_and_run_demos='a'
echo "Do you want to build and run the demos?"
OptionPrompt "a)DO BUILD/RUN demos b)DO NOT BUILD/RUN demos [a/b -- default: a]"
build_and_run_demos=`OptionRead`
if test "$build_and_run_demos" = "b" -o "$build_and_run_demos" = "B" ; then
build_test_demos=FALSE
else
build_test_demos=TRUE
echo "How many processor should use to run tests?"
OptionPrompt "[1] [2] [4] [8] [16] [default: $default_number_of_processors_to_run_demos]"
number_of_processors_to_run_demos=`OptionRead`
if test "$number_of_processors_to_run_demos" != 1 -a "$number_of_processors_to_run_demos" != 2 -a "$number_of_processors_to_run_demos" != 4 -a "$number_of_processors_to_run_demos" != 8 -a "$number_of_processors_to_run_demos" != 16; then
number_of_processors_to_run_demos=$default_number_of_processors_to_run_demos
echo "Setting the number of processors to run tests to [$default_number_of_processors_to_run_demos]"
echo "We do not currently support the number of processors you"
echo "specified!"
fi
fi
echo ""
echo "============================================================= "
echo ""
else
# If no FULL CONFIGURATION was requested then check for number of
# processors to run demos, if zero is set then do not run demos
if test $number_of_processors_to_run_demos = 0; then
build_test_demos=FALSE
fi
fi
#====================================================================
# Summary for building process to run
#====================================================================
echo ""
echo "============================================================= "
echo "************************************************************* "
echo "============================================================= "
echo "Building the " $lib_type "/" $lib_build" version of the library"
echo "using ["$number_of_processors_to_build_library"] processor(s)"
echo "with configuration file ["$configuration_file"]"
echo ""
echo "BUILD_DEMOS="$build_test_demos
if test "$build_test_demos" = "TRUE" ; then
echo "Using ["$number_of_processors_to_run_demos"] processor(s) to run tests"
else
echo "Skipping demos testing"
fi
echo "============================================================= "
echo "************************************************************* "
echo "============================================================= "
echo ""
#====================================================================
# Going to the build directory
#====================================================================
echo "I will use the ./"$build_dir" directory as the temp build folder"
if (test -d $build_dir); then
rm -r $build_dir/*
echo "Cleaning up ..."
cd $build_dir
echo "Done"
else
mkdir $build_dir
cd $build_dir
fi
echo ""
#====================================================================
# Calling CMake
#====================================================================
echo "============================================================= "
echo "I am going to run CMake ..."
echo "============================================================= "
echo ""
# Go one folder up since we did a cd into ./build
# Run CMake and test for any error
if ! cmake ../ \
-DSCICELLXX_LIB_TYPE=$lib_type \
-DSCICELLXX_BUILD_VERSION=$lib_build \
-DSCICELLXX_BUILD_DEMOS=$build_test_demos \
-DSCICELLXX_CONFIGURATION_FILE=$configuration_file \
-DCMAKE_VERBOSE_MAKEFILE=$verbose \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 ; then # Added to create the
# 'compile_commands.json
# file for emacs
# autocompletion in
# irony mode'
echo ""
echo "============================================================= "
echo "[ERROR] CMake"
echo "============================================================= "
echo ""
exit 1 # Add this flag for GitHub Actions report
fi
echo ""
echo "============================================================= "
echo "[Done] CMake"
echo "============================================================= "
echo ""
echo "============================================================= "
echo "Make clean"
echo "============================================================= "
echo ""
make clean
echo "============================================================= "
echo "Make"
echo "============================================================= "
echo ""
echo "Make with ["$number_of_processors_to_build_library"] processor(s)"
echo ""
# The -k option allows make to continue compiling even a compilation
# error is found
if ! make -k -j"$number_of_processors_to_build_library" ; then
echo ""
echo ""
echo ""
echo "============================================================= "
echo ""
echo "Do not commit any broken version of the library."
echo "If any build/test fails try to fix it and report back to the"
echo "developers."
echo ""
echo "============================================================= "
echo "[FAILED] make -k -j$number_of_processors_to_build_library"
echo "============================================================= "
echo ""
exit 1 # Add this flag for GitHub Actions report
fi
#====================================================================
# Finishing up !!!
#====================================================================
# Go to the root directory
cd ..
echo ""
echo "============================================================= "
echo ""
echo "Finishing library built process ... (cmake and make have"
echo "finished!)"
echo "If you can not spot any error messages above this, the"
echo $lib_name" library should now be ready to RUN TEST UNITS"
echo ""
echo "============================================================= "
echo ""
echo ""
echo ""
#====================================================================
# Run tests?
#====================================================================
if test "$build_test_demos" = "TRUE" ; then
echo ""
echo ""
echo ""
echo "============================================================= "
echo ""
echo "I am going to run the tests as requested"
echo "----------------------------------------"
echo "Using ["$number_of_processors_to_run_demos"] processor(s)"
echo ""
echo "============================================================= "
echo ""
echo ""
# Store whether 'make test' sucessed or failed
test_failed=0
# Go into the build folder to run tests
cd $build_dir
# Call the make test function instead of ctest (make test enables
# testing and then calls ctest)
# Use as many processors as requested to run tests in parallel
if ! make test ARGS=-j"$number_of_processors_to_run_demos" ; then
echo ""
echo ""
echo ""
echo "============================================================= "
echo ""
echo "Do not commit any broken version of the library."
echo "If any build/test fails try to fix it and report back to the"
echo "developers."
echo ""
echo "============================================================= "
echo "[FAILED] make test"
echo "============================================================= "
echo ""
# Set the flag to indicate a fail in tests
test_failed=1
fi
# Go one directory up
cd ..
# Once all test have been run, copy the file with the results of
# the test into the test results directory
echo ""
echo "============================================================= "
echo ""
echo "I will copy the test results summary into the following folder"
echo "$test_results_directory"
# Check whether the test directory already exists, if that is the
# case then delete it
if (test -d $test_results_directory); then
rm -rf $test_results_directory
fi
mkdir $test_results_directory
echo "Copying test results files ..."
cp build/Testing/Temporary/LastTest.log ./$test_results_directory/test_results.log
cp build/Testing/Temporary/CTestCostData.txt ./$test_results_directory/test_results_short.txt
echo ""
echo "============================================================= "
echo ""
echo "Finishing library test process ... (make test has finished!)"
echo "If you can't spot any error messages above this, the"
echo $lib_name" library should now be ready to use and free of errors"
echo ""
echo "============================================================= "
echo ""
echo "Check the validation files for information regarding"
echo "PASSED/FAILED tests."
echo ""
echo "============================================================= "
echo ""
if test $test_failed = 1; then
exit 1 # Add this flag for GitHub Actions report
fi
else
echo ""
echo ""
echo ""
echo "============================================================= "
echo ""
echo "You did not requested for RUN TEST UNITS."
echo ""
echo "We highly recommend to RUN TEST UNITS before continue"
echo "Type 'make test' and hit enter inside the build folder=$build_dir"
echo "If you want to use more than one processor, then type"
echo "'make test ARGS=-j#', where # represents the number of"
echo "processors you want to use to run the tests"
echo ""
echo "============================================================= "
echo ""
fi
echo ""
echo "============================================================= "
echo ""
echo "Do not commit any broken version of the library."
echo "If any build/test fails try to fix it and report back to the"
echo "developers."
echo ""
echo "Your contributions are very welcome!"
echo ""
echo "Please contact the developers if you encountered any"
echo "build/test problem."
echo ""
echo "============================================================= "
echo ""
# If reaching this point then everything should be OK
exit 0