mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: update lemon version, wmake wrappers
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -34,12 +34,10 @@ binDir="${WMAKE_BIN:-$WM_PROJECT_DIR/platforms/tools/$WM_ARCH$WM_COMPILER}"
|
||||
etcDir="${WM_DIR:-$WM_PROJECT_DIR/wmake}/etc"
|
||||
|
||||
# Executable and skeleton locations
|
||||
lemon="$binDir/lemon"
|
||||
lemon="${binDir}/lemon"
|
||||
skel="-T${etcDir}/lempar.c"
|
||||
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
printHelp() {
|
||||
cat<<USAGE
|
||||
|
||||
Usage: ${0##*/} [options] [lemon args/options]
|
||||
@ -47,6 +45,7 @@ Usage: ${0##*/} [options] [lemon args/options]
|
||||
options:
|
||||
-header Generate header only, suppressing other output
|
||||
-dry-run Process m4 only (output on stdout)
|
||||
-grammar Output grammar tables (stdout)
|
||||
-no-tmp Do not retain temporary m4 processed files
|
||||
-h, -help Print the usage
|
||||
|
||||
@ -56,7 +55,7 @@ the m4(1) macro processor and lemon will be called with 'm4' as a macro
|
||||
definition, which can be used in conditions (%ifdef m4, %ifndef m4)
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
exit 0 # Clean exit
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -64,14 +63,15 @@ USAGE
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Eg, wrap-lemon -header
|
||||
unset optHeader optDryRun optRemoveTmp m4Flags
|
||||
unset optDryRun optHeader optGrammar optRemoveTmp m4Flags
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
(-h | -help*) usage ;;
|
||||
(-h | -help*) printHelp ;;
|
||||
|
||||
(-head*) optHeader=true ;;
|
||||
(-dry-run) optDryRun=true ;;
|
||||
(-head*) optHeader=true ;;
|
||||
(-gram*) optGrammar=true ;;
|
||||
(-no-tmp) optRemoveTmp=true ;;
|
||||
|
||||
(*) break ;;
|
||||
@ -163,6 +163,12 @@ case "$parser" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$optGrammar" ]
|
||||
then
|
||||
parserFlags="${parserFlags}${parserFlags:+ }-g"
|
||||
fi
|
||||
|
||||
|
||||
exitCode=0 # No failures
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -188,6 +194,8 @@ unset tmpFile tmpDir
|
||||
|
||||
if [ -n "$optHeader" ]
|
||||
then
|
||||
## echo "${0##*/} : generate header" 1>&2
|
||||
|
||||
# Drop last argument (the parser input file)
|
||||
set -- "${@:1:${#}-1}"
|
||||
|
||||
@ -196,8 +204,7 @@ then
|
||||
rm -rf "$tmpDir" 2>/dev/null
|
||||
mkdir "$tmpDir" 2>/dev/null
|
||||
|
||||
# We may want this:
|
||||
# trap 'rm -f $tmpDir 2>/dev/null; exit $exitCode' EXIT TERM INT
|
||||
trap 'rm -rf $tmpDir; exit $exitCode' EXIT TERM INT
|
||||
|
||||
if [ "$usingM4" = true ]
|
||||
then
|
||||
@ -236,10 +243,10 @@ then
|
||||
done
|
||||
fi
|
||||
|
||||
rm -rf "$tmpDir" 2>/dev/null
|
||||
|
||||
elif [ "$usingM4" = true ]
|
||||
then
|
||||
## echo "${0##*/} : generate code (with m4 filtering)" 1>&2
|
||||
|
||||
# Drop last argument (the parser input file)
|
||||
set -- "${@:1:${#}-1}"
|
||||
|
||||
@ -252,8 +259,10 @@ then
|
||||
fi
|
||||
tmpFile="${tmpFile%.*}$extParser" # Eg, from .lyy-m4 -> .lyy
|
||||
|
||||
# We may want this:
|
||||
# trap 'rm -f $tmpFile 2>/dev/null; exit $exitCode' EXIT TERM INT
|
||||
if [ -n "$optRemoveTmp" ]
|
||||
then
|
||||
trap 'rm -f $tmpFile; exit $exitCode' EXIT TERM INT
|
||||
fi
|
||||
|
||||
if m4 $m4Flags "$parser" > "$tmpFile" && [ -f "$tmpFile" ]
|
||||
then
|
||||
@ -264,16 +273,16 @@ then
|
||||
exitCode=1
|
||||
fi
|
||||
|
||||
if [ -n "$optRemoveTmp" ]
|
||||
if [ -z "$optRemoveTmp" ]
|
||||
then
|
||||
rm -f "$tmpFile" 2>/dev/null
|
||||
else
|
||||
echo 2>/dev/null
|
||||
echo "Retaining intermediate: $tmpFile" 2>/dev/null
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# No special handling
|
||||
## echo "${0##*/} : generate code" 1>&2
|
||||
|
||||
"$lemon" "$skel" "$@"
|
||||
exitCode=$?
|
||||
|
||||
Reference in New Issue
Block a user