From 36c1993c5eadb8732ad698bf7933c244fdd8dde0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 19 May 2020 11:42:40 +0200 Subject: [PATCH] CONFIG: only set PV_PLUGIN_PATH if the directory actually exists - this does mean two passes are required on the initial compilation, but improves reliability thereafter. ENH: correct csh handling of system paraview --- etc/config.csh/aliases | 2 +- etc/config.csh/paraview | 50 ++++++++++++++++++++++++++--------- etc/config.sh/aliases | 12 +++++---- etc/config.sh/paraview | 31 +++++++++++++++------- etc/config.sh/paraview-system | 20 +++++++++----- 5 files changed, 80 insertions(+), 35 deletions(-) diff --git a/etc/config.csh/aliases b/etc/config.csh/aliases index f82bd35cc0..a1c6bb5124 100644 --- a/etc/config.csh/aliases +++ b/etc/config.csh/aliases @@ -67,7 +67,7 @@ alias foamVersion \ # Change ParaView version # ~~~~~~~~~~~~~~~~~~~~~~~ alias foamPV \ - 'source $WM_PROJECT_DIR/etc/config.csh/paraview ParaView_VERSION=\!*; echo ${ParaView_DIR:t}' + 'source $WM_PROJECT_DIR/etc/config.csh/paraview ParaView_VERSION=\!*; echo paraview=${ParaView_DIR:t}' #------------------------------------------------------------------------------ diff --git a/etc/config.csh/paraview b/etc/config.csh/paraview index 36c5c0939f..b31d544d73 100644 --- a/etc/config.csh/paraview +++ b/etc/config.csh/paraview @@ -46,6 +46,9 @@ # # setenv LD_LIBRARY_PATH $ParaView_DIR/lib/paraview-5.4:$LD_LIBRARY_PATH # +# Additional Notes +# PV_PLUGIN_PATH is *only* set if the directory actually exists. +# #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade @@ -77,6 +80,9 @@ while ( $#argv > 0 ) shift end +unset pv_plugin_dir +unsetenv PV_PLUGIN_PATH + if ($?ParaView_VERSION) then switch ("$ParaView_VERSION") case "": @@ -85,7 +91,6 @@ case "": breaksw case "none": - unsetenv PV_PLUGIN_PATH setenv ParaView_DIR # Defined but empty (used by foamPV alias) if ($?FOAM_VERBOSE && $?prompt) then @@ -100,14 +105,27 @@ case "system": if ("${pv_api}" == "") then unsetenv ParaView_DIR PV_PLUGIN_PATH else - setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api" + # Get ParaView_DIR from `which paraview` + # Eg, /usr/bin/paraview -> /usr/bin -> /usr + + set pv_dir=`which paraview` + if ( -x "$pv_dir" ) then + set pv_dir="${pv_dir:h}" + setenv ParaView_DIR "${pv_dir:h}" + endif + + set pv_plugin_dir="$FOAM_LIBBIN/paraview-$pv_api" + if ( -d "$pv_plugin_dir" ) then + setenv PV_PLUGIN_PATH "$pv_plugin_dir" + else + set pv_plugin_dir="${pv_plugin_dir} (missing)" # For message + endif endif if ($?FOAM_VERBOSE && $?prompt) then - echo "Using paraview (disabled)" - if ( $?PV_PLUGIN_PATH ) then + if ( $?pv_plugin_dir ) then echo "Using paraview (system)" - echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" + echo " plugins : ${pv_plugin_dir}" 1>&2 else echo "system paraview (not found)" endif @@ -132,12 +150,10 @@ default: endsw setenv ParaView_DIR "$archDir/ParaView-$ParaView_VERSION" + set pv_plugin_dir="$FOAM_LIBBIN/paraview-$pv_api" # Set paths if binaries are present if ( -r "$ParaView_DIR" ) then - # The OpenFOAM plugin directory must be the first in PV_PLUGIN_PATH - # and have paraview-major.minor encoded in its name - setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api" setenv PATH "${ParaView_DIR}/bin:${PATH}" set pvLibDir="unknown" @@ -176,16 +192,24 @@ default: set pvLibDir="unknown" end + # OpenFOAM plugin directory must be the first in PV_PLUGIN_PATH + # and have paraview-major.minor encoded in its name + if ( -d "$pv_plugin_dir" ) then + setenv PV_PLUGIN_PATH "$pv_plugin_dir" + else + set pv_plugin_dir="${pv_plugin_dir} (missing)" # For message + endif + if ($?FOAM_VERBOSE && $?prompt) then echo "Using paraview" - echo " ParaView_DIR : $ParaView_DIR" - echo " library dir : $pvLibDir" - echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" + echo " ParaView_DIR : $ParaView_DIR" + echo " library : $pvLibDir" + echo " plugins : ${pv_plugin_dir}" endif else if ($?FOAM_VERBOSE && $?prompt) then echo "No paraview found" - echo " ParaView_DIR : $ParaView_DIR" + echo " ParaView_DIR : $ParaView_DIR" endif unsetenv PV_PLUGIN_PATH @@ -201,6 +225,6 @@ endif unsetenv ParaView_VERSION ParaView_QT unset archDir libDir -unset pv_api pvLibDir pvPython qtDir +unset pv_api pv_plugin_dir pvLibDir pvPython qtDir #------------------------------------------------------------------------------ diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases index 692d18fecb..47086dc60e 100644 --- a/etc/config.sh/aliases +++ b/etc/config.sh/aliases @@ -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/aliases @@ -102,8 +101,11 @@ unset -f foamPV 2>/dev/null foamPV() { . "$WM_PROJECT_DIR/etc/config.sh/paraview" "${@+ParaView_VERSION=$@}" - local pvdir="${ParaView_DIR##*/}" - echo "${pvdir:-ParaView_DIR not set}" 1>&2 + # If not already reported + if [ -z "$FOAM_VERBOSE" ] + then + echo "paraview=${ParaView_DIR##*/}" 1>&2 + fi } diff --git a/etc/config.sh/paraview b/etc/config.sh/paraview index 265869f960..f1b2eef6fc 100644 --- a/etc/config.sh/paraview +++ b/etc/config.sh/paraview @@ -50,6 +50,10 @@ # Note # When _foamAddLib is unset (eg, called from makeParaView or from foamPV): # - the ParaView_VERSION variable is retained. +# +# Additional Notes +# PV_PLUGIN_PATH is *only* set if the directory actually exists. +# #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade @@ -98,12 +102,13 @@ case "$ParaView_VERSION" in ;; (system) - unset PV_PLUGIN_PATH + unset ParaView_DIR PV_PLUGIN_PATH eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh -config paraview-system)" ;; (*) # ParaView_VERSION set and non-empty + unset ParaView_DIR PV_PLUGIN_PATH # Set API to correspond to VERSION # pv_api is . from ParaView_VERSION @@ -120,14 +125,11 @@ case "$ParaView_VERSION" in esac export ParaView_DIR="$archDir/ParaView-$ParaView_VERSION" - unset PV_PLUGIN_PATH + pv_plugin_dir="$FOAM_LIBBIN/paraview-$pv_api" # Set paths if binaries are present if [ -r "$ParaView_DIR" ] then - # The OpenFOAM plugin directory must be the first in PV_PLUGIN_PATH - # and have paraview-major.minor encoded in its name - export PV_PLUGIN_PATH="$FOAM_LIBBIN/paraview-$pv_api" export PATH="$ParaView_DIR/bin:$PATH" # QT libraries as required, and Qt5_DIR for the root directory. @@ -169,12 +171,21 @@ case "$ParaView_VERSION" in unset pvLibDir done + # OpenFOAM plugin directory must be the first in PV_PLUGIN_PATH + # and have paraview-major.minor encoded in its name + if [ -d "$pv_plugin_dir" ] + then + export PV_PLUGIN_PATH="$pv_plugin_dir" + else + pv_plugin_dir="${pv_plugin_dir} (missing)" # For message + fi + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using paraview" 1>&2 - echo " ParaView_DIR : $ParaView_DIR" 1>&2 - echo " library dir : $pvLibDir" 1>&2 - echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" 1>&2 + echo " ParaView_DIR : $ParaView_DIR" 1>&2 + echo " library : $pvLibDir" 1>&2 + echo " plugins : $pv_plugin_dir" 1>&2 fi else if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] @@ -183,7 +194,7 @@ case "$ParaView_VERSION" in echo " ParaView_DIR : $ParaView_DIR" 1>&2 fi - unset ParaView_DIR PV_PLUGIN_PATH + unset ParaView_DIR fi ;; esac @@ -197,6 +208,6 @@ then fi unset archDir libDir -unset pv_api pvLibDir pvPython qtDir +unset pv_api pv_plugin_dir pvLibDir pvPython qtDir #------------------------------------------------------------------------------ diff --git a/etc/config.sh/paraview-system b/etc/config.sh/paraview-system index 1bdec0f30d..3f1b569f0a 100644 --- a/etc/config.sh/paraview-system +++ b/etc/config.sh/paraview-system @@ -37,8 +37,9 @@ eval \ #------------------------------------------------------------------------------ ParaView_DIR="$(command -v paraview 2>/dev/null)" +unset PV_PLUGIN_PATH pv_plugin_dir -# Do have paraview? +# Have paraview? # Obtain major.minor from `paraview --version` if [ -n "$ParaView_DIR" ] then @@ -63,19 +64,26 @@ fi case "$pv_api" in ([0-9]*.[0-9]*) export ParaView_DIR - export PV_PLUGIN_PATH="$FOAM_LIBBIN/paraview-$pv_api" + pv_plugin_dir="$FOAM_LIBBIN/paraview-$pv_api" + + if [ -d "$pv_plugin_dir" ] + then + export PV_PLUGIN_PATH="$pv_plugin_dir" + else + pv_plugin_dir="${pv_plugin_dir} (missing)" # For message + fi ;; (*) - unset ParaView_DIR PV_PLUGIN_PATH + unset ParaView_DIR ;; esac if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then - if [ -n "$PV_PLUGIN_PATH" ] + if [ -n "$ParaView_DIR" ] then echo "Using paraview (system)" 1>&2 - echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" 1>&2 + echo " plugins : $pv_plugin_dir" 1>&2 else echo "system paraview (not found)" 1>&2 fi @@ -92,6 +100,6 @@ else fi unset archDir -unset pv_api +unset pv_api pv_plugin_dir #------------------------------------------------------------------------------