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
@@ -78,7 +78,7 @@ BINDIR='./bin/' # build directory for unit tests
78
78
LIBDIR=' ./lib/' # build directory for library
79
79
MODCODE=' json_module.F90' # json module file name
80
80
LIBOUT=' libjsonfortran.a' # name of json library
81
-
81
+ FPP= " gfortran -E " # default to gfortran -E pre-processing
82
82
83
83
# The following warning might be triggered by ifort unless explicitly silenced:
84
84
# warning #7601: F2008 standard does not allow an internal procedure to be an actual argument procedure name. (R1214.4).
@@ -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 () {
@@ -122,18 +122,21 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
122
122
intel|Intel|INTEL|ifort)
123
123
FCOMPILER=' Intel'
124
124
FCOMPILERFLAGS=" $INTELCOMPILERFLAGS "
125
+ FPP=" fpp"
125
126
shift
126
127
;;
127
128
gnu|Gnu|GNU|gfortran|Gfortran|GFortran|GFORTRAN)
128
129
FCOMPILER=' gnu'
129
130
FCOMPILERFLAGS=" $GNUCOMPILERFLAGS "
131
+ FPP=" gfortran -E"
130
132
shift
131
133
;;
132
134
* )
133
135
FCOMPILER=" custom"
134
136
echo " Warning: Trying to build with unsupported compiler, $2 ." 1>&2
135
137
echo " Please ensure you set appropriate --cflags and (single) quote them" 1>&2
136
138
FC=" $2 "
139
+ FPP=" gfortran -E" # try gfortran to preprocess as a default
137
140
shift
138
141
;;
139
142
esac
@@ -213,7 +216,7 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
213
216
shift
214
217
;;
215
218
no|No|NO)
216
- JF_SKIP_DOCSS =" no"
219
+ JF_SKIP_DOCS =" no"
217
220
shift
218
221
;;
219
222
* )
@@ -226,7 +229,7 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
226
229
exit 0
227
230
;;
228
231
--clean)
229
- rm -r src{,/tests}/* .o $DOCDIR * $LIBDIR * $BINDIR * * .gcov*
232
+ rm -r -- src{,/tests}/* .o $DOCDIR * $LIBDIR * $BINDIR * * .gcov*
230
233
;;
231
234
* )
232
235
echo " Unknown flag, \" $1 \" , passed to ${script_name} !" 2>&1
254
257
255
258
if [[ $FCOMPILER == custom ]]; then
256
259
echo " Trying to compile with custom compiler, $FC "
257
- CUSTOM=" -fc $FC "
260
+ CUSTOM=( " -fc" " $FC " )
258
261
fi
259
262
260
263
if [[ $TRY_UNICODE == [yY]* ]]; then
261
264
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
265
+ FoBiS.py build -ch -compiler " ${FCOMPILER} " " ${CUSTOM[@]} " -cflags " ${FCOMPILERFLAGS} " -dbld " ${BINDIR} " -s " ${INTROSPECDIR} " -dmod ./ -dobj ./ -t " ${UCS4TESTCODE} " -o " ${UCS4TESTCODE% .f90} " -colors
263
266
if " ${BINDIR} /${UCS4TESTCODE% .f90} " ; then
264
267
DEFINES=" -DUSE_UCS4 -Wunused-function"
265
268
fi
269
272
echo " "
270
273
echo " Building library..."
271
274
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
275
+ 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
276
274
277
# build the unit tests (uses the above library):
275
278
if [[ $JF_SKIP_TESTS != [yY]* ]]; then
@@ -282,7 +285,7 @@ if [[ $JF_SKIP_TESTS != [yY]* ]]; then
282
285
for TEST in " ${TESTDIR%/ } " /jf_test_* .[fF]90; do
283
286
THIS_TEST=${TEST##*/ }
284
287
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
288
+ 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
289
done
287
290
else
288
291
echo " Skip building the unit tests since \$ JF_SKIP_TESTS has been set to 'true'."
292
295
echo " "
293
296
if [[ $JF_SKIP_TESTS != [yY]* ]] ; then
294
297
echo " Running tests..."
295
- cd " $BINDIR "
296
298
OLD_IGNORES=" $GLOBIGNORE "
299
+ # run next commands in subshell to avoid `cd -`
300
+ (cd " $BINDIR "
297
301
GLOBIGNORE=' *.*'
298
302
#
299
303
for TEST in jf_test_* ; do
300
304
# It would be nice to run json output printed to stdout through jsonlint, however,
301
305
# some tests output more than one json structure and these need to be split
302
306
echo " Running ${TEST} "
303
- ./${TEST}
304
- done
305
- cd -
307
+ " ./${TEST} "
308
+ done)
306
309
GLOBIGNORE=" $OLD_IGNORES "
307
310
if [[ $CODE_COVERAGE = [yY]* ]] ; then
308
311
for SRCFILE in json_string_utilities.F90 json_value_module.F90 json_file_module.F90 ; do
@@ -343,8 +346,9 @@ echo ""
343
346
if [[ $JF_SKIP_DOCS != [yY]* ]]; then
344
347
if hash ford 2> /dev/null; then
345
348
echo " Building documentation..."
346
- [[ $TRY_UNICODE = [yY]* ]] && MACRO_FLAG=" -m USE_UCS4"
347
- ford $MACRO_FLAG -p $PAGESDIR $FORDMD
349
+ [[ $TRY_UNICODE = [yY]* ]] && MACRO_FLAG=(" -m" " USE_UCS4" )
350
+ echo " $FPP " > preprocessor-def.md # Override via include in project file, until FORD gets CLI for this
351
+ ford --debug " ${MACRO_FLAG[@]} " -p " $PAGESDIR " " $FORDMD "
348
352
else
349
353
echo " FORD not found! Install using: sudo pip install ford"
350
354
fi
0 commit comments