Skip to content
Snippets Groups Projects
Commit dd1c2edb authored by Mark OLESEN's avatar Mark OLESEN
Browse files

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.
parent 583905fd
Branches
Tags
No related merge requests found
......@@ -173,13 +173,18 @@ findObjectDir()
# Default (local) build directory
if [ -z "$objectsDir" ]
then
relativeDir="$absdir"
appDir=.
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
absdir=$(expandPath "$appDir"/.)
if [ -d "$absdir/Make" ]
then
objectsDir="${absdir}/Make/${WM_OPTIONS}"
else
relativeDir="$absdir"
appDir=.
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
absdir=$(expandPath "$appDir"/.)
relativeDir="${relativeDir#${absdir}}"
objectsDir="${appDir}/Make/${WM_OPTIONS}${relativeDir}"
relativeDir="${relativeDir#${absdir}}"
objectsDir="${appDir}/Make/${WM_OPTIONS}${relativeDir}"
fi
fi
echo "$objectsDir"
......
......@@ -313,16 +313,18 @@ 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
rm -rf "$objectsDir" 2>/dev/null
# 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
#------------------------------------------------------------------------------
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment