From 7a90f5e6fbc31009ad47402cdef576324d6193c9 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Thu, 5 Jan 2017 16:22:07 +0100 Subject: [PATCH] ENH: add versioning to paraview plugin support libraries (issue #370) - use "-pvMAJ.MIN" suffix for similarity with the paraview convention - use sentinel file to ensure clean change of intermediate targets - ensure all library files are being properly removed --- .../graphics/PVReaders/Allwmake | 56 ++++++++++++++++- .../graphics/PVReaders/PVFoamReader/Allwclean | 8 +-- .../graphics/PVReaders/PVFoamReader/Allwmake | 63 +++++++++++++++++-- .../PVFoamReader/PVFoamReader/CMakeLists.txt | 2 +- .../PVFoamReader/vtkPVFoam/Make/files | 2 +- .../PVFoamReader/vtkPVFoam/Make/options | 4 +- .../PVReaders/PVblockMeshReader/Allwclean | 8 +-- .../PVReaders/PVblockMeshReader/Allwmake | 63 +++++++++++++++++-- .../PVblockMeshReader/CMakeLists.txt | 2 +- .../vtkPVblockMesh/Make/files | 2 +- .../vtkPVblockMesh/Make/options | 4 +- .../PVReaders/vtkPVReaders/Make/files | 2 +- .../PVReaders/vtkPVReaders/Make/options | 2 + .../graphics/runTimePostProcessing/Allwclean | 9 ++- .../graphics/runTimePostProcessing/Allwmake | 61 ++++++++++++++++-- wmake/rules/General/paraview | 8 +++ 16 files changed, 260 insertions(+), 36 deletions(-) create mode 100644 wmake/rules/General/paraview diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake index df34613a03a..c6ca055da06 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake @@ -7,6 +7,11 @@ export WM_CONTINUE_ON_ERROR=true # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments +# Source the wmake functions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions + +# ----------------------------------------------------------------------------- + # # There are several prerequisites for building plugins # @@ -34,6 +39,53 @@ canBuildPlugin() } +# +# Check sentinel file(s) to handle paraview version changes +# +versionOk() +{ + findObjectDir "$1" # Where generated files are stored + local sentinel="$objectsDir/ThirdParty" + + echo $sentinel + + local prev + if read -r prev 2>/dev/null < $sentinel + then + case "$prev" in + ("ParaView_DIR=$ParaView_DIR") + return 0 + ;; + (*) + echo "ParaView_DIR changed between builds" 1>&2 + return 1 + ;; + esac + elif [ -f "$objectsDir/CMakeCache.txt" ] + then + echo "previous build was incomplete" 1>&2 + return 1 + else + return 0 + fi +} + + +# +# Build library - use sentinel file(s) to handle paraview version changes +# +wmakeLibPv() +{ + for libName + do + sentinel=$(versionOk $libName) || wclean $libName # version changed + wmake $targetType $libName && { + echo "ParaView_DIR=$ParaView_DIR" > $sentinel + } + done +} + + # ----------------------------------------------------------------------------- # major version as per paraview include directory: @@ -45,9 +97,9 @@ case "$major" in if canBuildPlugin then ( - wmake $targetType vtkPVReaders + wmakeLibPv vtkPVReaders PVblockMeshReader/Allwmake $targetType $* - PVFoamReader/Allwmake $targetType $* + PVFoamReader/Allwmake $targetType $* # Dummy directory to trigger proper 'wclean all' behaviour # - the Allwclean will otherwise not be used diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean index f0cd56dee20..4df5195cb12 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean @@ -2,17 +2,15 @@ cd ${0%/*} || exit 1 # Run from this directory # Source the wmake functions -. $WM_DIR/scripts/wmakeFunctions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions -#set -x - -# deal with client/server vs combined plugins +# Cleanup client-server and/or combined plugins rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null rm -rf PVFoamReader/Make # safety: old build location wclean libso vtkPVFoam -# Where are the generated files stored? +# Cleanup generated files findObjectDir $PWD # remove entire top-level rm -rf "$objectsDir" > /dev/null 2>&1 diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake index 7788998933d..afba137322b 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake @@ -5,20 +5,56 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # Source the wmake functions -. $WM_DIR/scripts/wmakeFunctions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Ensure CMake gets the correct C/C++ compilers [ -n "$WM_CC" ] && export CC="$WM_CC" [ -n "$WM_CXX" ] && export CXX="$WM_CXX" +# ----------------------------------------------------------------------------- + +# +# Check sentinel file(s) to handle paraview version changes +# +versionOk() +{ + findObjectDir "$1" # Where generated files are stored + local sentinel="$objectsDir/ThirdParty" + + echo $sentinel + + local prev + if read -r prev 2>/dev/null < $sentinel + then + case "$prev" in + ("ParaView_DIR=$ParaView_DIR") + return 0 + ;; + (*) + echo "ParaView_DIR changed between builds" 1>&2 + return 1 + ;; + esac + elif [ -f "$objectsDir/CMakeCache.txt" ] + then + echo "previous build was incomplete" 1>&2 + return 1 + else + return 0 + fi +} + # CMake into objectsDir, # with an additional attempt if (possibly incorrect) CMakeCache.txt existed doCmake() { local sourceDir="$1" - findObjectDir $sourceDir # Where are generated files stored? + + # version changed + sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1 + test -f "$objectsDir/CMakeCache.txt" retry=$? # CMakeCache.txt exists, but sources may have moved @@ -35,14 +71,33 @@ doCmake() else exit 1 fi - } && make + } && make && { + echo "ParaView_DIR=$ParaView_DIR" > $sentinel + } ) } +# +# Build library - use sentinel file(s) to handle paraview version changes +# +wmakeLibPv() +{ + for libName + do + sentinel=$(versionOk $libName) || wclean $libName # version changed + wmake $targetType $libName && { + echo "ParaView_DIR=$ParaView_DIR" > $sentinel + } + done +} + + +# ----------------------------------------------------------------------------- + if [ -d "$ParaView_DIR" ] then - wmake $targetType vtkPVFoam + wmakeLibPv vtkPVFoam if [ "$targetType" != objects ] then diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/CMakeLists.txt index 6671a5d179b..40745ba9285 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/PVFoamReader/CMakeLists.txt @@ -62,7 +62,7 @@ add_paraview_plugin( target_link_libraries( PVFoamReader_SM LINK_PUBLIC - vtkPVFoam + vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR} finiteVolume OpenFOAM ) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/files b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/files index b26829761d7..6f9412f0af7 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/files +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/files @@ -8,4 +8,4 @@ vtkPVFoamMeshZone.C vtkPVFoamUpdateInfo.C vtkPVFoamUtils.C -LIB = $(FOAM_LIBBIN)/libvtkPVFoam +LIB = $(FOAM_LIBBIN)/libvtkPVFoam-pv${ParaView_MAJOR} diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/options b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/options index 0154a3bcbac..aa2b9039da5 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/options +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/Make/options @@ -1,3 +1,5 @@ +sinclude $(GENERAL_RULES)/paraview + EXE_INC = \ ${c++LESSWARN} \ -I$(LIB_SRC)/meshTools/lnInclude \ @@ -16,5 +18,5 @@ LIB_LIBS = \ -lconversion \ -lgenericPatchFields \ -llagrangian \ - -L$(FOAM_LIBBIN) -lvtkPVReaders \ + -L$(FOAM_LIBBIN) -lvtkPVReaders-pv${ParaView_MAJOR} \ $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean index 3a81901a0bb..8e0fd1a41a0 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean @@ -2,17 +2,15 @@ cd ${0%/*} || exit 1 # Run from this directory # Source the wmake functions -. $WM_DIR/scripts/wmakeFunctions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions -#set -x - -# deal with client/server vs combined plugins +# Cleanup client-server and/or combined plugins rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null rm -rf PVblockMeshReader/Make # safety: old build location wclean libso vtkPVblockMesh -# Where are the generated files stored? +# Cleanup generated files findObjectDir $PWD # remove entire top-level rm -rf "$objectsDir" > /dev/null 2>&1 diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake index 607a6cb8e3c..844b1293062 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake @@ -5,20 +5,56 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # Source the wmake functions -. $WM_DIR/scripts/wmakeFunctions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Ensure CMake gets the correct C/C++ compilers [ -n "$WM_CC" ] && export CC="$WM_CC" [ -n "$WM_CXX" ] && export CXX="$WM_CXX" +# ----------------------------------------------------------------------------- + +# +# Check sentinel file(s) to handle paraview version changes +# +versionOk() +{ + findObjectDir "$1" # Where generated files are stored + local sentinel="$objectsDir/ThirdParty" + + echo $sentinel + + local prev + if read -r prev 2>/dev/null < $sentinel + then + case "$prev" in + ("ParaView_DIR=$ParaView_DIR") + return 0 + ;; + (*) + echo "ParaView_DIR changed between builds" 1>&2 + return 1 + ;; + esac + elif [ -f "$objectsDir/CMakeCache.txt" ] + then + echo "previous build was incomplete" 1>&2 + return 1 + else + return 0 + fi +} + # CMake into objectsDir, # with an additional attempt if (possibly incorrect) CMakeCache.txt existed doCmake() { local sourceDir="$1" - findObjectDir $sourceDir # Where are generated files stored? + + # version changed + sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1 + test -f "$objectsDir/CMakeCache.txt" retry=$? # CMakeCache.txt exists, but sources may have moved @@ -35,14 +71,33 @@ doCmake() else exit 1 fi - } && make + } && make && { + echo "ParaView_DIR=$ParaView_DIR" > $sentinel + } ) } +# +# Build library - use sentinel file(s) to handle paraview version changes +# +wmakeLibPv() +{ + for libName + do + sentinel=$(versionOk $libName) || wclean $libName # version changed + wmake $targetType $libName && { + echo "ParaView_DIR=$ParaView_DIR" > $sentinel + } + done +} + + +# ----------------------------------------------------------------------------- + if [ -d "$ParaView_DIR" ] then - wmake $targetType vtkPVblockMesh + wmakeLibPv vtkPVblockMesh if [ "$targetType" != objects ] then diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/CMakeLists.txt index 0ee611b0ed9..6e756647903 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/PVblockMeshReader/CMakeLists.txt @@ -62,7 +62,7 @@ add_paraview_plugin( target_link_libraries( PVblockMeshReader_SM LINK_PUBLIC - vtkPVblockMesh + vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR} blockMesh OpenFOAM ) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/files b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/files index e6e4fb230e5..b3a5e2fdf8b 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/files +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/files @@ -2,4 +2,4 @@ vtkPVblockMesh.C vtkPVblockMeshConvert.C vtkPVblockMeshUtils.C -LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh +LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh-pv${ParaView_MAJOR} diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/options b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/options index 79abf2d7fc4..f8fc1e5877c 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/options +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/Make/options @@ -1,3 +1,5 @@ +sinclude $(GENERAL_RULES)/paraview + EXE_INC = \ ${c++LESSWARN} \ -I$(LIB_SRC)/meshTools/lnInclude \ @@ -12,5 +14,5 @@ LIB_LIBS = \ -lmeshTools \ -lfileFormats \ -lblockMesh \ - -L$(FOAM_LIBBIN) -lvtkPVReaders \ + -L$(FOAM_LIBBIN) -lvtkPVReaders-pv${ParaView_MAJOR} \ $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/files b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/files index e26a8c4979e..bce3910d9dc 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/files +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/files @@ -1,3 +1,3 @@ vtkPVReaders.C -LIB = $(FOAM_LIBBIN)/libvtkPVReaders +LIB = $(FOAM_LIBBIN)/libvtkPVReaders-pv${ParaView_MAJOR} diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/options b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/options index d84fae1560c..39510d9f57d 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/options +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVReaders/Make/options @@ -1,3 +1,5 @@ +sinclude $(GENERAL_RULES)/paraview + EXE_INC = \ ${c++LESSWARN} \ -I$(ParaView_INCLUDE_DIR) \ diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwclean b/src/functionObjects/graphics/runTimePostProcessing/Allwclean index 1d94a698c53..00ff12fadbb 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwclean +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwclean @@ -2,10 +2,13 @@ cd ${0%/*} || exit 1 # Run from this directory # Source the wmake functions -. $WM_DIR/scripts/wmakeFunctions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions -# Where are the generated files stored? -findObjectDir $PWD +# Cleanup library +rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null + +# Cleanup generated files +findObjectDir $PWD # remove entire top-level rm -rf "$objectsDir" > /dev/null 2>&1 #------------------------------------------------------------------------------ diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwmake b/src/functionObjects/graphics/runTimePostProcessing/Allwmake index 4b2ad8b107f..66ba0b7cc1a 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwmake +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwmake @@ -2,23 +2,56 @@ cd ${0%/*} || exit 1 # Run from this directory # Source the wmake functions -. $WM_DIR/scripts/wmakeFunctions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Ensure CMake gets the correct C/C++ compilers [ -n "$WM_CC" ] && export CC="$WM_CC" [ -n "$WM_CXX" ] && export CXX="$WM_CXX" -echo "======================================================================" -echo "${PWD##*/} : $PWD" -echo +# ----------------------------------------------------------------------------- + +# +# Check sentinel file(s) to handle vtk/paraview version changes +# +versionOk() +{ + findObjectDir "$1" # Where generated files are stored + local sentinel="$objectsDir/ThirdParty" + + echo $sentinel + + local prev + if read -r prev 2>/dev/null < $sentinel + then + case "$prev" in + ("ParaView_DIR=$ParaView_DIR" | "VTK_DIR=$VTK_DIR") + return 0 + ;; + (*) + echo "ParaView_DIR or VTK_DIR changed between builds" 1>&2 + return 1 + ;; + esac + elif [ -f "$objectsDir/CMakeCache.txt" ] + then + echo "previous build was incomplete" 1>&2 + return 1 + else + return 0 + fi +} + # CMake into objectsDir, # with an additional attempt if (possibly incorrect) CMakeCache.txt existed doCmake() { local sourceDir="$1" - findObjectDir $sourceDir # Where are generated files stored? + + # version changed + sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1 + test -f "$objectsDir/CMakeCache.txt" retry=$? # CMakeCache.txt exists, but sources may have moved @@ -35,11 +68,27 @@ doCmake() else exit 1 fi - } && make + } && make && { + if [ -d "$VTK_DIR" ] + then + echo "VTK_DIR=$VTK_DIR" + elif [ -d "$ParaView_DIR" ] + then + echo "ParaView_DIR=$ParaView_DIR" + else + echo unknown + fi > $sentinel + } ) } +# ----------------------------------------------------------------------------- + +echo "======================================================================" +echo "${PWD##*/} : $PWD" +echo + if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ] then if [ "$targetType" != objects ] diff --git a/wmake/rules/General/paraview b/wmake/rules/General/paraview new file mode 100644 index 00000000000..1df6ded1bc9 --- /dev/null +++ b/wmake/rules/General/paraview @@ -0,0 +1,8 @@ +#-------------------------------*- makefile -*--------------------------------- +# paraview values + +# major.minor: eg, /path/paraview-5.0 -> 5.0 +# +ParaView_MAJOR := $(shell echo $(ParaView_INCLUDE_DIR) | sed -e 's/^.*-//') + +#------------------------------------------------------------------------------ -- GitLab