Skip to content

Commit 511c0c4

Browse files
Merge pull request #201 from zbeekman/master
De-lint shell scripts with spellcheck and debug FORD upgrade
2 parents 660abd8 + 1577925 commit 511c0c4

File tree

5 files changed

+43
-25
lines changed

5 files changed

+43
-25
lines changed

CMakeLists.txt

+9-2
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,20 @@ if ( NOT SKIP_DOC_GEN )
163163
else ()
164164
set ( MACRO_FLAG "" )
165165
endif ()
166+
# Pick the preprocessor to use based on the Fortran compiler
167+
if ( "${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" )
168+
set ( FPP "fpp\n" )
169+
else ()
170+
set ( FPP "gfortran -E\n" ) # default to gfortran -E for gfortran and unsupported compilers
171+
endif ()
172+
file ( WRITE "${CMAKE_BINARY_DIR}/preprocessor-def.md" "${FPP}" )
166173
# Dynamically generate the FORD outputs list
167174
message ( STATUS "Dynamically computing FORD output information..." )
168175
if ( NOT (DEFINED FORD_OUTPUTS_CACHED) )
169176
message ( STATUS "Running FORD to dynamically compute documentation outputs, this could take a while..." )
170177
execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR}
171178
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOC_DIR}
172-
COMMAND "${FORD}" -q ${MACRO_FLAG} -d "${PROJ_DIR}" -o "${DOC_DIR}" -p "${PAGE_DIR}" "${FORD_PROJECT_FILE}" OUTPUT_QUIET )
179+
COMMAND "${FORD}" --debug -q ${MACRO_FLAG} -d "${PROJ_DIR}" -o "${DOC_DIR}" -p "${PAGE_DIR}" "${FORD_PROJECT_FILE}" OUTPUT_QUIET )
173180
else ()
174181
message ( STATUS "Re-using cached FORD outputs, rather than regenerating them" )
175182
endif ()
@@ -190,7 +197,7 @@ if ( NOT SKIP_DOC_GEN )
190197
list ( APPEND FORD_DEPENDS "${DOC_SRC_FILE}" )
191198
endforeach ()
192199
add_custom_command ( OUTPUT ${FORD_OUTPUTS_CACHED}
193-
COMMAND "${FORD}" ${MACRO_FLAG} -d "${PROJ_DIR}" -o "${DOC_DIR}" -p "${CMAKE_SOURCE_DIR}/pages" "${FORD_PROJECT_FILE}"
200+
COMMAND "${FORD}" --debug ${MACRO_FLAG} -d "${PROJ_DIR}" -o "${DOC_DIR}" -p "${CMAKE_SOURCE_DIR}/pages" "${FORD_PROJECT_FILE}"
194201
MAIN_DEPENDENCY "${FORD_PROJECT_FILE}"
195202
DEPENDS ${FORD_DEPENDS}
196203
COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using FORD" )

build.sh

+20-16
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
#
6060
# REQUIRES
6161
# 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]
6363
#
6464
# AUTHOR
6565
# Jacob Williams : 12/27/2014
6666
#
6767

68-
set -e
68+
set -o errexit
6969

7070
FORDMD='json-fortran.md' # FORD options file for building documentation
7171
DOCDIR='./doc/' # build directory for documentation
@@ -78,7 +78,7 @@ BINDIR='./bin/' # build directory for unit tests
7878
LIBDIR='./lib/' # build directory for library
7979
MODCODE='json_module.F90' # json module file name
8080
LIBOUT='libjsonfortran.a' # name of json library
81-
81+
FPP="gfortran -E" # default to gfortran -E pre-processing
8282

8383
# The following warning might be triggered by ifort unless explicitly silenced:
8484
# 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
9797
# e.g., "./build.sh --compiler intel --coverage no --compiler gnu --coverage" will
9898
# perform the build with the GFORTRAN compiler, and coverage analysis
9999

100-
script_name="$(basename $0)"
100+
script_name="$(basename "$0")"
101101

102102
# usage message
103103
print_usage () {
@@ -122,18 +122,21 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
122122
intel|Intel|INTEL|ifort)
123123
FCOMPILER='Intel'
124124
FCOMPILERFLAGS="$INTELCOMPILERFLAGS"
125+
FPP="fpp"
125126
shift
126127
;;
127128
gnu|Gnu|GNU|gfortran|Gfortran|GFortran|GFORTRAN)
128129
FCOMPILER='gnu'
129130
FCOMPILERFLAGS="$GNUCOMPILERFLAGS"
131+
FPP="gfortran -E"
130132
shift
131133
;;
132134
*)
133135
FCOMPILER="custom"
134136
echo "Warning: Trying to build with unsupported compiler, $2." 1>&2
135137
echo "Please ensure you set appropriate --cflags and (single) quote them" 1>&2
136138
FC="$2"
139+
FPP="gfortran -E" # try gfortran to preprocess as a default
137140
shift
138141
;;
139142
esac
@@ -213,7 +216,7 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
213216
shift
214217
;;
215218
no|No|NO)
216-
JF_SKIP_DOCSS="no"
219+
JF_SKIP_DOCS="no"
217220
shift
218221
;;
219222
*)
@@ -226,7 +229,7 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
226229
exit 0
227230
;;
228231
--clean)
229-
rm -r src{,/tests}/*.o $DOCDIR* $LIBDIR* $BINDIR* *.gcov*
232+
rm -r -- src{,/tests}/*.o $DOCDIR* $LIBDIR* $BINDIR* *.gcov*
230233
;;
231234
*)
232235
echo "Unknown flag, \"$1\", passed to ${script_name}!" 2>&1
@@ -254,12 +257,12 @@ fi
254257

255258
if [[ $FCOMPILER == custom ]]; then
256259
echo "Trying to compile with custom compiler, $FC"
257-
CUSTOM="-fc $FC"
260+
CUSTOM=("-fc" "$FC")
258261
fi
259262

260263
if [[ $TRY_UNICODE == [yY]* ]]; then
261264
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
263266
if "${BINDIR}/${UCS4TESTCODE%.f90}"; then
264267
DEFINES="-DUSE_UCS4 -Wunused-function"
265268
fi
@@ -269,7 +272,7 @@ fi
269272
echo ""
270273
echo "Building library..."
271274

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
273276

274277
#build the unit tests (uses the above library):
275278
if [[ $JF_SKIP_TESTS != [yY]* ]]; then
@@ -282,7 +285,7 @@ if [[ $JF_SKIP_TESTS != [yY]* ]]; then
282285
for TEST in "${TESTDIR%/}"/jf_test_*.[fF]90; do
283286
THIS_TEST=${TEST##*/}
284287
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
286289
done
287290
else
288291
echo "Skip building the unit tests since \$JF_SKIP_TESTS has been set to 'true'."
@@ -292,17 +295,17 @@ fi
292295
echo ""
293296
if [[ $JF_SKIP_TESTS != [yY]* ]] ; then
294297
echo "Running tests..."
295-
cd "$BINDIR"
296298
OLD_IGNORES="$GLOBIGNORE"
299+
# run next commands in subshell to avoid `cd -`
300+
(cd "$BINDIR"
297301
GLOBIGNORE='*.*'
298302
#
299303
for TEST in jf_test_*; do
300304
# It would be nice to run json output printed to stdout through jsonlint, however,
301305
# some tests output more than one json structure and these need to be split
302306
echo "Running ${TEST}"
303-
./${TEST}
304-
done
305-
cd -
307+
"./${TEST}"
308+
done)
306309
GLOBIGNORE="$OLD_IGNORES"
307310
if [[ $CODE_COVERAGE = [yY]* ]] ; then
308311
for SRCFILE in json_string_utilities.F90 json_value_module.F90 json_file_module.F90 ; do
@@ -343,8 +346,9 @@ echo ""
343346
if [[ $JF_SKIP_DOCS != [yY]* ]]; then
344347
if hash ford 2>/dev/null; then
345348
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"
348352
else
349353
echo "FORD not found! Install using: sudo pip install ford"
350354
fi

deploy.sh

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
# If running under travis-ci this will automatically deploy updates to the master branch's
44
# documentation on build events for the master branch, and will add/update documentation for
55
# any new/updated tags that are pushed.
6+
set -o errexit
7+
set -o verbose
68
if [ "$TRAVIS" ]; then #running under travis
79
if $TRAVIS_SECURE_ENV_VARS ; then
810
# only try to update master's development documentation
911
if [ "$TRAVIS_BRANCH" = "master" ] && \
1012
[ "$TRAVIS_PULL_REQUEST" = "false" ] && \
11-
[ "$(ls -A $TRAVIS_BUILD_DIR/doc)" ] ; then #not empty
12-
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
13-
cd gh-pages
13+
[ "$(ls -A "$TRAVIS_BUILD_DIR/doc")" ] ; then #not empty
14+
git clone --branch=gh-pages "https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG" gh-pages
15+
cd gh-pages || exit 1
1416
rm -r css favicon.png fonts index.html interface js lists media module page proc \
1517
program search.html sourcefile src tipuesearch type
1618
cp -r "$TRAVIS_BUILD_DIR"/doc/* .
@@ -19,13 +21,13 @@ if [ "$TRAVIS" ]; then #running under travis
1921
git push origin gh-pages
2022
fi
2123
# If publishing a new/updated tag, deploy it's documentation
22-
if [ "$TRAVIS_TAG" ] && [ "$(ls -A $TRAVIS_BUILD_DIR/doc)" ] ; then #not empty
23-
cd "$TRAVIS_BUILD_DIR"
24-
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG gh-pages
24+
if [ "$TRAVIS_TAG" ] && [ "$(ls -A "$TRAVIS_BUILD_DIR/doc")" ] ; then #not empty
25+
cd "$TRAVIS_BUILD_DIR" || exit 1
26+
git clone --branch=gh-pages "https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG" gh-pages
2527
sed "1 s/^/version: ${TRAVIS_TAG}\n/" json-fortran.md > json-fortran.tagged.md
2628
# rebuild FORD documentation without pages, with version info, wiping out any existing tag folder
2729
ford -o "gh-pages/$TRAVIS_TAG" json-fortran.tagged.md
28-
cd gh-pages
30+
cd gh-pages || exit 1
2931
git add -A # add all new files in $TRAVIS_TAG/
3032
git commit -m "Tag/release documentation updated by travis job $TRAVIS_JOB_NUMBER for tag $TRAVIS_TAG $TRAVIS_COMMIT"
3133
git push origin gh-pages

json-fortran.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
project: JSON-Fortran
3+
preprocessor: {!preprocessor-def.md!}
34
favicon: ./media/json-fortran-32x32.png
45
project_dir: ./src
56
output_dir: ./doc
@@ -20,6 +21,9 @@ display: public
2021
private
2122
source: true
2223
graph: true
24+
coloured_edges: true
25+
print_creation_date: true
26+
creation_date: %Y-%m-%d %H:%M %z
2327
exclude_dir: tests
2428
extra_mods: iso_fortran_env:https://gcc.gnu.org/onlinedocs/gfortran/ISO_005fFORTRAN_005fENV.html
2529
md_extensions: markdown.extensions.toc(anchorlink=False)

preprocessor-def.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gfortran -E

0 commit comments

Comments
 (0)