COMP: wmake findObjectDir fails for non-project directories (fixes #1807)

- experienced while reusing src/Pstream/Allwmake-mpi to create
  additional mpi-layers after installation. Since the copied sources
  are not located within the OpenFOAM source-tree (and/or the
  source-tree is non-writable), it should not and does not use the
  central build/WM_OPTIONS directory.

  However, when exploring for the appropriate local Make directory, it
  searched for the current '.' directory instead of checking for the
  resolved directory.

  This fails, since there is no src/Pstream/Make directory.
  Must check for src/Pstream/mpi/Make directory first!

- Adjust wclean to always remove a local build directory
  (Make/WM_OPTIONS) for additional safety.
  After which, attempt to remove central build/WM_OPTIONS version too.
This commit is contained in:
Mark Olesen
2020-08-12 12:15:27 +02:00
parent 583905fdeb
commit dd1c2edb6b
2 changed files with 22 additions and 15 deletions

View File

@ -173,6 +173,10 @@ findObjectDir()
# Default (local) build directory
if [ -z "$objectsDir" ]
then
if [ -d "$absdir/Make" ]
then
objectsDir="${absdir}/Make/${WM_OPTIONS}"
else
relativeDir="$absdir"
appDir=.
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
@ -181,6 +185,7 @@ findObjectDir()
relativeDir="${relativeDir#${absdir}}"
objectsDir="${appDir}/Make/${WM_OPTIONS}${relativeDir}"
fi
fi
echo "$objectsDir"
}

View File

@ -313,17 +313,19 @@ fi
# Clean the 'Make' directory if present
#------------------------------------------------------------------------------
if [ -d "$MakeDir" ]
if [ -d "$MakeDir" ] && [ -n "$WM_OPTIONS" ]
then
objectsDir="$MakeDir/$WM_OPTIONS"
case "$PWD" in
("$WM_PROJECT_DIR"/*)
buildPath="$WM_PROJECT_DIR/build/${WM_OPTIONS}"
objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% )
;;
esac
# Remove in-source directory (if any)
rm -rf "$MakeDir/$WM_OPTIONS" 2>/dev/null
# Remove out-of-source directory (if applicable)
relativeDir="${PWD#${WM_PROJECT_DIR}/}"
if [ "$relativeDir" != "$PWD" ]
then
objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}"
rm -rf "$objectsDir" 2>/dev/null
fi
fi
#------------------------------------------------------------------------------
# Remove the lnInclude directory if present