ENH: add canCompile test to RunFunctions

- allow conditional skipping of tutorials (for example) if wmake or
  the expected compiler is not available
This commit is contained in:
Mark Olesen
2020-06-08 21:46:59 +02:00
parent b2467ff442
commit 51db3c85a7
5 changed files with 53 additions and 3 deletions

View File

@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2015-2018 OpenCFD Ltd.
# Copyright (C) 2015-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# RunFunctions
@ -54,6 +53,33 @@ notTest()
return 0
}
#
# Test for wmake and compiler suite or emit warning
#
canCompile()
{
if ! command -v wmake >/dev/null
then
echo "No wmake command found ... cannot compile" 1>&2
return 1
fi
local cxx_compiler
cxx_compiler="$(wmake -show-cxx 2>/dev/null)"
if [ -z "$cxx_compiler" ]
then
echo "No wmake rule for C++ compiler? ... cannot compile" 1>&2
return 1
elif ! command -v "$cxx_compiler" >/dev/null
then
echo "No path to C++ compiler ($cxx_compiler) ... cannot compile" 1>&2
return 1
fi
return 0
}
#
# Check if '$1' corresponds to an OpenFOAM value for 'true' (see Switch.H)

View File

@ -3,6 +3,12 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
if ! canCompile
then
echo "skipping tutorial $PWD"
exit 0
fi
m4 < ./system/blockMeshDict.m4 > ./system/blockMeshDict
runApplication blockMesh

View File

@ -15,6 +15,12 @@ then
endTime=25
fi
if ! canCompile
then
echo "skipping tutorial $PWD"
exit 0
fi
#------------------------------------------------------------------------------
# Compute the case in 'serial' mode, and collect the data

View File

@ -3,6 +3,12 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
if ! canCompile
then
echo "skipping tutorial $PWD"
exit 0
fi
runApplication blockMesh
runApplication makeFaMesh

View File

@ -3,6 +3,12 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
if ! canCompile
then
echo "skipping tutorial $PWD"
exit 0
fi
wmake calcRadiusField
wclean calcRadiusField