CONFIG: enable use of stricter deprecation warnings

- selected with '+strict' in WM_COMPILE_CONTROL or 'wmake -strict', it
  enables the FOAM_DEPRECATED_STRICT() macro, which can be used to
  mark methods that are implicitly deprecated, but are not yet marked
  as full deprecated (eg, API modification is too recent, generates
  too many warnings).  Can be considered a developer option.
This commit is contained in:
Mark Olesen
2023-08-09 14:34:17 +02:00
parent 224c3199aa
commit 778796853d
10 changed files with 67 additions and 19 deletions

View File

@ -32,6 +32,11 @@ else
COMPILER_VERSION :=
endif
# Enable additional compile-time checks
ifneq (,$(findstring +strict,$(WM_COMPILE_CONTROL)))
GFLAGS += -DFOAM_COMPILE_STRICT
endif
# Default compilation is 'Opt' - never permit an empty value
ifeq (,$(strip $(WM_COMPILE_OPTION)))
WM_COMPILE_OPTION := Opt

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2014-2017 OpenFOAM Foundation
# Copyright (C) 2019-2022 OpenCFD Ltd.
# Copyright (C) 2019-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -26,7 +26,8 @@
# -j | -jN | -j N
#
# Parsed options (wmake)
# -debug
# -debug | -debug-O[g0123]
# -strict
# -q | -queue
# -build-root=...
# Exports FOAM_BUILDROOT value.
@ -87,7 +88,7 @@ USAGE
#------------------------------------------------------------------------------
unset wmakeOpt_frontend wmakeOpt_nonRecursive
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_queue
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_strict wmakeOpt_queue
for arg in "$@"
do
@ -178,6 +179,11 @@ do
continue # Argument handled, remove it
;;
-strict)
wmakeOpt_strict="$arg"
continue # Argument handled, remove it
;;
-q | -queue)
wmakeOpt_queue="-queue"
continue # Argument handled, remove it
@ -203,13 +209,13 @@ then
if [ -z "$wmakeOpt_log" ]
then
exec wmake $wmakeOpt_frontend -all \
$wmakeOpt_debug $wmakeOpt_queue $wmakeOpt_openmp $*
$wmakeOpt_debug $wmakeOpt_strict $wmakeOpt_queue $wmakeOpt_openmp $*
exit $? # Unneeded, but just in case something went wrong
else
echo "Logging wmake -all output to '$wmakeOpt_log'" 1>&2
echo 1>&2
exec wmake $wmakeOpt_frontend -all \
$wmakeOpt_debug $wmakeOpt_queue $wmakeOpt_openmp $* 2>&1 | \
$wmakeOpt_debug $wmakeOpt_strict $wmakeOpt_queue $wmakeOpt_openmp $* 2>&1 | \
/usr/bin/tee $wmakeOpt_log
# Need to cleanup after the tee
rc=$? # Error code from tee (not wmake), but not entirely important
@ -234,7 +240,7 @@ fi
#------------------------------------------------------------------------------
unset wmakeOpt_frontend wmakeOpt_nonRecursive
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_queue
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_strict wmakeOpt_queue
unset -f usage

View File

@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2022 OpenCFD Ltd.
# Copyright (C) 2017-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -71,6 +71,7 @@ then
cat<<HELP_FULL
-debug Add '-g -DFULLDEBUG' flags
-debug-O[g0123] Add '-g -DFULLDEBUG' flags and optimization level
-strict More deprecation warnings ('+strict' WM_COMPILE_CONTROL)
-build-root=PATH Specify FOAM_BUILDROOT for compilation intermediates
-module-prefix=PATH Specify FOAM_MODULE_PREFIX as absolute/relative path
-module-prefix=TYPE Specify FOAM_MODULE_PREFIX as predefined type
@ -209,7 +210,7 @@ allCores()
# Default to compiling the local target only
unset opt_all opt_update opt_quiet opt_show opt_pwd
unset opt_debug opt_openmp opt_openfoam
unset opt_debug opt_openmp opt_openfoam opt_strict
# Consistency with inherited values
if [ "$WM_QUIET" = true ]
@ -267,6 +268,10 @@ do
opt_debug="-g -${1##*-}"
;;
-strict)
opt_strict="+strict"
;;
-build-root=*)
export FOAM_BUILDROOT="${1#*=}"
echo "Build-root = ${FOAM_BUILDROOT:-[]}" 1>&2
@ -520,6 +525,22 @@ case "$opt_openfoam" in
;;
esac
# Handle -strict flag(s)
if [ -n "$opt_strict" ]
then
# Add +strict into WM_COMPILE_CONTROL
opt_strict="${WM_COMPILE_CONTROL:+ }+strict"
case "$WM_COMPILE_CONTROL" in
(*+strict*)
# Appears to have already been added
;;
(*)
export WM_COMPILE_CONTROL="${WM_COMPILE_CONTROL}${opt_strict}"
;;
esac
fi
# Debug:
##echo "WM_COMPILE_CONTROL='$WM_COMPILE_CONTROL'" 1>&2