From 69a61bf8355471372b66465022242063a05c9bff Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Mon, 16 Mar 2020 10:21:34 +0000 Subject: [PATCH 1/6] BUG: objToVTK - corrected for empty lines in obj file. See #1632 --- .../utilities/mesh/manipulation/objToVTK/objToVTK.C | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C b/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C index ccc9da33dc..8965219067 100644 --- a/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C +++ b/applications/utilities/mesh/manipulation/objToVTK/objToVTK.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -128,6 +128,8 @@ int main(int argc, char *argv[]) std::ifstream OBJfile(objName); + Info<< "Processing file " << objName << endl; + if (!OBJfile.good()) { FatalErrorInFunction @@ -145,13 +147,14 @@ int main(int argc, char *argv[]) label lineNo = 0; while (OBJfile.good()) { - string line = getLine(OBJfile); + const string line = getLine(OBJfile); lineNo++; + if (line.empty()) continue; + // Read first word IStringStream lineStream(line); - word cmd; - lineStream >> cmd; + word cmd(lineStream); if (cmd == "v") { From ba3a31af956e6cec33881e44f6842e518aca5cca Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 12 Feb 2020 17:09:43 +0100 Subject: [PATCH 2/6] ENH: openfoam shell session - improved and relocated - '-c' option (as per shell), '-Dkey[=value]' option to provide preferences via the command-line. For example, etc/openfoam -DWM_COMPILER=Clang -int64 ./Allwmake -j -s -l These can also be combined with other options. Eg, etc/openfoam -DWM_COMPILER=Clang \ -c 'wmake -show-path-cxx -show-cxxflags' - relocated from bin/tools/ => etc/ for easier access - bin/tools/openfoam.in : for autoconfig-style installation - Auto-detect if the shell script was executed with openfoam and interpret accordingly. Simple example, -------------- #!/usr/bin/openfoam cd "${0%/*}" || exit # Run -*-sh-*- from this dir blockMesh simpleFoam -------------- Note it is NOT currently possible to provide any other parameters this way. Eg, `#!/usr/bin/openfoam -sp` (NOT) This will either fail to run, or result in infinite recursion. --- bin/tools/openfoam | 193 ---------------------------- bin/tools/openfoam.in | 26 ++++ bin/tools/source-bashrc | 22 ++-- doc/openfoam.1.in | 70 +++++++++++ etc/bashrc | 14 ++- etc/config.sh/setup | 4 +- etc/cshrc | 9 +- etc/openfoam | 272 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 398 insertions(+), 212 deletions(-) delete mode 100755 bin/tools/openfoam create mode 100644 bin/tools/openfoam.in create mode 100644 doc/openfoam.1.in create mode 100755 etc/openfoam diff --git a/bin/tools/openfoam b/bin/tools/openfoam deleted file mode 100755 index bae80e12af..0000000000 --- a/bin/tools/openfoam +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------ -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | www.openfoam.com -# \\/ M anipulation | -#------------------------------------------------------------------------------ -# Copyright (C) 2019 OpenCFD Ltd. -#------------------------------------------------------------------------------ -# License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . -# -# Script -# openfoam [args] -# -# Description -# Open an interactive bash session with an OpenFOAM environment, -# or run an OpenFOAM application (with arguments) after first sourcing -# the OpenFOAM etc/bashrc file from the project directory. -# -# This script normally exists in $WM_PROJECT_DIR/bin/tools but can also -# be modified to use a hard-coded PROJECT_DIR entry and placed elsewhere -# in the filesystem (eg, /usr/bin). -# -#------------------------------------------------------------------------------ -# Hard-coded value (eg, with autoconfig) -projectDir="@PROJECT_DIR@" - -if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ] -then - # Auto-detect from location - toolsDir="${0%/*}" # The bin/tools dir - projectDir="${toolsDir%/bin/tools}" # Project dir - - case "$projectDir" in - (/bin | /usr/bin | /usr/local/bin) - # This shouldn't happen. - # If copied to a system dir, should also be using hard-coded values! - echo "Warning: suspicious looking project dir: $projectDir" 1>&2 - ;; - - ("$toolsDir") - # Eg, called as ./openfoam etc - need to try harder - projectDir="$(\cd $(dirname $0)/../.. && \pwd -L)" || unset projectDir - ;; - esac -fi - -#------------------------------------------------------------------------------ -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<&2 - exit 1 - ;; - *) - break - ;; - esac - shift -done - -#------------------------------------------------------------------------------- - -# Remove current OpenFOAM environment -if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ] -then - . "$WM_PROJECT_DIR/etc/config.sh/unset" -fi - -[ -d "$projectDir" ] || { - echo "Error: no project dir: $projectDir" 1>&2 - exit 2 -} - -_foamSourceBashEnv="$projectDir/etc/bashrc" - -if [ "$#" -eq 0 ] -then - # Interactive shell - _foamSourceBashEnv="$projectDir/bin/tools/source-bashrc" -fi - -[ -f "$_foamSourceBashEnv" ] || { - echo "Error: file not found: $_foamSourceBashEnv" 1>&2 - exit 2 -} - -if [ "$#" -eq 0 ] -then - # Source user ~/.bashrc and OpenFOAM etc/bashrc. - # 1) Can either use a tmp file, or 2) chain off to a dedicated file - # We use a dedicated file. - - if [ -n "$_foamSettings" ] - then - export FOAM_SETTINGS="$_foamSettings" - fi - - ## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2 - - # Interactive shell (newer bash can use --init-file instead of --rcfile) - exec bash --rcfile "$_foamSourceBashEnv" -i - -else - # Non-interactive - - # Source bashrc within a function to preserve command-line arguments - # - this will not have aliases, but working non-interactively anyhow - sourceBashrc() - { - . "$_foamSourceBashEnv" $_foamSettings - } - - sourceBashrc - exec "$@" -fi - -#------------------------------------------------------------------------------ diff --git a/bin/tools/openfoam.in b/bin/tools/openfoam.in new file mode 100644 index 0000000000..39b1fe76fb --- /dev/null +++ b/bin/tools/openfoam.in @@ -0,0 +1,26 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | www.openfoam.com +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# Copyright (C) 2020 OpenCFD Ltd. +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +# +# Script +# openfoam [options] [args] +# +# Description +# Forwarding to the OpenFOAM etc/openfoam bash session script. +# +#------------------------------------------------------------------------------ +# Hard-coded directory path (eg, autoconfig) +projectDir="@PROJECT_DIR@" + +exec "$projectDir"/etc/openfoam "$@" + +#------------------------------------------------------------------------------ diff --git a/bin/tools/source-bashrc b/bin/tools/source-bashrc index 13f494785a..e4fec4062b 100644 --- a/bin/tools/source-bashrc +++ b/bin/tools/source-bashrc @@ -5,34 +5,36 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2019 OpenCFD Ltd. +# Copyright (C) 2019-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # bin/tools/source-bashrc # # Description -# Source user ~/.bashrc and OpenFOAM etc/bashrc +# Source user ~/.bashrc and OpenFOAM etc/bashrc. +# Not normally sourced manually, but from bash with the --rcfile option. # -# This file is normally not sourced manually, -# but from bash with the --rcfile option. #------------------------------------------------------------------------------ -# Hard-coded value (eg, with autoconfig) +# Hard-coded directory path (eg, autoconfig) projectDir="@PROJECT_DIR@" if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ] then - # Auto-detect (as per OpenFOAM etc/bashrc) + # Auto-detect location (as per OpenFOAM etc/bashrc) # -- # Assuming this file is $WM_PROJECT_DIR/bin/tools/source-bashrc, # the next lines should work when sourced by BASH or ZSH shells. # -- projectDir="${BASH_SOURCE:-${ZSH_NAME:+$0}}" - [ -n "$projectDir" ] && projectDir="$(\cd $(dirname $projectDir)/../.. && \pwd -L)" || unset projectDir + if [ -n "$projectDir" ] + then + projectDir="$(\cd "$(dirname "$projectDir")"/../.. && \pwd -L)" || \ + unset projectDir + fi fi #------------------------------------------------------------------------------ @@ -66,7 +68,7 @@ then # Some feedback if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ] then - info="$(foamEtcFile -show-patch 2>/dev/null)" + info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)" # echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2 echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2 diff --git a/doc/openfoam.1.in b/doc/openfoam.1.in new file mode 100644 index 0000000000..2dbdac04bb --- /dev/null +++ b/doc/openfoam.1.in @@ -0,0 +1,70 @@ +.TH "OPENFOAM" 1 "OpenFOAM-version" "www.openfoam.com" "OpenFOAM Commands Manual" + +.SH NAME +openfoam \- OpenFOAM bash(1) session + +.SH SYNOPSIS +\fBopenfoam\fR [\fIOPTIONS\fR] [\fIapplication ...\fR] + +.SH DESCRIPTION +Activate an \fBOpenFOAM\fR environment in an interactive or +non-interactive bash(1) session. + +If no application is given, an interactive bash session will be used. +If an application (optionally with arguments) is provided, the +OpenFOAM \fIetc/bashrc\fR file will be sourced from the project directory +prior to running the application. + +.SH OPTIONS +.TP +\fB\-c\fR \fIcommand\fR +Execute shell commands with OpenFOAM environment +.TP +\fB\-D\fR\fIkey=[value]\fR +Define key/value to pass as a preference +.TP +\fB\-sp\fR +Use single precision for scalar-size +.TP +\fB\-dp\fR +Use double precision for scalar-size +.TP +\fB\-spdp\fR +Use single precision for scalar-size, double for solve-scalar size +.TP +\fB\-int32\fR +Use 32-bit label-size +.TP +\fB\-int64\fR +Use 64-bit label-size +.TP +\fB\-prefix=DIR\fR +Specify alternative OpenFOAM project directory +.TP +\fB\-show-api\fR | \fB\-version\fR +Print META-INFO api value and exit +.TP +\fB\-show-patch\fR +Print META-INFO patch value and exit +.TP +\fB\-show-prefix\fR +Print project directory and exit +.TP +\fB\-help\fR +Print the usage + +.SH ARGUMENTS + +If arguments remain after option processing, the first argument is +assumed to be an application with options and arguments. + +.SH FILES + +The \fIetc/bashrc\fR file from the OpenFOAM project directory supplies +the environment settings. + +.SH "SEE ALSO" +Online documentation https://www.openfoam.com/documentation/ + +.SH COPYRIGHT +Copyright \(co 2020 OpenCFD Ltd. diff --git a/etc/bashrc b/etc/bashrc index 9743498f39..30241548cd 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/bashrc @@ -30,11 +29,16 @@ # - $WM_PROJECT_SITE/$FOAM_API/etc/prefs.sh # - $WM_PROJECT_SITE/etc/prefs.sh # +# Some settings can also be overridden on the command-line when +# sourcing this file. For example, +# +# . /path/etc/bashrc WM_COMPILER=Clang WM_LABEL_SIZE=64 +# # Environment -# FOAM_VERBOSE (set/unset) -# - add extra verbosity when sourcing files # FOAM_CONFIG_NOUSER (set/unset) # - suppress use of user/group configuration files +# FOAM_VERBOSE (set/unset) +# - add extra verbosity when sourcing files # WM_PROJECT_SITE (optional directory) # - local site-specific directory, uses WM_PROJECT_DIR/site if unset # diff --git a/etc/config.sh/setup b/etc/config.sh/setup index d502e835cc..afead38f9f 100644 --- a/etc/config.sh/setup +++ b/etc/config.sh/setup @@ -132,8 +132,8 @@ then _foamAddMan "$WM_PROJECT_DIR/doc" fi -# Interactive shell -if /usr/bin/tty -s 2>/dev/null +# Interactive shell (use PS1, not tty) +if [ -n "$PS1" ] then _foamEtc -config aliases [ "${BASH_VERSINFO:-0}" -ge 4 ] && _foamEtc -config bash_completion diff --git a/etc/cshrc b/etc/cshrc index 86fb8bb6cf..b63ba3e4ed 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -29,11 +29,16 @@ # - $WM_PROJECT_SITE/$FOAM_API/etc/prefs.csh # - $WM_PROJECT_SITE/prefs.csh # +# Some settings can also be overridden on the command-line when +# sourcing this file. For example, +# +# source /path/etc/cshrc WM_COMPILER=Clang WM_LABEL_SIZE=64 +# # Environment -# FOAM_VERBOSE (set/unset) -# - add extra verbosity when sourcing files # FOAM_CONFIG_NOUSER (set/unset) # - suppress use of user/group configuration files +# FOAM_VERBOSE (set/unset) +# - add extra verbosity when sourcing files # WM_PROJECT_SITE (optional directory) # - local site-specific directory, uses WM_PROJECT_DIR/site if unset # diff --git a/etc/openfoam b/etc/openfoam new file mode 100755 index 0000000000..e6d67dcb57 --- /dev/null +++ b/etc/openfoam @@ -0,0 +1,272 @@ +#!/bin/bash +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | www.openfoam.com +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# Copyright (C) 2019-2020 OpenCFD Ltd. +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +# +# Script +# openfoam [options] [args] +# +# Description +# Open an interactive bash session with an OpenFOAM environment, +# or run an OpenFOAM application (with arguments) after first sourcing +# the OpenFOAM etc/bashrc file from the project directory. +# +# Note +# This script normally exists in the $WM_PROJECT_DIR/etc/ directory. +# Do not copy/move/link to other locations. Use instead an edited copy of +# `bin/tools/openfoam.in` with a hard-coded projectDir entry. +# +# See OpenFOAM etc/bashrc for (command-line) preferences. +# Some equivalent settings: +# -sp | -DWM_PRECISION_OPTION=SP +# -dp | -DWM_PRECISION_OPTION=DP +# -int32 | -DWM_LABEL_SIZE=32 +# -int64 | -DWM_LABEL_SIZE=64 +# +# However, the '-D' options grant more flexibility. For example, +# etc/openfoam -DWM_COMPILER=Clang +# +#------------------------------------------------------------------------------ +# Auto-detect from location +projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)" + +#------------------------------------------------------------------------------ +printHelp() { + cat</dev/null)" + + if [ -n "$value" ] + then + echo "$value" + else + echo "Could not determine OPENFOAM '$1' value" 1>&2 + return 1 + fi +} + +#------------------------------------------------------------------------------- + +# No inheritance of FOAM_SETTINGS +unset FOAM_SETTINGS +unset _foamSettings _foamScriptCommand + +# Parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help* | --help*) + printHelp + ;; + -show-api | -version | --version) # Show API and exit + getApiInfo api + exit $? + ;; + -show-patch) # Show patch level and exit + getApiInfo patch + exit $? + ;; + -show-prefix) # Show project directory and exit + echo "$projectDir" + exit $? + ;; + + -c) # Shell command + _foamScriptCommand="$2" + [ -n "$_foamScriptCommand" ] || { + echo "$0: missing or bad command argument: $2" 1>&2 + exit 1 + } + shift 2 + break + ;; + + -D*) # Define key/value to pass as preference + setting="${1#-D}" + if [ -n "$setting" ] + then + _foamSettings="$_foamSettings${_foamSettings:+ }$setting" + fi + ;; + + -sp | -dp | -spdp ) + # WM_PRECISION_OPTION=(SP|DP|SPDP) + setting=$(echo "${1#-}" | sed -e 's/-//g;y/sdp/SDP/') + _foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=$setting" + ;; + + -int32 | -int64) + # WM_LABEL_SIZE=... + _foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}" + ;; + + -prefix=*) + projectDir="${1#*=}" + ;; + + -verbose) + export FOAM_VERBOSE=true + ;; + + --) + shift + break + ;; + -*) + echo "$0: unknown option: '$1'" 1>&2 + exit 1 + ;; + *) + break + ;; + esac + shift +done + +#------------------------------------------------------------------------------- + +# Sanity check (installed under /bin, /usr/bin, /usr/local/bin) +# This should not happen. +# If copied to a system dir, should also be using hard-coded values! + +if [ "${projectDir%/bin}" != "$projectDir" ] +then + echo "Warning: suspicious project dir: $projectDir" 1>&2 +fi + +[ -d "$projectDir/META-INFO" ] || { + echo "Warning: missing META-INFO in OpenFOAM directory:" 1>&2 + echo " $projectDir" 1>&2 +} + + +# Remove current OpenFOAM environment +if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ] +then + . "$WM_PROJECT_DIR/etc/config.sh/unset" || true +fi + +unset interactive + +if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ] +then + # Interactive shell, chain off via a file + interactive=true + _foamSourceBashEnv="$projectDir/bin/tools/source-bashrc" +else + # Non-interactive shell, use the OPENFOAM etc/bashrc + _foamSourceBashEnv="$projectDir/etc/bashrc" +fi + +[ -f "$_foamSourceBashEnv" ] || { + echo "Error: file not found: $_foamSourceBashEnv" 1>&2 + exit 2 +} + +if [ -n "$interactive" ] +then + # Interactive shell + # ----------------- + + # Source ~/.bashrc and OpenFOAM etc/bashrc in one of two ways: + # 1) Generate and use a tmp file + # 2) Chain off to a dedicated file [This is what we use] + + if [ -n "$_foamSettings" ] + then + # Pass preferences via the FOAM_SETTINGS mechanism + export FOAM_SETTINGS="$_foamSettings" + fi + + ## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2 + + # Newer bash can use --init-file instead of --rcfile + exec bash --rcfile "$_foamSourceBashEnv" -i + exit $? # Safety +fi + + +# Non-interactive shell +# --------------------- + +# Source bashrc within a function to preserve command-line arguments +# Suppresses aliases as a side-effect, but non-interactive anyhow. +sourceBashrc() +{ + . "$_foamSourceBashEnv" $_foamSettings +} + + +if [ -n "$_foamScriptCommand" ] +then + # A shell command + + sourceBashrc + exec bash -c "$_foamScriptCommand" "$@" + exit $? # Safety +fi + + +# An application or a shell script + +# It may actually be a script with a '#!/project-path/bin/openfoam', +# so we need to catch this to avoid infinite recursion. +if [ -f "$1" ] \ +&& [ -n "$(sed -ne '1{/^#!.*\/openfoam$/p; q}' "$1" 2>/dev/null)" ] +then + # A shell script + + sourceBashrc + exec bash "$@" + +else + # An application + + sourceBashrc + exec "$@" + +fi + +#------------------------------------------------------------------------------ From ac8b64df4660ba1c5cebec26d8156acb4d3d7c06 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 20 Feb 2020 12:11:08 +0100 Subject: [PATCH 3/6] CONFIG: support FOAM_EXTRA_CXXFLAGS (#1256) - allows custom tuning of compilation parameters --- etc/bashrc | 5 ++++ etc/config.csh/unset | 20 ++++++++------ etc/config.sh/unset | 21 ++++++++------- etc/cshrc | 5 ++++ wmake/rules/General/Clang/c++ | 5 +++- wmake/rules/General/Gcc/c++ | 5 +++- wmake/rules/General/Icc/c++ | 5 +++- wmake/rules/General/Pgi/c++ | 6 ++++- wmake/wclean | 51 ++++++++++++++++++++++++----------- wmake/wmake | 32 ++++++++++++++++------ 10 files changed, 110 insertions(+), 45 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 30241548cd..a949d5e11e 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -136,6 +136,11 @@ projectDir="$HOME/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION" # * on a 32-bit OS this option is ignored (always 32-bit) #export WM_ARCH_OPTION=64 +# [FOAM_EXTRA_CXXFLAGS] +# Additional compilation flags - do not inherit from the environment. +# Set after sourcing or via to avoid surprises. +unset FOAM_EXTRA_CXXFLAGS + ################################################################################ # NO (NORMAL) USER EDITING BELOW HERE diff --git a/etc/config.csh/unset b/etc/config.csh/unset index c3405cd65e..94dc6f8490 100644 --- a/etc/config.csh/unset +++ b/etc/config.csh/unset @@ -9,8 +9,7 @@ # Copyright (C) 2016-2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.csh/unset @@ -46,20 +45,15 @@ endif unsetenv WM_ARCH unsetenv WM_ARCH_OPTION -unsetenv WM_CC -unsetenv WM_CFLAGS unsetenv WM_COMPILER unsetenv WM_COMPILER_ARCH unsetenv WM_COMPILER_TYPE unsetenv WM_COMPILER_LIB_ARCH unsetenv WM_COMPILE_OPTION -unsetenv WM_CXX -unsetenv WM_CXXFLAGS unsetenv WM_DIR unsetenv WM_HOSTS unsetenv WM_LABEL_OPTION unsetenv WM_LABEL_SIZE -unsetenv WM_LDFLAGS unsetenv WM_MPLIB unsetenv WM_NCOMPPROCS unsetenv WM_OPTIONS @@ -75,6 +69,11 @@ unsetenv WM_PROJECT_VERSION unsetenv WM_SCHEDULER unsetenv WM_THIRD_PARTY_DIR +# Older variables + +# Before 1906 +unsetenv WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS + #------------------------------------------------------------------------------ # Unset FOAM_* environment variables @@ -84,8 +83,9 @@ unsetenv FOAM_APPBIN unsetenv FOAM_APP unsetenv FOAM_CODE_TEMPLATES unsetenv FOAM_ETC +unsetenv FOAM_EXTRA_CXXFLAGS +unsetenv FOAM_EXTRA_LDFLAGS unsetenv FOAM_EXT_LIBBIN -unsetenv FOAM_INST_DIR unsetenv FOAM_JOB_DIR unsetenv FOAM_LIBBIN unsetenv FOAM_MPI @@ -102,6 +102,10 @@ unsetenv FOAM_USER_APPBIN unsetenv FOAM_USER_LIBBIN unsetenv FOAM_UTILITIES +# Old variables + +# Before 1812 +unsetenv FOAM_INST_DIR #------------------------------------------------------------------------------ # Unset MPI-related environment variables diff --git a/etc/config.sh/unset b/etc/config.sh/unset index 3676b19c20..4b9bcbf15f 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/unset @@ -35,19 +34,14 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ unset WM_ARCH unset WM_ARCH_OPTION -unset WM_CC -unset WM_CFLAGS unset WM_COMPILER unset WM_COMPILER_TYPE unset WM_COMPILER_LIB_ARCH unset WM_COMPILE_OPTION -unset WM_CXX -unset WM_CXXFLAGS unset WM_DIR unset WM_HOSTS unset WM_LABEL_OPTION unset WM_LABEL_SIZE -unset WM_LDFLAGS unset WM_MPLIB unset WM_NCOMPPROCS unset WM_OPTIONS @@ -63,6 +57,10 @@ unset WM_PROJECT_VERSION unset WM_SCHEDULER unset WM_THIRD_PARTY_DIR +# Older variables + +# Before 1906 +unset WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS #------------------------------------------------------------------------------ # Unset FOAM_* environment variables @@ -72,8 +70,9 @@ unset FOAM_APPBIN unset FOAM_APP unset FOAM_CODE_TEMPLATES unset FOAM_ETC +unset FOAM_EXTRA_CXXFLAGS +unset FOAM_EXTRA_LDFLAGS unset FOAM_EXT_LIBBIN -unset FOAM_INST_DIR unset FOAM_JOB_DIR unset FOAM_LIBBIN unset FOAM_MPI @@ -90,6 +89,10 @@ unset FOAM_USER_APPBIN unset FOAM_USER_LIBBIN unset FOAM_UTILITIES +# Old variables + +# Before 1812 +unset FOAM_INST_DIR #------------------------------------------------------------------------------ # Unset MPI-related environment variables diff --git a/etc/cshrc b/etc/cshrc index b63ba3e4ed..9c3e9a03e2 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -138,6 +138,11 @@ set projectDir=`lsof +p $$ |& \ # * on a 32-bit OS this option is ignored (always 32-bit) #setenv WM_ARCH_OPTION 64 +# [FOAM_EXTRA_CXXFLAGS] +# Additional compilation flags - do not inherit from the environment. +# Set after sourcing or via to avoid surprises. +unsetenv FOAM_EXTRA_CXXFLAGS + ################################################################################ # NO (NORMAL) USER EDITING BELOW HERE diff --git a/wmake/rules/General/Clang/c++ b/wmake/rules/General/Clang/c++ index aa379895cc..4bba0cb569 100644 --- a/wmake/rules/General/Clang/c++ +++ b/wmake/rules/General/Clang/c++ @@ -14,9 +14,12 @@ c++WARN = \ -Wall -Wextra -Wold-style-cast \ -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof \ -Wno-undefined-var-template \ - -Wno-unknown-warning-option + -Wno-unknown-warning-option \ + $(FOAM_EXTRA_CXXFLAGS) c++LESSWARN = \ -Wno-old-style-cast -Wno-unused-local-typedefs \ -Wno-tautological-undefined-compare -Wno-shift-negative-value \ -Wno-null-pointer-arithmetic + +#------------------------------------------------------------------------------ diff --git a/wmake/rules/General/Gcc/c++ b/wmake/rules/General/Gcc/c++ index 15b7870a3e..337a7dfe73 100644 --- a/wmake/rules/General/Gcc/c++ +++ b/wmake/rules/General/Gcc/c++ @@ -13,9 +13,12 @@ ptFLAGS = -DNoRepository -ftemplate-depth-100 c++WARN = \ -Wall -Wextra -Wold-style-cast \ -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof \ - -Wno-attributes -Wno-unknown-pragmas + -Wno-attributes -Wno-unknown-pragmas \ + $(FOAM_EXTRA_CXXFLAGS) c++LESSWARN = \ -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds \ -Wno-deprecated-declarations \ -fpermissive + +#------------------------------------------------------------------------------ diff --git a/wmake/rules/General/Icc/c++ b/wmake/rules/General/Icc/c++ index 2119fe8faf..e0ad375d2a 100644 --- a/wmake/rules/General/Icc/c++ +++ b/wmake/rules/General/Icc/c++ @@ -14,7 +14,10 @@ c++WARN = \ -Wall -Wextra \ -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof \ -Wno-unknown-pragmas \ - -diag-disable 327,654,1125,1292,2289,2304,11062,11074,11076 + -diag-disable 327,654,1125,1292,2289,2304,11062,11074,11076 \ + $(FOAM_EXTRA_CXXFLAGS) c++LESSWARN = \ -diag-disable 1224,2026,2305 + +#------------------------------------------------------------------------------ diff --git a/wmake/rules/General/Pgi/c++ b/wmake/rules/General/Pgi/c++ index b089aab167..e1f41b9425 100644 --- a/wmake/rules/General/Pgi/c++ +++ b/wmake/rules/General/Pgi/c++ @@ -10,5 +10,9 @@ ptFLAGS = -DNoRepository # - Standard warnings # - Less restrictive warnings (may be needed for flex++, CGAL, etc.) -c++WARN = +c++WARN = \ + $(FOAM_EXTRA_CXXFLAGS) + c++LESSWARN = + +#------------------------------------------------------------------------------ diff --git a/wmake/wclean b/wmake/wclean index c7ebcd7bab..3317a802fe 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -7,7 +7,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2017 OpenCFD Ltd. +# Copyright (C) 2017-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -37,37 +37,52 @@ # lnInclude directories generated for libraries. # #------------------------------------------------------------------------------ -Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions -. ${0%/*}/scripts/wmakeFunctions # Source wmake functions +Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions +. "${0%/*}/scripts/wmakeFunctions" # Source wmake functions -usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<&2 + echo + echo "Error encountered:" + while [ "$#" -ge 1 ]; do echo " $1"; shift; done + echo + echo "See '${0##*/} -help' for usage" + echo exit 1 } + #------------------------------------------------------------------------------ # Parse arguments and options #------------------------------------------------------------------------------ @@ -78,16 +93,20 @@ MakeDir=Make while [ "$#" -gt 0 ] do case "$1" in - -h | -help*) - usage + -help-f*) # Full help + printHelp -full + ;; + -h | -help*) # Short help + printHelp ;; -a | -all | all) targetType=all ;; -s | -silent) # Ignored - for compatibility with wmake + export WM_QUIET=true ;; -*) - usage "unknown option: '$1'" + die "unknown option: '$1'" ;; *) break diff --git a/wmake/wmake b/wmake/wmake index 8bc070eb4b..ce1a2185a7 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -7,7 +7,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2017-2019 OpenCFD Ltd. +# Copyright (C) 2017-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -94,19 +94,22 @@ cat< Date: Mon, 24 Feb 2020 14:41:00 +0100 Subject: [PATCH 4/6] CONFIG: improve prefix matching for system libraries (#1607) - missed detection of system libraries when installed with multiarch paths like /usr/lib/x86_64-linux-gnu CONFIG: improve handling of group/user config files (#928) - changed bashrc handling of FOAM_CONFIG_NOUSER to use FOAM_CONFIG_MODE instead. Propagate into foamEtcFile to make this a stickier control. This change allows better control, but also enables cluster installations to define their own value within the OpenFOAM prefs.sh file to prevent users accidentally mis-configuring things if necessary. - remove undocumented handling of an (a)ll mode in foamEtcFile to avoid potential pitfalls. - add support for FOAM_CONFIG_ETC handling. This allows injection of an extra search layer when finding project etc files ENH: improvements to foamConfigurePaths (#928) - handle FOAM_CONFIG_ETC implicitly, or explicitly with the new -etc option. STYLE: more explicit wording in foamConfigurePaths usage (#1602) - document that an absolute path (eg, -scotch-path) overrides/ignores the equivalent ThirdParty setting (eg, -scotch) - longer options -system-compiler and -third-compiler for -system and -third, respectively. Clearer as to their purpose. - adjust the location sanity check to look for META-INFO directory. --- bin/foamEtcFile | 44 ++- bin/foamGetDict | 24 +- bin/foamLog | 13 +- bin/foamNewApp | 3 +- bin/foamNewBC | 3 +- bin/foamNewFunctionObject | 3 +- bin/tools/foamConfigurePaths | 278 ++++++++++++------ bin/tools/foamCreateModuleInclude | 47 ++- bin/tools/lib-dir | 7 +- etc/bashrc | 10 +- .../solvers/scalarTransport/scalarTransport | 7 +- etc/config.csh/functions | 25 +- etc/config.csh/settings | 5 +- etc/config.csh/setup | 32 +- etc/config.csh/unset | 4 +- etc/config.sh/functions | 30 +- etc/config.sh/paraview | 7 +- etc/config.sh/settings | 5 +- etc/config.sh/setup | 44 ++- etc/config.sh/unset | 2 + etc/cshrc | 10 +- etc/openfoam | 16 +- etc/templates/closedVolume/README | 4 +- .../collatedFileOperation.C | 2 +- wmake/scripts/have_adios2 | 15 +- wmake/scripts/have_boost | 13 +- wmake/scripts/have_ccmio | 11 +- wmake/scripts/have_cgal | 13 +- wmake/scripts/have_fftw | 13 +- wmake/scripts/have_hypre | 13 +- wmake/scripts/have_kahip | 13 +- wmake/scripts/have_metis | 13 +- wmake/scripts/have_mgridgen | 16 +- wmake/scripts/have_petsc | 17 +- wmake/scripts/have_readline | 13 +- wmake/scripts/have_scotch | 18 +- wmake/scripts/have_zoltan | 13 +- wmake/scripts/sysFunctions | 125 +++++++- 38 files changed, 575 insertions(+), 356 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 024c16a33b..c9a385abf0 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -33,7 +33,13 @@ # \endcode # # Environment -# - WM_PROJECT_SITE (unset defaults to PROJECT/site) +# FOAM_CONFIG_ETC +# Alternative etc directory for shipped files +# +# FOAM_CONFIG_MODE +# Fallback search mode for etc files. Unset is the same as "ugo". +# +# WM_PROJECT_SITE (unset defaults to PROJECT/site) # # Note # This script must exist in the project 'bin' directory @@ -46,8 +52,8 @@ printHelp() { cat</dev/null) \ +$("$projectDir"/bin/foamEtcFile -list -mode=o caseDicts 2>/dev/null)"; ## echo "Using <$searchDirs>" 1>&2 diff --git a/bin/foamLog b/bin/foamLog index fa35d383bc..25908fee22 100755 --- a/bin/foamLog +++ b/bin/foamLog @@ -7,6 +7,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------- # Copyright (C) 2011-2016 OpenFOAM Foundation +# Copyright (C) 2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -38,8 +39,6 @@ #------------------------------------------------------------------------------ Script="${0##*/}" toolsDir="${0%/*}/tools" -groupDir="${WM_PROJECT_SITE:-${WM_PROJECT_DIR:-}/site}" -userDir="$HOME/.OpenFOAM" usage() { exec 1>&2 @@ -91,13 +90,9 @@ cat <&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done +printHelp() { cat<&2 +else + die "Please run from the OpenFOAM top-level installation directory" \ + "No etc/bashrc or META-INFO/ found" +fi + +# Use foamEtcFile to locate files, but only edit shipped files +if [ -x bin/foamEtcFile ] +then + _foamEtc() { + ./bin/foamEtcFile -mode=o "$@" + } +else + die "No bin/foamEtcFile found in installation" +fi # Check if argument matches the expected input. Respects case. @@ -211,6 +238,28 @@ replaceCsh() done } +# Locate file with foamEtcFile -mode=o and forward to replace() +replaceEtc() +{ + local file="$1" + shift + + file=$(_foamEtc "$file") + replace $file "$@" +} + + +# Locate file with foamEtcFile -mode=o and forward to replaceCsh() +replaceEtcCsh() +{ + local file="$1" + shift + + file=$(_foamEtc "$file") + replaceCsh $file "$@" +} + + # Get the option's value (argument), or die on missing or empty argument # $1 option # $2 value @@ -275,22 +324,55 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help* | --help*) - usage + printHelp ;; '') # Discard empty arguments ;; + -debug-list) + # Undocumented (experimental) + # TDB: List files that can be edited by this script + cat << CONFIG_SH +etc/bashrc +etc/config.sh/adios2 +etc/config.sh/compiler +etc/config.sh/paraview +etc/config.sh/vtk +etc/config.sh/CGAL +etc/config.sh/FFTW +etc/config.sh/metis +etc/config.sh/kahip +etc/config.sh/scotch +CONFIG_SH + + cat << CONFIG_CSH +etc/cshrc +etc/config.csh/adios2 +etc/config.csh/compiler +etc/config.csh/paraview +etc/config.csh/vtk +etc/config.csh/CGAL +etc/config.csh/FFTW +CONFIG_CSH + exit 0 + ;; + ## Basic ## + -etc=*) + # Define FOAM_CONFIG_ETC for finding files + export FOAM_CONFIG_ETC="${1#*=}" + ;; + -project-path) # Replace WM_PROJECT_DIR=... optionValue=$(getOptionValue "$@") - replace etc/bashrc WM_PROJECT_DIR "\"$optionValue\"" - replaceCsh etc/cshrc WM_PROJECT_DIR "\"$optionValue\"" + replaceEtc bashrc WM_PROJECT_DIR "\"$optionValue\"" + replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optionValue\"" - removeBashMagic etc/bashrc - removeCshMagic etc/cshrc + removeBashMagic $(_foamEtc bashrc) + removeCshMagic $(_foamEtc cshrc) adjusted=true shift @@ -299,8 +381,8 @@ do -version | -foamVersion | --projectVersion) # Replace WM_PROJECT_VERSION=... optionValue=$(getOptionValue "$@") - replace etc/bashrc WM_PROJECT_VERSION "$optionValue" - replaceCsh etc/cshrc WM_PROJECT_VERSION "$optionValue" + replaceEtc bashrc WM_PROJECT_VERSION "$optionValue" + replaceEtcCsh cshrc WM_PROJECT_VERSION "$optionValue" adjusted=true shift ;; @@ -314,30 +396,30 @@ do -sp | -SP | -float32) # Replace WM_PRECISION_OPTION=... - replace etc/bashrc WM_PRECISION_OPTION "SP" - replaceCsh etc/cshrc WM_PRECISION_OPTION "SP" + replaceEtc bashrc WM_PRECISION_OPTION "SP" + replaceEtcCsh cshrc WM_PRECISION_OPTION "SP" adjusted=true ;; -dp | -DP | -float64) # Replace WM_PRECISION_OPTION=... - replace etc/bashrc WM_PRECISION_OPTION "DP" - replaceCsh etc/cshrc WM_PRECISION_OPTION "DP" + replaceEtc bashrc WM_PRECISION_OPTION "DP" + replaceEtcCsh cshrc WM_PRECISION_OPTION "DP" adjusted=true ;; -spdp | -SPDP) # Replace WM_PRECISION_OPTION=... - replace etc/bashrc WM_PRECISION_OPTION "SPDP" - replaceCsh etc/cshrc WM_PRECISION_OPTION "SPDP" + replaceEtc bashrc WM_PRECISION_OPTION "SPDP" + replaceEtcCsh cshrc WM_PRECISION_OPTION "SPDP" adjusted=true ;; -int32 | -int64) # Replace WM_LABEL_SIZE=... optionValue="${1#-int}" - replace etc/bashrc WM_LABEL_SIZE "$optionValue" - replaceCsh etc/cshrc WM_LABEL_SIZE "$optionValue" + replaceEtc bashrc WM_LABEL_SIZE "$optionValue" + replaceEtcCsh cshrc WM_LABEL_SIZE "$optionValue" adjusted=true ;; @@ -347,8 +429,8 @@ do -clang) # Replace default_clang_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/compiler default_clang_version "$optionValue" - replace etc/config.csh/compiler default_clang_version "$optionValue" + replaceEtc config.sh/compiler default_clang_version "$optionValue" + replaceEtc config.csh/compiler default_clang_version "$optionValue" adjusted=true shift ;; @@ -356,32 +438,32 @@ do -gcc) # Replace default_gcc_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/compiler default_gcc_version "$optionValue" - replace etc/config.csh/compiler default_gcc_version "$optionValue" + replaceEtc config.sh/compiler default_gcc_version "$optionValue" + replaceEtc config.csh/compiler default_gcc_version "$optionValue" adjusted=true shift ;; - -system) + -system-compiler | -system) # Replace WM_COMPILER_TYPE=... and WM_COMPILER=... optionValue=$(getOptionValue "$@") - replace etc/bashrc \ + replaceEtc bashrc \ WM_COMPILER_TYPE system \ WM_COMPILER "$optionValue" - replaceCsh etc/cshrc \ + replaceEtcCsh cshrc \ WM_COMPILER_TYPE system \ WM_COMPILER "$optionValue" adjusted=true shift ;; - -third | -ThirdParty) + -third-compiler | -third | -ThirdParty) # Replace WM_COMPILER_TYPE=... and WM_COMPILER=... optionValue=$(getOptionValue "$@") - replace etc/bashrc \ + replaceEtc bashrc \ WM_COMPILER_TYPE ThirdParty \ WM_COMPILER "$optionValue" - replaceCsh etc/cshrc \ + replaceEtcCsh cshrc \ WM_COMPILER_TYPE ThirdParty \ WM_COMPILER "$optionValue" adjusted=true @@ -390,22 +472,22 @@ do gmp-[4-9]* | gmp-system) # gcc-related package - replace etc/config.sh/compiler default_gmp_version "$1" - replace etc/config.csh/compiler default_gmp_version "$1" + replaceEtc config.sh/compiler default_gmp_version "$1" + replaceEtc config.csh/compiler default_gmp_version "$1" adjusted=true ;; mpfr-[2-9]* | mpfr-system) # gcc-related package - replace etc/config.sh/compiler default_mpfr_version "$1" - replace etc/config.csh/compiler default_mpfr_version "$1" + replaceEtc config.sh/compiler default_mpfr_version "$1" + replaceEtc config.csh/compiler default_mpfr_version "$1" adjusted=true ;; mpc-[0-9]* | mpc-system) # gcc-related package - replace etc/config.sh/compiler default_mpc_version "$1" - replace etc/config.csh/compiler default_mpc_version "$1" + replaceEtc config.sh/compiler default_mpc_version "$1" + replaceEtc config.csh/compiler default_mpc_version "$1" adjusted=true ;; @@ -415,8 +497,8 @@ do -mpi) # Explicitly set WM_MPLIB=... optionValue=$(getOptionValue "$@") - replace etc/bashrc WM_MPLIB "$optionValue" - replaceCsh etc/cshrc WM_MPLIB "$optionValue" + replaceEtc bashrc WM_MPLIB "$optionValue" + replaceEtcCsh cshrc WM_MPLIB "$optionValue" optMpi=system adjusted=true shift @@ -431,34 +513,34 @@ do _matches "$optMpi" "$expected" || \ die "'$1' has bad value: '$optMpi'" - _inlineSed etc/config.sh/mpi \ + _inlineSed $(_foamEtc config.sh/mpi) \ "FOAM_MPI=$expected" \ "FOAM_MPI=$optMpi" \ "Replaced 'FOAM_MPI=$expected' setting by 'FOAM_MPI=$optMpi'" - _inlineSed etc/config.csh/mpi \ + _inlineSed $(_foamEtc config.csh/mpi) \ "FOAM_MPI $expected" \ "FOAM_MPI $optMpi" \ "Replaced 'FOAM_MPI $expected' setting by 'FOAM_MPI $optMpi'" - replace etc/bashrc WM_MPLIB OPENMPI - replaceCsh etc/cshrc WM_MPLIB OPENMPI + replaceEtc bashrc WM_MPLIB OPENMPI + replaceEtcCsh cshrc WM_MPLIB OPENMPI adjusted=true shift ;; -openmpi-system) # Explicitly set WM_MPLIB=SYSTEMOPENMPI - replace etc/bashrc WM_MPLIB SYSTEMOPENMPI - replaceCsh etc/cshrc WM_MPLIB SYSTEMOPENMPI + replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI + replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI optMpi=system adjusted=true ;; -openmpi-third) # Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi - replace etc/bashrc WM_MPLIB OPENMPI - replaceCsh etc/cshrc WM_MPLIB OPENMPI + replaceEtc bashrc WM_MPLIB OPENMPI + replaceEtcCsh cshrc WM_MPLIB OPENMPI optMpi=third adjusted=true ;; @@ -469,8 +551,8 @@ do -adios | -adios2) # Replace adios2_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/adios2 adios2_version "$optionValue" - replace etc/config.csh/adios2 adios2_version "$optionValue" + replaceEtc config.sh/adios2 adios2_version "$optionValue" + replaceEtc config.csh/adios2 adios2_version "$optionValue" adjusted=true shift ;; @@ -478,8 +560,8 @@ do -adios-path | -adios2-path) # Replace ADIOS2_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\"" - replaceCsh etc/config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\"" + replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\"" + replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\"" adjusted=true shift ;; @@ -487,8 +569,8 @@ do -boost) # Replace boost_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/CGAL boost_version "$optionValue" - replace etc/config.csh/CGAL boost_version "$optionValue" + replaceEtc config.sh/CGAL boost_version "$optionValue" + replaceEtc config.csh/CGAL boost_version "$optionValue" adjusted=true shift ;; @@ -496,8 +578,8 @@ do -boost-path) # Replace BOOST_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/CGAL BOOST_ARCH_PATH "\"$optionValue\"" - replaceCsh etc/config.csh/CGAL BOOST_ARCH_PATH "\"$optionValue\"" + replaceEtc config.sh/CGAL BOOST_ARCH_PATH "\"$optionValue\"" + replaceEtcCsh config.csh/CGAL BOOST_ARCH_PATH "\"$optionValue\"" adjusted=true shift ;; @@ -505,8 +587,8 @@ do -cgal) # Replace cgal_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/CGAL cgal_version "$optionValue" - replace etc/config.csh/CGAL cgal_version "$optionValue" + replaceEtc config.sh/CGAL cgal_version "$optionValue" + replaceEtc config.csh/CGAL cgal_version "$optionValue" adjusted=true shift ;; @@ -514,8 +596,8 @@ do -cgal-path) # Replace CGAL_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/CGAL CGAL_ARCH_PATH "$optionValue" - replaceCsh etc/config.csh/CGAL CGAL_ARCH_PATH "$optionValue" + replaceEtc config.sh/CGAL CGAL_ARCH_PATH "$optionValue" + replaceEtcCsh config.csh/CGAL CGAL_ARCH_PATH "$optionValue" adjusted=true shift ;; @@ -523,8 +605,8 @@ do -fftw) # Replace fftw_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/FFTW fftw_version "$optionValue" - replace etc/config.csh/FFTW fftw_version "$optionValue" + replaceEtc config.sh/FFTW fftw_version "$optionValue" + replaceEtc config.csh/FFTW fftw_version "$optionValue" adjusted=true shift ;; @@ -532,8 +614,8 @@ do -fftw-path) # Replace FFTW_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/FFTW FFTW_ARCH_PATH "\"$optionValue\"" - replaceCsh etc/config.csh/FFTW FFTW_ARCH_PATH "\"$optionValue\"" + replaceEtc config.sh/FFTW FFTW_ARCH_PATH "\"$optionValue\"" + replaceEtcCsh config.csh/FFTW FFTW_ARCH_PATH "\"$optionValue\"" adjusted=true shift ;; @@ -541,8 +623,8 @@ do -cmake) # Replace cmake_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/paraview cmake_version "$optionValue" - replace etc/config.csh/paraview cmake_version "$optionValue" + replaceEtc config.sh/paraview cmake_version "$optionValue" + replaceEtc config.csh/paraview cmake_version "$optionValue" adjusted=true shift ;; @@ -550,7 +632,7 @@ do -kahip) # Replace KAHIP_VERSION=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/kahip KAHIP_VERSION "$optionValue" + replaceEtc config.sh/kahip KAHIP_VERSION "$optionValue" adjusted=true shift ;; @@ -558,7 +640,7 @@ do -kahip-path) # Replace KAHIP_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\"" + replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\"" adjusted=true shift ;; @@ -566,7 +648,7 @@ do -metis) # Replace METIS_VERSION=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/metis METIS_VERSION "$optionValue" + replaceEtc config.sh/metis METIS_VERSION "$optionValue" adjusted=true shift ;; @@ -574,7 +656,7 @@ do -metis-path) # Replace METIS_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/metis METIS_ARCH_PATH "\"$optionValue\"" + replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optionValue\"" adjusted=true shift ;; @@ -582,7 +664,7 @@ do -scotch | -scotchVersion | --scotchVersion) # Replace SCOTCH_VERSION=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/scotch SCOTCH_VERSION "$optionValue" + replaceEtc config.sh/scotch SCOTCH_VERSION "$optionValue" adjusted=true shift ;; @@ -590,7 +672,7 @@ do -scotch-path | -scotchArchPath | --scotchArchPath) # Replace SCOTCH_ARCH_PATH=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\"" + replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\"" adjusted=true shift ;; @@ -605,8 +687,8 @@ do _matches "$optionValue" "$expected" || \ [ "$optionValue" != "${optionValue%system}" ] || \ die "'$1' has bad value: '$optionValue'" - replace etc/config.sh/paraview ParaView_VERSION "$optionValue" - replace etc/config.csh/paraview ParaView_VERSION "$optionValue" + replaceEtc config.sh/paraview ParaView_VERSION "$optionValue" + replaceEtc config.csh/paraview ParaView_VERSION "$optionValue" adjusted=true shift ;; @@ -614,8 +696,8 @@ do -paraview-qt) # Replace ParaView_QT=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/paraview ParaView_QT "$optionValue" - replace etc/config.csh/paraview ParaView_QT "$optionValue" + replaceEtc config.sh/paraview ParaView_QT "$optionValue" + replaceEtc config.csh/paraview ParaView_QT "$optionValue" adjusted=true shift ;; @@ -623,8 +705,8 @@ do -paraview-path | -paraviewInstall | --paraviewInstall) # Replace ParaView_DIR=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/paraview ParaView_DIR \""$optionValue\"" - replaceCsh etc/config.csh/paraview ParaView_DIR \""$optionValue\"" + replaceEtc config.sh/paraview ParaView_DIR \""$optionValue\"" + replaceEtcCsh config.csh/paraview ParaView_DIR \""$optionValue\"" adjusted=true shift ;; @@ -632,8 +714,8 @@ do -vtk) # Replace vtk_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/vtk vtk_version "$optionValue" - replace etc/config.csh/vtk vtk_version "$optionValue" + replaceEtc config.sh/vtk vtk_version "$optionValue" + replaceEtc config.csh/vtk vtk_version "$optionValue" adjusted=true shift ;; @@ -641,8 +723,8 @@ do -mesa) # Replace mesa_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/vtk mesa_version "$optionValue" - replace etc/config.csh/vtk mesa_version "$optionValue" + replaceEtc config.sh/vtk mesa_version "$optionValue" + replaceEtc config.csh/vtk mesa_version "$optionValue" adjusted=true shift ;; diff --git a/bin/tools/foamCreateModuleInclude b/bin/tools/foamCreateModuleInclude index dd616ae30d..7a95574057 100755 --- a/bin/tools/foamCreateModuleInclude +++ b/bin/tools/foamCreateModuleInclude @@ -7,23 +7,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2016-2017 CINECA -# Copyright (C) 2017-2019 OpenCFD Ltd. +# Copyright (C) 2017-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # foamCreateModuleInclude @@ -134,15 +121,24 @@ syspath() { # Frontend: do all basic sanity checks in the front-end only if [ -z "$optBackend" ] then - # Check that it appears to be an OpenFOAM installation - [ -d "$projectDir" -a -f "$projectDir/etc/bashrc" ] || \ - die "Incorrect projectDir? $projectDir" - # Check preloads - for file in "$preloads" - do - [ -f "$file" ] || echo "No such file to preload: $file" 1>&2 - done + if [ -n "$preloads" ] + then + for file in $preloads + do + [ -f "$file" ] || echo "No such file to preload: $file" 1>&2 + done + fi + + # Check that it appears to be an OpenFOAM installation + # could also check [ -d "$projectDir/META-INFO" ] + if [ -d "$projectDir" ] && [ -f "etc/bashrc" ] + then + echo "Appears to be an OpenFOAM installation" 1>&2 + else + die "Incorrect OpenFOAM projectDir?" \ + " $projectDir" + fi # Call itself with clean environment. # Tag the start/end of the original PATH, MANPATH, LD_LIBRARY_PATH @@ -234,6 +230,9 @@ unset FOAM_INST_DIR WM_PROJECT_INST_DIR unset WM_PROJECT_USER_DIR WM_THIRD_PARTY_DIR unset SCOTCH_VERSION +# Probably don't want these either +unset FOAM_CONFIG_MODE + # Also remove user directories as being unreliable @@ -283,7 +282,7 @@ unalias util 2>/dev/null #------------------------------------------------ # Generalize environment. -# This needs rethinking since it largely duplicates logic from the etc/config.sh/settings +# Needs rethinking, it largely duplicates logic from etc/config.sh/settings rewriteEnv() { sed \ diff --git a/bin/tools/lib-dir b/bin/tools/lib-dir index 5cc178019d..12651b22b6 100755 --- a/bin/tools/lib-dir +++ b/bin/tools/lib-dir @@ -6,11 +6,10 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2018 OpenCFD Ltd. +# Copyright (C) 2018-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # tools/lib-dir [OPTION] DIR [LIBEXT] @@ -135,7 +134,7 @@ then fi # 2) Use fallback if the previous failed -if [ -z "$resolved" -a -n "$alt" ] +if [ -z "$resolved" ] && [ -n "$alt" ] then # Fallback case "$alt" in diff --git a/etc/bashrc b/etc/bashrc index a949d5e11e..e4002104e3 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -35,10 +35,16 @@ # . /path/etc/bashrc WM_COMPILER=Clang WM_LABEL_SIZE=64 # # Environment -# FOAM_CONFIG_NOUSER (set/unset) -# - suppress use of user/group configuration files +# FOAM_CONFIG_ETC +# - alternative/additional location for OpenFOAM etc/ directory +# +# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile) +# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files +# - no influence on OpenFOAM applications, just the config files +# # FOAM_VERBOSE (set/unset) # - add extra verbosity when sourcing files +# # WM_PROJECT_SITE (optional directory) # - local site-specific directory, uses WM_PROJECT_DIR/site if unset # diff --git a/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport index 24fc867895..b7434eb2be 100644 --- a/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport +++ b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport @@ -8,9 +8,10 @@ Description Solves a transport equation for a scalar field. - The name of the scalar field is specified in this file. A sample scalar - field file, that must be initialised for the case, typically in the 0 - directory, is available in $FOAM_ETC/caseDicts/solvers/scalarTransport. + The name of the scalar field is specified in this file. + A sample scalar field file, that must be initialised for the case, + typically in the 0 directory, + is available in tetc/caseDicts/solvers/scalarTransport \*---------------------------------------------------------------------------*/ diff --git a/etc/config.csh/functions b/etc/config.csh/functions index f71dd99015..685b6462b0 100644 --- a/etc/config.csh/functions +++ b/etc/config.csh/functions @@ -5,11 +5,10 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2018 OpenCFD Ltd. +# Copyright (C) 2018-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.csh/functions @@ -36,25 +35,13 @@ alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}' alias _foamAddLibAuto 'eval `$WM_PROJECT_DIR/bin/tools/lib-dir -csh \!*`' # Echo values when FOAM_VERBOSE is on, no-op otherwise -if ($?FOAM_VERBOSE && $?prompt) then - alias _foamEcho 'echo \!*' -else - alias _foamEcho 'true' -endif - # Source an etc file, possibly with some verbosity if ($?FOAM_VERBOSE && $?prompt) then - if ($?FOAM_CONFIG_NOUSER) then - alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose -mode=o \!*`' - else - alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`' - endif + alias _foamEcho 'echo \!*' + alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`' else - if ($?FOAM_CONFIG_NOUSER) then - alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh -mode=o \!*`' - else - alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh \!*`' - endif + alias _foamEcho 'true' + alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh \!*`' endif diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 206846e18f..196f66ebb0 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.csh/settings diff --git a/etc/config.csh/setup b/etc/config.csh/setup index ecdea3b40f..497fdd795d 100644 --- a/etc/config.csh/setup +++ b/etc/config.csh/setup @@ -18,10 +18,11 @@ # Finalize setup of OpenFOAM environment for C-shell (csh, tcsh) # # Environment +# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile) +# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files +# # FOAM_VERBOSE (set/unset) # - add extra verbosity when sourcing files -# FOAM_CONFIG_NOUSER (set/unset) -# - suppress use of user/group configuration files # #------------------------------------------------------------------------------ @@ -77,14 +78,21 @@ endif # Overrides via -# 1. other (system) values +# 1. Always use (O)ther values from the OpenFOAM project etc/ directory _foamEtc -mode=o prefs.csh -# 2. user or group values (unless disabled) -if (! $?FOAM_CONFIG_NOUSER ) then - _foamEtc -mode=ug prefs.csh +# 2. (U)ser or (G)roup values (unless disabled). Could use some more work +if ($?FOAM_CONFIG_MODE) then + set configMode="${FOAM_CONFIG_MODE:s/o//}" # Already handled O(ther) +else + set configMode="ug" endif - +# Is the remainder valid - has U(ser) or G(roup)? +switch ("$configMode") +case *[ug]*: + _foamEtc -mode="$configMode" prefs.csh + breaksw +endsw # Capture and evaluate any command-line parameters # These can be used to set/unset values, specify additional files etc. @@ -119,6 +127,16 @@ while ( $#argv > 0 ) shift end +# The prefs may have injected a FOAM_CONFIG_ETC value. +# Verify that it makes sense before continuing. +if ( $?FOAM_CONFIG_ETC ) then + if ( ! -d "$FOAM_CONFIG_ETC" ) then + echo "Ignore invalid FOAM_CONFIG_ETC = $FOAM_CONFIG_ETC" + else if ( "$FOAM_CONFIG_ETC" == "$WM_PROJECT_DIR/etc" ) then + unsetenv FOAM_CONFIG_ETC + endif +endif + # Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/etc/config.csh/unset b/etc/config.csh/unset index 94dc6f8490..580fb8c856 100644 --- a/etc/config.csh/unset +++ b/etc/config.csh/unset @@ -6,7 +6,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -82,6 +82,8 @@ unsetenv FOAM_API unsetenv FOAM_APPBIN unsetenv FOAM_APP unsetenv FOAM_CODE_TEMPLATES +unsetenv FOAM_CONFIG_ETC +unsetenv FOAM_CONFIG_MODE unsetenv FOAM_ETC unsetenv FOAM_EXTRA_CXXFLAGS unsetenv FOAM_EXTRA_LDFLAGS diff --git a/etc/config.sh/functions b/etc/config.sh/functions index 6bd5ac74f0..30ca825534 100644 --- a/etc/config.sh/functions +++ b/etc/config.sh/functions @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2017-2018 OpenCFD Ltd. +# Copyright (C) 2017-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/functions @@ -39,32 +38,25 @@ then { foamVar_name="$1" shift - eval "$($foamClean -sh-env=$foamVar_name $@)" + eval "$($foamClean -sh-env="$foamVar_name" "$@")" unset "foamVar_name" } # Echo values to stderr when FOAM_VERBOSE is on, no-op otherwise - unset -f _foamEcho 2>/dev/null - if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] - then - _foamEcho() { echo "$@" 1>&2; } - else - _foamEcho() { true; } - fi - # Source an etc file, possibly with some verbosity # - use eval to avoid intermediate variables (ksh doesn't have 'local') + unset -f _foamEcho 2>/dev/null unset -f _foamEtc 2>/dev/null if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then - _foamEtc() - { - eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh-verbose ${FOAM_CONFIG_NOUSER:+-mode=o} $@)"; + _foamEcho() { echo "$@" 1>&2; } + _foamEtc() { + eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh-verbose "$@")"; } else - _foamEtc() - { - eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh ${FOAM_CONFIG_NOUSER:+-mode=o} $@)"; + _foamEcho() { true; } + _foamEtc() { + eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh "$@")"; } fi @@ -162,7 +154,7 @@ then # - use lib-dir script instead of rewriting _foamAddLibAuto() { - eval "$($WM_PROJECT_DIR/bin/tools/lib-dir -sh $@)"; + eval "$("$WM_PROJECT_DIR"/bin/tools/lib-dir -sh "$@")"; } fi diff --git a/etc/config.sh/paraview b/etc/config.sh/paraview index ab2f12e604..d850ccf307 100644 --- a/etc/config.sh/paraview +++ b/etc/config.sh/paraview @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/paraview @@ -109,7 +108,7 @@ case "$ParaView_VERSION" in (system) unset PV_PLUGIN_PATH - eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh ${FOAM_CONFIG_NOUSER:+-mode=o} -config paraview-system)" + eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh -config paraview-system)" ;; (*) diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 8b3ba1248f..fefba566bc 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/settings diff --git a/etc/config.sh/setup b/etc/config.sh/setup index afead38f9f..407aa4cce6 100644 --- a/etc/config.sh/setup +++ b/etc/config.sh/setup @@ -5,11 +5,10 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2018 OpenCFD Ltd. +# Copyright (C) 2018-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/setup @@ -19,15 +18,16 @@ # Finalize setup of OpenFOAM environment for POSIX shell. # # Environment +# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile) +# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files +# # FOAM_VERBOSE (set/unset) # - add extra verbosity when sourcing files -# FOAM_CONFIG_NOUSER (set/unset) -# - suppress use of user/group configuration files # #------------------------------------------------------------------------------ # [FOAM_API] - The API level for the project -export FOAM_API="$($WM_PROJECT_DIR/bin/foamEtcFile -show-api)" +export FOAM_API=$("$WM_PROJECT_DIR/bin/foamEtcFile" -show-api) # The installation parent directory prefixDir="${WM_PROJECT_DIR%/*}" @@ -83,11 +83,22 @@ fi # Overrides via -# 1. other (system) values +# 1. Always use O(ther) values from the OpenFOAM project etc/ directory _foamEtc -mode=o prefs.sh -# 2. user or group values (unless disabled) -[ -z "$FOAM_CONFIG_NOUSER" ] && _foamEtc -mode=ug prefs.sh +# 2. (U)ser or (G)roup values (unless disabled). +unset configMode +if [ -z "$FOAM_CONFIG_MODE" ] +then + configMode="ug" +else + case "$FOAM_CONFIG_MODE" in (*[u]*) configMode="${configMode}u" ;; esac + case "$FOAM_CONFIG_MODE" in (*[g]*) configMode="${configMode}g" ;; esac +fi +if [ -n "$configMode" ] +then + _foamEtc -mode="$configMode" prefs.sh +fi # Capture and evaluate any command-line parameters @@ -104,6 +115,21 @@ else _foamEval "$@" fi +# The prefs may have injected a FOAM_CONFIG_ETC value. +# Verify that it makes sense before continuing. +if [ -n "$FOAM_CONFIG_ETC" ] +then + if [ ! -d "$FOAM_CONFIG_ETC" ] + then + echo "Ignore invalid FOAM_CONFIG_ETC = $FOAM_CONFIG_ETC" 1>&2 + unset FOAM_CONFIG_ETC + elif [ "$FOAM_CONFIG_ETC" = "$WM_PROJECT_DIR/etc" ] + then + # Redundant value + unset FOAM_CONFIG_ETC + fi +fi + # Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/etc/config.sh/unset b/etc/config.sh/unset index 4b9bcbf15f..6f05533f1b 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -69,6 +69,8 @@ unset FOAM_API unset FOAM_APPBIN unset FOAM_APP unset FOAM_CODE_TEMPLATES +unset FOAM_CONFIG_ETC +unset FOAM_CONFIG_MODE unset FOAM_ETC unset FOAM_EXTRA_CXXFLAGS unset FOAM_EXTRA_LDFLAGS diff --git a/etc/cshrc b/etc/cshrc index 9c3e9a03e2..3ce361b92b 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -35,10 +35,16 @@ # source /path/etc/cshrc WM_COMPILER=Clang WM_LABEL_SIZE=64 # # Environment -# FOAM_CONFIG_NOUSER (set/unset) -# - suppress use of user/group configuration files +# FOAM_CONFIG_ETC +# - alternative/additional location for OpenFOAM etc/ directory +# +# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile) +# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files +# - no influence on OpenFOAM applications, just the config files +# # FOAM_VERBOSE (set/unset) # - add extra verbosity when sourcing files +# # WM_PROJECT_SITE (optional directory) # - local site-specific directory, uses WM_PROJECT_DIR/site if unset # diff --git a/etc/openfoam b/etc/openfoam index e6d67dcb57..7bbe622fe3 100755 --- a/etc/openfoam +++ b/etc/openfoam @@ -51,6 +51,7 @@ options: -dp Double precision -spdp Mixed single/double precision -int32 | -int64 The label-size + -etc=DIR Additional project etc/ directory -prefix=DIR Alternative OpenFOAM project directory -show-api | -version Print META-INFO api value and exit -show-patch Print META-INFO patch value and exit @@ -91,7 +92,7 @@ getApiInfo() # No inheritance of FOAM_SETTINGS unset FOAM_SETTINGS -unset _foamSettings _foamScriptCommand +unset _foamEtcDir _foamSettings _foamScriptCommand # Parse options while [ "$#" -gt 0 ] @@ -142,6 +143,11 @@ do _foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}" ;; + -etc=*) + # Define FOAM_CONFIG_ETC for finding files + _foamEtcDir="${1#*=}" + ;; + -prefix=*) projectDir="${1#*=}" ;; @@ -205,6 +211,14 @@ fi exit 2 } +if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ] +then + # Additional etc directory + export FOAM_CONFIG_ETC="$_foamEtcDir" +else + unset FOAM_CONFIG_ETC +fi + if [ -n "$interactive" ] then # Interactive shell diff --git a/etc/templates/closedVolume/README b/etc/templates/closedVolume/README index e82f1320ee..0ff3c261e7 100644 --- a/etc/templates/closedVolume/README +++ b/etc/templates/closedVolume/README @@ -11,7 +11,7 @@ Overview Meshing ======= + Meshing is setup as in the inflowOutflow template -+ See $FOAM_ETC/templates/inflowOutflow/README for details ++ See etc/templates/inflowOutflow/README for details + The setup includes an example for one named patch to be generated in the mesh + In snappyHexMeshDict, replace with the name of region in the trisurface; replace with the name of the resulting mesh patch @@ -21,4 +21,4 @@ Initialisation + In the field files in the 0 directory, set initial values + The template includes a fixedValue boundary condition on in 0/T + The user can replace with a real mesh patch name and apply a - fixed temperature on that patch \ No newline at end of file + fixed temperature on that patch diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C b/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C index 35432b2a0c..fb1e920f2e 100644 --- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C @@ -286,7 +286,7 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation "enabled, deactivate" << nl << " threading by setting maxThreadFileBufferSize " "to 0 in" << nl - << " $FOAM_ETC/controlDict" + << " OpenFOAM etc/controlDict" << endl; } diff --git a/wmake/scripts/have_adios2 b/wmake/scripts/have_adios2 index 4397cd8b41..c3bfbf2d0d 100644 --- a/wmake/scripts/have_adios2 +++ b/wmake/scripts/have_adios2 @@ -52,7 +52,7 @@ echo_adios2() } -# Provide hint for enabling +# Hint for enabling hint_adios2() { /bin/cat<&2 @@ -97,10 +97,10 @@ have_adios2() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -114,10 +114,9 @@ have_adios2() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -132,7 +131,7 @@ have_adios2() } -# Force reset of old variables +# Reset variables no_adios2 # Testing diff --git a/wmake/scripts/have_boost b/wmake/scripts/have_boost index aca69a63ed..4af9622f48 100644 --- a/wmake/scripts/have_boost +++ b/wmake/scripts/have_boost @@ -74,10 +74,10 @@ have_boost() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -91,10 +91,9 @@ have_boost() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -111,7 +110,7 @@ have_boost() } -# Force reset of old variables +# Reset variables no_boost # Testing diff --git a/wmake/scripts/have_ccmio b/wmake/scripts/have_ccmio index 68e2b2f718..3f2d686515 100644 --- a/wmake/scripts/have_ccmio +++ b/wmake/scripts/have_ccmio @@ -81,7 +81,7 @@ have_ccmio() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") else unset prefix fi @@ -94,10 +94,9 @@ have_ccmio() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -137,7 +136,7 @@ have_ccmio() } -# Force reset of old variables +# Reset variables no_ccmio # Testing diff --git a/wmake/scripts/have_cgal b/wmake/scripts/have_cgal index b0a90e7ed2..35194ac9a7 100644 --- a/wmake/scripts/have_cgal +++ b/wmake/scripts/have_cgal @@ -74,10 +74,10 @@ have_cgal() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -91,10 +91,9 @@ have_cgal() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -111,7 +110,7 @@ have_cgal() } -# Force reset of old variables +# Reset variables no_cgal # Testing diff --git a/wmake/scripts/have_fftw b/wmake/scripts/have_fftw index cfafa54c1e..0fa66f1b37 100644 --- a/wmake/scripts/have_fftw +++ b/wmake/scripts/have_fftw @@ -74,10 +74,10 @@ have_fftw() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -91,10 +91,9 @@ have_fftw() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -109,7 +108,7 @@ have_fftw() } -# Force reset of old variables +# Reset variables no_fftw # Testing diff --git a/wmake/scripts/have_hypre b/wmake/scripts/have_hypre index db9f77bbdd..293644e9b6 100644 --- a/wmake/scripts/have_hypre +++ b/wmake/scripts/have_hypre @@ -84,10 +84,10 @@ have_hypre() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -101,10 +101,9 @@ have_hypre() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -119,7 +118,7 @@ have_hypre() } -# Force reset of old variables +# Reset variables no_hypre # Testing diff --git a/wmake/scripts/have_kahip b/wmake/scripts/have_kahip index e528d5c100..e10fa1927c 100644 --- a/wmake/scripts/have_kahip +++ b/wmake/scripts/have_kahip @@ -82,10 +82,10 @@ have_kahip() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -99,10 +99,9 @@ have_kahip() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -120,7 +119,7 @@ have_kahip() } -# Force reset of old variables +# Reset variables no_kahip # Testing diff --git a/wmake/scripts/have_metis b/wmake/scripts/have_metis index 373f810793..1d1931586a 100644 --- a/wmake/scripts/have_metis +++ b/wmake/scripts/have_metis @@ -82,10 +82,10 @@ have_metis() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -99,10 +99,9 @@ have_metis() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -127,7 +126,7 @@ have_metis() } -# Force reset of old variables +# Reset variables no_metis # Testing diff --git a/wmake/scripts/have_mgridgen b/wmake/scripts/have_mgridgen index 4f016c72d2..dfed46abfd 100644 --- a/wmake/scripts/have_mgridgen +++ b/wmake/scripts/have_mgridgen @@ -83,10 +83,10 @@ have_mgridgen() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName $libName2)" + library=$(findExtLib "$libName" "$libName2") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -100,12 +100,10 @@ have_mgridgen() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib/$libName2" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName2" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || library=$(findLibrary -prefix="$prefix" -name="$libName2") \ + || { #silent# [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -165,7 +163,7 @@ have_mgridgen() } -# Force reset of old variables +# Reset variables no_mgridgen # Testing diff --git a/wmake/scripts/have_petsc b/wmake/scripts/have_petsc index 603584011f..2941f2e59d 100644 --- a/wmake/scripts/have_petsc +++ b/wmake/scripts/have_petsc @@ -42,7 +42,7 @@ no_petsc() } -# Reset variables +# Report echo_petsc() { echo "petsc=${HAVE_PETSC:-false}" @@ -52,7 +52,7 @@ echo_petsc() } -# Provide hint for enabling +# Hint for enabling hint_petsc() { /bin/cat<&2 @@ -101,10 +101,10 @@ have_petsc() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") # No system header, attempt discovery with pkg-config @@ -131,10 +131,9 @@ have_petsc() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -151,7 +150,7 @@ have_petsc() } -# Force reset of old variables +# Reset variables no_petsc # Testing diff --git a/wmake/scripts/have_readline b/wmake/scripts/have_readline index 21a258bc04..a11f294366 100644 --- a/wmake/scripts/have_readline +++ b/wmake/scripts/have_readline @@ -70,10 +70,10 @@ have_readline() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -87,10 +87,9 @@ have_readline() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -106,7 +105,7 @@ have_readline() } -# Force reset of old variables +# Reset variables no_readline # Testing diff --git a/wmake/scripts/have_scotch b/wmake/scripts/have_scotch index 78460c8096..154e7e71f6 100644 --- a/wmake/scripts/have_scotch +++ b/wmake/scripts/have_scotch @@ -88,7 +88,7 @@ have_scotch() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then header=$(findFirstFile \ @@ -110,10 +110,9 @@ have_scotch() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -230,10 +229,9 @@ have_ptscotch() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -249,7 +247,7 @@ have_ptscotch() } -# Force reset of old variables +# Reset variables no_scotch # Testing diff --git a/wmake/scripts/have_zoltan b/wmake/scripts/have_zoltan index 681abd2bea..d0a9b30fe1 100644 --- a/wmake/scripts/have_zoltan +++ b/wmake/scripts/have_zoltan @@ -81,10 +81,10 @@ have_zoltan() elif hasAbsdir "$prefix" then header=$(findFirstFile "$prefix/include/$incName") - library="$(findExtLib $libName)" + library=$(findExtLib "$libName") elif isSystem "$prefix" then - header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + header=$(findSystemInclude -name="$incName") prefix=$(sysPrefix "$header") else unset prefix @@ -98,10 +98,9 @@ have_zoltan() } # Library - [ -n "$library" ] || library=$(findLibrary \ - "$prefix/lib/$libName" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ - ) || { + [ -n "$library" ] \ + || library=$(findLibrary -prefix="$prefix" -name="$libName") \ + || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } @@ -116,7 +115,7 @@ have_zoltan() } -# Force reset of old variables +# Reset variables no_zoltan # Testing diff --git a/wmake/scripts/sysFunctions b/wmake/scripts/sysFunctions index 606d958966..3c7e41a2c9 100644 --- a/wmake/scripts/sysFunctions +++ b/wmake/scripts/sysFunctions @@ -5,7 +5,7 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2018-2019 OpenCFD Ltd. +# Copyright (C) 2018-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, licensed under GNU General Public License @@ -21,12 +21,18 @@ # isNone, isSystem, isAbsdir, hasAbsdir # isDarwin, isWindows # findFirstFile +# findSystemInclude # findLibrary # findExtLib # # Internal variables used # extLibraries # +# External variables used +# WM_OSTYPE (is set for Windows) +# WM_COMPILER_LIB_ARCH +# DEB_TARGET_MULTIARCH +# #------------------------------------------------------------------------------ if [ -z "$WMAKE_SCRIPTS_SYSFUNCTIONS" ] @@ -34,14 +40,19 @@ then # Load once, but do not rely on this variable elsewhere WMAKE_SCRIPTS_SYSFUNCTIONS=loaded + # Handle Debian multi-arch, ignore missing/bad dpkg-architecture. + if [ -z "$DEB_TARGET_MULTIARCH" ] + then + DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true) + fi + # True if OS is Darwin. isDarwin() { - test Darwin = "$(uname -s 2>/dev/null)" + test Darwin = "$(uname -s 2>/dev/null || true)" } # True if target OS is Windows - # Uses cached value from libso extension isWindows() { test MSwindows = "$WM_OSTYPE" @@ -58,7 +69,6 @@ then extLibraries=".a .dll .dll.a" # including cross-compiling fi - # True if '$1' begins with '/' isAbsdir() { @@ -126,27 +136,114 @@ then return 2 } + # Check system /usr/local/include /usr/include paths + # + # On success, echoes the resolved file and returns 0, otherwise returns 2 + # + # Specify -name=incName to search for + # + findSystemInclude() + { + local searchName + + case "$1" in + -name=*) + searchName="${1#*=}" + ;; + esac + + if [ -z "$searchName" ] + then + return 1 + fi + + findFirstFile \ + "/usr/local/include/$searchName" \ + "/usr/include/$searchName" \ + ; + } # Check existence of library with ending '.a', '.so' ... # # On success, echoes the resolved file and returns 0, otherwise returns 2 + # + # This function has two modes of operation. + # + # 1) Automated search. + # Specify -prefix=dirName -name=libName and search for + # (lib, lib64, lib/x86_64..) etc. + # + # 2) Directed search. + # specify the fully qualified names to search on the parameter list + # findLibrary() { + local prefixDir searchDir searchName local file ext - for file + searchDir=true + + while [ "$searchDir" = true ] && [ "$#" -gt 0 ] do - [ -n "$file" ] || continue - for ext in '' $extLibraries - do - if [ -f "$file$ext" ] && [ -r "$file$ext" ] - then - echo "$file$ext" # Found - return 0 - fi - done + case "$1" in + -prefix=*) + prefixDir="${1#*=}" + shift + ;; + + -name=*) + searchName="${1#*=}" + shift + ;; + + (*) + unset searchDir + ;; + esac done + if [ -n "$searchName" ] + then + # Automated search + # Eg, lib/ lib64/, lib/x86_64-linux-gnu + + : "${prefixDir:=/usr}" # A reasonable default + [ -d "$prefixDir" ] || return 2 + + for searchDir in \ + lib \ + "${WM_COMPILER_LIB_ARCH:+lib}$WM_COMPILER_LIB_ARCH" \ + "${DEB_TARGET_MULTIARCH:+lib/}${DEB_TARGET_MULTIARCH}" \ + ; + do + for ext in '' $extLibraries + do + file="$prefixDir/$searchDir/$searchName$ext" + if [ -f "$file" ] && [ -r "$file" ] + then + echo "$file" # Found + return 0 + fi + done + done + + else + # Directed search + + for file + do + [ -n "$file" ] || continue + for ext in '' $extLibraries + do + if [ -f "$file$ext" ] && [ -r "$file$ext" ] + then + echo "$file$ext" # Found + return 0 + fi + done + done + fi + return 2 } From 794ab397421bf2c91f842bd91d9981b57b7daff3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Mar 2020 14:35:30 +0100 Subject: [PATCH 5/6] BUG: missing output for foamDictionary -includes (closes #1635) - log to stdout when explicitly enabled --- .../functionEntries/includeEntry/includeEntry.C | 8 +++++--- .../functionEntries/includeEtcEntry/includeEtcEntry.C | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index 776b9b0fa6..6e7fd29ab8 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -143,7 +143,8 @@ bool Foam::functionEntries::includeEntry::execute { if (Foam::functionEntries::includeEntry::log) { - DetailInfo << fName << endl; + // Report to stdout which file is included + Info<< fName << nl; } // Add watch on included file @@ -194,7 +195,8 @@ bool Foam::functionEntries::includeEntry::execute { if (Foam::functionEntries::includeEntry::log) { - DetailInfo << fName << endl; + // Report to stdout which file is included + Info<< fName << nl; } // Add watch on included file diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C index e596a2a3f2..9431a57a92 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -123,7 +123,8 @@ bool Foam::functionEntries::includeEtcEntry::execute { if (Foam::functionEntries::includeEtcEntry::log) { - DetailInfo << fName << endl; + // Report to stdout which file is included + Info<< fName << nl; } parentDict.read(ifs); return true; @@ -162,7 +163,8 @@ bool Foam::functionEntries::includeEtcEntry::execute { if (Foam::functionEntries::includeEtcEntry::log) { - DetailInfo << fName << endl; + // Report to stdout which file is included + Info<< fName << nl; } entry.read(parentDict, ifs); return true; From 80e403381004a1f024acb6e4678e957a7a3b9377 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Mar 2020 14:56:50 +0100 Subject: [PATCH 6/6] CONFIG: bump patch level --- META-INFO/api-info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META-INFO/api-info b/META-INFO/api-info index 9614623e84..562278138f 100644 --- a/META-INFO/api-info +++ b/META-INFO/api-info @@ -1,2 +1,2 @@ api=1912 -patch=200312 +patch=200316