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,13 +173,18 @@ findObjectDir()
# Default (local) build directory # Default (local) build directory
if [ -z "$objectsDir" ] if [ -z "$objectsDir" ]
then then
relativeDir="$absdir" if [ -d "$absdir/Make" ]
appDir=. then
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal objectsDir="${absdir}/Make/${WM_OPTIONS}"
absdir=$(expandPath "$appDir"/.) else
relativeDir="$absdir"
appDir=.
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
absdir=$(expandPath "$appDir"/.)
relativeDir="${relativeDir#${absdir}}" relativeDir="${relativeDir#${absdir}}"
objectsDir="${appDir}/Make/${WM_OPTIONS}${relativeDir}" objectsDir="${appDir}/Make/${WM_OPTIONS}${relativeDir}"
fi
fi fi
echo "$objectsDir" echo "$objectsDir"

View File

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