59
59
#
60
60
# REQUIRES
61
61
# FoBiS.py : https://github.com/szaghi/FoBiS [version 1.2.5 or later required]
62
- # FORD : https://github.com/cmacmackin/ford [version 3 .0.2 is the one tested ]
62
+ # FORD : https://github.com/cmacmackin/ford [version 4 .0.0 or later ]
63
63
#
64
64
# AUTHOR
65
65
# Jacob Williams : 12/27/2014
66
66
#
67
67
68
- set -e
68
+ set -o errexit
69
69
70
70
FORDMD=' json-fortran.md' # FORD options file for building documentation
71
71
DOCDIR=' ./doc/' # build directory for documentation
@@ -97,7 +97,7 @@ FCOMPILER='gnu' #Set default compiler to gfortran
97
97
# e.g., "./build.sh --compiler intel --coverage no --compiler gnu --coverage" will
98
98
# perform the build with the GFORTRAN compiler, and coverage analysis
99
99
100
- script_name=" $( basename $0 ) "
100
+ script_name=" $( basename " $0 " ) "
101
101
102
102
# usage message
103
103
print_usage () {
@@ -213,7 +213,7 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
213
213
shift
214
214
;;
215
215
no|No|NO)
216
- JF_SKIP_DOCSS =" no"
216
+ JF_SKIP_DOCS =" no"
217
217
shift
218
218
;;
219
219
* )
@@ -226,7 +226,7 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
226
226
exit 0
227
227
;;
228
228
--clean)
229
- rm -r src{,/tests}/* .o $DOCDIR * $LIBDIR * $BINDIR * * .gcov*
229
+ rm -r -- src{,/tests}/* .o $DOCDIR * $LIBDIR * $BINDIR * * .gcov*
230
230
;;
231
231
* )
232
232
echo " Unknown flag, \" $1 \" , passed to ${script_name} !" 2>&1
254
254
255
255
if [[ $FCOMPILER == custom ]]; then
256
256
echo " Trying to compile with custom compiler, $FC "
257
- CUSTOM=" -fc $FC "
257
+ CUSTOM=( " -fc" " $FC " )
258
258
fi
259
259
260
260
if [[ $TRY_UNICODE == [yY]* ]]; then
261
261
echo " Trying to compile library with Unicode/UCS4 support"
262
- FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags " ${FCOMPILERFLAGS} " -dbld " ${BINDIR} " -s " ${INTROSPECDIR} " -dmod ./ -dobj ./ -t ${UCS4TESTCODE} -o ${UCS4TESTCODE% .f90} -colors
262
+ FoBiS.py build -ch -compiler " ${FCOMPILER} " " ${CUSTOM[@]} " -cflags " ${FCOMPILERFLAGS} " -dbld " ${BINDIR} " -s " ${INTROSPECDIR} " -dmod ./ -dobj ./ -t " ${UCS4TESTCODE} " -o " ${UCS4TESTCODE% .f90} " -colors
263
263
if " ${BINDIR} /${UCS4TESTCODE% .f90} " ; then
264
264
DEFINES=" -DUSE_UCS4 -Wunused-function"
265
265
fi
269
269
echo " "
270
270
echo " Building library..."
271
271
272
- FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags " ${FCOMPILERFLAGS} ${DEFINES} " ${COVERAGE} ${PROFILING} -dbld ${LIBDIR} -s ${SRCDIR} -dmod ./ -dobj ./ -t ${MODCODE} -o ${LIBOUT} -mklib static -colors
272
+ FoBiS.py build -ch -compiler ${FCOMPILER} " ${CUSTOM[@]} " -cflags " ${FCOMPILERFLAGS} ${DEFINES} " ${COVERAGE} ${PROFILING} -dbld ${LIBDIR} -s ${SRCDIR} -dmod ./ -dobj ./ -t ${MODCODE} -o ${LIBOUT} -mklib static -colors
273
273
274
274
# build the unit tests (uses the above library):
275
275
if [[ $JF_SKIP_TESTS != [yY]* ]]; then
@@ -282,7 +282,7 @@ if [[ $JF_SKIP_TESTS != [yY]* ]]; then
282
282
for TEST in " ${TESTDIR%/ } " /jf_test_* .[fF]90; do
283
283
THIS_TEST=${TEST##*/ }
284
284
echo " Build ${THIS_TEST% .[fF]90} "
285
- FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags " ${FCOMPILERFLAGS} ${DEFINES} " ${COVERAGE} ${PROFILING} -dbld ${BINDIR} -s ${TESTDIR} -i ${LIBDIR} -libs ${LIBDIR} /${LIBOUT} -dmod ./ -dobj ./ -t ${THIS_TEST} -o ${THIS_TEST% .[fF]90} -colors
285
+ FoBiS.py build -ch -compiler ${FCOMPILER} " ${CUSTOM[@]} " -cflags " ${FCOMPILERFLAGS} ${DEFINES} " ${COVERAGE} ${PROFILING} -dbld " ${BINDIR} " -s " ${TESTDIR} " -i " ${LIBDIR} " -libs " ${LIBDIR} /${LIBOUT} " -dmod ./ -dobj ./ -t " ${THIS_TEST} " -o " ${THIS_TEST% .[fF]90} " -colors
286
286
done
287
287
else
288
288
echo " Skip building the unit tests since \$ JF_SKIP_TESTS has been set to 'true'."
292
292
echo " "
293
293
if [[ $JF_SKIP_TESTS != [yY]* ]] ; then
294
294
echo " Running tests..."
295
- cd " $BINDIR "
296
295
OLD_IGNORES=" $GLOBIGNORE "
296
+ # run next commands in subshell to avoid `cd -`
297
+ (cd " $BINDIR "
297
298
GLOBIGNORE=' *.*'
298
299
#
299
300
for TEST in jf_test_* ; do
300
301
# It would be nice to run json output printed to stdout through jsonlint, however,
301
302
# some tests output more than one json structure and these need to be split
302
303
echo " Running ${TEST} "
303
- ./${TEST}
304
- done
305
- cd -
304
+ " ./${TEST} "
305
+ done)
306
306
GLOBIGNORE=" $OLD_IGNORES "
307
307
if [[ $CODE_COVERAGE = [yY]* ]] ; then
308
308
for SRCFILE in json_string_utilities.F90 json_value_module.F90 json_file_module.F90 ; do
0 commit comments