ENH: improve isolation of shell variables in wmake scripts

- reduces unexpected interactions between various make elements
This commit is contained in:
Mark Olesen
2017-02-10 16:13:54 +01:00
committed by mark
parent e82a029453
commit 3d02c8a530
14 changed files with 201 additions and 185 deletions

View File

@ -10,8 +10,7 @@ rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null
rm -rf PVFoamReader/Make # safety: old build location rm -rf PVFoamReader/Make # safety: old build location
wclean libso vtkPVFoam wclean libso vtkPVFoam
# Cleanup generated files # Cleanup generated files - remove entire top-level
findObjectDir $PWD # remove entire top-level removeObjectDir $PWD
rm -rf "$objectsDir" > /dev/null 2>&1
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -10,8 +10,7 @@ rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null
rm -rf PVblockMeshReader/Make # safety: old build location rm -rf PVblockMeshReader/Make # safety: old build location
wclean libso vtkPVblockMesh wclean libso vtkPVblockMesh
# Cleanup generated files # Cleanup generated files - remove entire top-level
findObjectDir $PWD # remove entire top-level removeObjectDir $PWD
rm -rf "$objectsDir" > /dev/null 2>&1
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -10,16 +10,17 @@ cd ${0%/*} || exit 1 # Run from this directory
# use sentinel file to handle version changes # use sentinel file to handle version changes
wmakeMpiLib() wmakeMpiLib()
{ {
local objectsDir
for libName for libName
do do
( (
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
libDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/Pstream/$libName" objectsDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/Pstream/$libName"
whichmpi="$libDir/using:$FOAM_MPI" whichmpi="$objectsDir/using:$FOAM_MPI"
[ -e "$whichmpi" ] || wclean $libName [ -e "$whichmpi" ] || wclean $libName
echo "wmake $targetType $libName" echo "wmake $targetType $libName"
wmake $targetType $libName wmake $targetType $libName
mkdir -p "$libDir" mkdir -p "$objectsDir"
touch "$whichmpi" touch "$whichmpi"
) )
done done

View File

@ -7,8 +7,7 @@ cd ${0%/*} || exit 1 # Run from this directory
# Cleanup library # Cleanup library
rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null
# Cleanup generated files # Cleanup generated files - remove entire top-level
findObjectDir $PWD # remove entire top-level removeObjectDir $PWD
rm -rf "$objectsDir" > /dev/null 2>&1
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -20,8 +20,6 @@ wcleanMpiLib()
do do
( (
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
whichmpi="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName/using:$FOAM_MPI"
whichscotch="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName/using:$SCOTCH_VERSION"
wclean $libName wclean $libName
) )
done done

View File

@ -126,18 +126,19 @@ hasScotch()
wmakeMpiLib() wmakeMpiLib()
{ {
local decompName="$1" local decompName="$1"
local objectsDir
shift shift
for libName for libName
do do
( (
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
libDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName" objectsDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName"
whichmpi="$libDir/using:$FOAM_MPI" whichmpi="$objectsDir/using:$FOAM_MPI"
whichdecomp="$libDir/using:$decompName" whichdecomp="$objectsDir/using:$decompName"
[ -e "$whichmpi" -a -e "$whichdecomp" ] || wclean $libName [ -e "$whichmpi" -a -e "$whichdecomp" ] || wclean $libName
echo "wmake $targetType $libName" echo "wmake $targetType $libName"
wmake $targetType $libName wmake $targetType $libName
mkdir -p "$libDir" mkdir -p "$objectsDir"
touch "$whichdecomp" "$whichmpi" touch "$whichdecomp" "$whichmpi"
) )
done done

View File

@ -44,12 +44,15 @@
sameDependency() sameDependency()
{ {
local depend="$1" local depend="$1"
findObjectDir "$2" # Where generated files are stored local sourceDir="$2"
local sentinel="$objectsDir/ThirdParty" local objectsDir sentinel prev
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
sentinel="$objectsDir/ThirdParty"
echo $sentinel echo $sentinel
local prev
if read -r prev 2>/dev/null < $sentinel if read -r prev 2>/dev/null < $sentinel
then then
if [ "$prev" = "$depend" ] if [ "$prev" = "$depend" ]
@ -70,35 +73,24 @@ sameDependency()
# CMake into objectsDir with external dependency # CMake into objectsDir with external dependency
# - use sentinel file(s) to handle paraview/vtk version changes
cmakeVersioned() cmakeVersioned()
{ {
local depend="$1" local depend="$1"
local sourceDir="$2" local sourceDir="$2"
findObjectDir $sourceDir # Where are generated files stored? local objectsDir sentinel
local sentinel # Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# version changed # Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") \ sentinel=$(sameDependency "$depend" "$sourceDir") || \
|| rm -rf "$objectsDir" > /dev/null 2>&1 rm -rf "$objectsDir" > /dev/null 2>&1
test -f "$objectsDir/CMakeCache.txt"
retry=$? # Additional attempt if sources moved
mkdir -p $objectsDir && \ mkdir -p $objectsDir && \
( (
cd $objectsDir || exit 1 cd $objectsDir && cmake $sourceDir && make \
&& echo "$depend" > ${sentinel:-/dev/null}
cmake $sourceDir || {
if [ $retry -eq 0 ]
then
echo "Removing CMakeCache.txt and attempt again" 1>&2
rm -f CMakeCache.txt
cmake $sourceDir
else
exit 1
fi
} && make && { echo "$depend" > $sentinel; }
) )
} }
@ -127,9 +119,11 @@ wmakeLibPv()
for libName for libName
do do
# version changed sentinel=$(sameDependency "$depend" $libName) || \
sentinel=$(sameDependency "$depend" $libName) || wclean $libName wclean $libName
wmake $targetType $libName && { echo "$depend" > $sentinel; }
wmake $targetType $libName \
&& echo "$depend" > ${sentinel:-/dev/null}
done done
} }

View File

@ -28,6 +28,11 @@
# Functions to check wmake environment and find .dep and .o files # Functions to check wmake environment and find .dep and .o files
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Ensure these variables are always defined
MakeDir=Make
: ${Script:=wmakeFunctions}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Check environment variables # Check environment variables
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -52,78 +57,83 @@ checkEnv()
# expandPath dirName # expandPath dirName
# expandPath fileName # expandPath fileName
# #
# Sets: # Output:
# - exPath # - the expanded path name
expandPath() expandPath()
{ {
if [ -d "$1" ] if [ -d "$1" ]
then then
exPath=$(cd "$1" && pwd -P) (cd "$1" && pwd -P)
elif [ -n "$1" ]
then
(cd $(dirname "$1") && pwd -P)
else else
exPath=$(cd $(dirname "$1") && pwd -P) pwd -P
fi fi
} }
# Find the target directory # Find the target directory, which contains a Make/ directory
# search upwards in its parent directories, but stopping
# when it hits the project root, home, or the file-system root
#
# findTarget dirName # findTarget dirName
# findTarget fileName
# #
# Sets: # Output:
# - dir # - the relative target directory
#
# Side-effect variables:
# - sets exPath
# - sets wmpdir
# #
# Global variables used: # Global variables used:
# - WM_PROJECT_DIR, HOME # - WM_PROJECT_DIR, HOME
findTarget() findTarget()
{ {
expandPath $WM_PROJECT_DIR local wmpdir=$(expandPath $WM_PROJECT_DIR)
wmpdir=$exPath local home=$(expandPath $HOME)
expandPath $1 local reldir="${1:-.}"
local absdir=$(expandPath $reldir)
if [ "$exPath" = "$wmpdir" \ while [ -n "$absdir" ]
-o "$exPath" = "$HOME" \ do
-o "$exPath" = "/" \ case "$absdir" in
] ($wmpdir | $home | /)
then break
echo "$Script error: could not find Make directory" 1>&2 ;;
exit 1 esac
elif [ -d "$1/Make" ]
then if [ -d "$reldir/Make" ]
dir=$1 then
else echo "$reldir"
findTarget "$1/.." return 0
fi else
# Check parent directory
absdir="${absdir%/*}"
reldir="$reldir/.."
fi
done
echo "Error: no Make directory for $(expandPath $1)" 1>&2
echo 1>&2
return 1
} }
# Change to 'MakeDir'
# - 'MakeDir' for its input # Change to 'MakeDir' parent
# - uses 'MakeDir' for its input
# #
# Sets: # Side-effects:
# - dir
#
# Side-effect variables:
# - sets exPath
# - unsets targetType # - unsets targetType
cdSource() cdSource()
{ {
if [ ! -d $MakeDir ] local dir
if [ ! -d "$MakeDir" ]
then then
echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2 echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2
echo " Searching up directories tree for Make directory" 1>&2 echo " Searching up directories tree for Make directory" 1>&2
dir=$(findTarget .) || exit 1 # Fatal
cd $dir 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
unset targetType unset targetType
findTarget .
if [ "$dir" ]
then
cd $dir 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
fi
fi fi
[ -r $MakeDir/files ] || { [ -r $MakeDir/files ] || {
@ -137,48 +147,58 @@ cdSource()
# findObjectDir dirName # findObjectDir dirName
# findObjectDir fileName # findObjectDir fileName
# #
# Sets: # Output:
# - dir # - the objectsDir
# - path
# - appDir
# - objectsDir
#
# Side-effect variables:
# - sets exPath
# - sets wmpdir
# - set platformPath
# #
# Global variables used: # Global variables used:
# - WM_PROJECT_DIR, WM_OPTIONS # - WM_PROJECT_DIR, WM_OPTIONS
findObjectDir() findObjectDir()
{ {
expandPath $WM_PROJECT_DIR local wmpdir=$(expandPath $WM_PROJECT_DIR)
wmpdir=$exPath local exPath=$(expandPath ${1:-.})
expandPath $1 local objectsDir
if echo $exPath | grep "$wmpdir" > /dev/null case "$exPath" in
then ("$wmpdir"/*)
platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} local buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
objectsDir=$platformPath$(echo $exPath | sed s%$wmpdir%% ) objectsDir=$buildPath$(echo $exPath | sed s%$wmpdir%% )
else ;;
path=$exPath (*)
dir=. local path=$exPath
if [ ! -d Make ] local appDir=.
then [ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
findTarget . exPath=$(expandPath $appDir/.)
fi
appDir=$dir
expandPath $appDir/.
objectsDir=$appDir/Make/${WM_OPTIONS}$(echo $path | sed s%$exPath%% ) objectsDir=$appDir/Make/${WM_OPTIONS}$(echo $path | sed s%$exPath%% )
;;
esac
echo "$objectsDir"
}
# Find the object directory and remove it
# removeObjectDir dirName
# removeObjectDir fileName
#
# Output:
# - NONE
#
# Global variables used:
# - WM_PROJECT_DIR, WM_OPTIONS
removeObjectDir()
{
local objectsDir=$(findObjectDir ${1:-.})
if [ -d "$objectsDir" ]
then
rm -rf "$objectsDir" > /dev/null 2>&1
fi fi
} }
# depToSource # depToSource depFile
# - uses 'depFile' for its input
# #
# Sets: # Output:
# - sourceFile # - the sourceFile corresponding to depFile
# #
# Global variables used: # Global variables used:
# - WM_OPTIONS # - WM_OPTIONS
@ -187,20 +207,24 @@ if [ -n "$BASH_VERSION" ]
then then
depToSource() depToSource()
{ {
sourceFile=${depFile%.dep} local sourceFile=${1%.dep}
sourceFile="${sourceFile/platforms\/${WM_OPTIONS}\//}" sourceFile="${sourceFile/platforms\/${WM_OPTIONS}\//}"
sourceFile="${sourceFile/Make\/${WM_OPTIONS}\//}"
sourceFile="${sourceFile/platforms\/${WM_OPTIONS}${WM_MPLIB}\//}" sourceFile="${sourceFile/platforms\/${WM_OPTIONS}${WM_MPLIB}\//}"
sourceFile="${sourceFile/Make\/${WM_OPTIONS}\//}"
sourceFile="${sourceFile/Make\/${WM_OPTIONS}${WM_MPLIB}\//}" sourceFile="${sourceFile/Make\/${WM_OPTIONS}${WM_MPLIB}\//}"
echo "$sourceFile"
} }
else else
depToSource() depToSource()
{ {
sourceFile=$(echo ${depFile%.dep} | \ local sourceFile=$(echo ${1%.dep} | \
sed -e s%platforms/${WM_OPTIONS}/%% \ sed -e s%platforms/${WM_OPTIONS}/%% \
-e s%Make/${WM_OPTIONS}/%% \
-e s%platforms/${WM_OPTIONS}${WM_MPLIB}/%% \ -e s%platforms/${WM_OPTIONS}${WM_MPLIB}/%% \
-e s%Make/${WM_OPTIONS}/%% \
-e s%Make/${WM_OPTIONS}${WM_MPLIB}/%% ) -e s%Make/${WM_OPTIONS}${WM_MPLIB}/%% )
echo "$sourceFile"
} }
fi fi

View File

@ -47,6 +47,7 @@ Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]] $Script [OPTION] target [dir [MakeDir]]
options: options:
-a | -all Same as the 'all' target
-s | -silent Ignored - for compatibility with wmake -s | -silent Ignored - for compatibility with wmake
-help Print the usage -help Print the usage
@ -67,19 +68,23 @@ USAGE
exit 1 exit 1
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Parse arguments and options # Parse arguments and options
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset dir targetType
MakeDir=Make
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-a | -all | all)
targetType=all
;;
-s | -silent) # Ignored - for compatibility with wmake -s | -silent) # Ignored - for compatibility with wmake
shift
;; ;;
-*) -*)
usage "unknown option: '$1'" usage "unknown option: '$1'"
@ -88,16 +93,14 @@ do
break break
;; ;;
esac esac
shift
done done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Check arguments and change to the directory in which to run wclean # Check arguments and change to the directory in which to run wclean.
# The variables 'targetType' and 'MakeDir' are considered global
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset dir targetType
MakeDir=Make
if [ $# -ge 1 ] if [ $# -ge 1 ]
then then
if [ -d "$1" ] if [ -d "$1" ]
@ -132,7 +135,7 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# If target not specified search up the directory tree for the Make # If target not specified search up the directory tree for the Make
# sub-directory, check the existance of the 'files' file and clean there if # sub-directory, check the existence of the 'files' file and clean there if
# present # present
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -159,12 +162,11 @@ then
# Second pass: clean up object directories with WM_PROJECT_DIR that don't # Second pass: clean up object directories with WM_PROJECT_DIR that don't
# have respective source code folders, along with the respective binaries # have respective source code folders, along with the respective binaries
expandPath $PWD if [ "$(expandPath $PWD)" = "$WM_PROJECT_DIR" ]
if [ "$exPath" = "$WM_PROJECT_DIR" ]
then then
findObjectDir $PWD objectsDir=$(findObjectDir $PWD) || exit 1 # Fatal
if [ -d $objectsDir ] if [ -d "$objectsDir" ]
then then
echo " Removing redundant object directories in $objectsDir" echo " Removing redundant object directories in $objectsDir"
@ -173,7 +175,7 @@ then
do do
# Hack'ish way of getting the original source code path # Hack'ish way of getting the original source code path
depFile=$(dirname $variablesFile) depFile=$(dirname $variablesFile)
depToSource $depFile sourceFile=$(depToSource $depFile)
# Check if the original source code directory exists # Check if the original source code directory exists
if [ ! -r "$sourceFile" ] if [ ! -r "$sourceFile" ]
@ -227,43 +229,40 @@ then
then then
./Allclean ./Allclean
exit $? exit $?
else
# For all the sub-directories containing a 'Make' directory
for dir in `find . \( -type d -a -name Make \)`
do
dir=${dir%/Make} # Parent directory - trim /Make from the end
# If Allwclean exists execute otherwise wclean
if [ -e "$dir/Allwclean" ]
then
$dir/Allwclean
else
$0 $dir
fi
done
fi fi
fi
# targetType is not needed beyond this point # For all sub-directories containing a 'Make' directory
unset targetType for dir in $(find . -type d -name Make)
do
dir=${dir%/*} # Parent directory containing the Make directory
# Use Allwclean if it exists, otherwise wclean
if [ -e "$dir/Allwclean" ]
then
$dir/Allwclean
else
$0 $dir
fi
done
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Clean the 'Make' directory if present # Clean the 'Make' directory if present
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ -d $MakeDir ] if [ -d "$MakeDir" ]
then then
objectsDir=$MakeDir/$WM_OPTIONS objectsDir=$MakeDir/$WM_OPTIONS
if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ] case "$PWD" in
then ("$WM_PROJECT_DIR"/*)
buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%%) objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% )
fi ;;
esac
rm -rf $objectsDir 2>/dev/null rm -rf $objectsDir 2>/dev/null
fi fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Remove the lnInclude directory if present # Remove the lnInclude directory if present
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -103,10 +103,10 @@ else
[ -n "$platform" ] || continue [ -n "$platform" ] || continue
fi fi
if [ -d platforms/${platform} ] if [ -d "platforms/$platform" ]
then then
echo "Cleaning platform $platform" echo "Cleaning platform $platform"
rm -rf platforms/${platform}* rm -rf "platforms/$platform"*
else else
echo "Platform $platform not built" echo "Platform $platform not built"
fi fi

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -105,8 +105,7 @@ fi
# and echo path for the dep file corresponding to the specified source file # and echo path for the dep file corresponding to the specified source file
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
findObjectDir $sourceFile echo "$(findObjectDir $sourceFile)/${sourceFile##*/}.dep"
echo "$objectsDir/${sourceFile##*/}.dep"
exit 0 # clean exit exit 0 # clean exit

View File

@ -239,7 +239,8 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Check arguments and change to the directory in which to run wmake # Check arguments and change to the directory in which to run wmake.
# The variables 'targetType' and 'MakeDir' are considered global
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset dir targetType unset dir targetType
@ -352,7 +353,7 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Search up the directory tree for the Make sub-directory, # Search up the directory tree for the Make sub-directory,
# check the existance of the 'files' file and build there if present # check the existence of the 'files' file and build there if present
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
cdSource cdSource
@ -387,11 +388,12 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
objectsDir=$MakeDir/$WM_OPTIONS objectsDir=$MakeDir/$WM_OPTIONS
if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ] case "$PWD" in
then ("$WM_PROJECT_DIR"/*)
buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%%) objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% )
fi ;;
esac
( (
unset MAKEFLAGS unset MAKEFLAGS

View File

@ -141,7 +141,7 @@ files)
# Remove the selected .dep files from the object tree # Remove the selected .dep files from the object tree
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
findObjectDir . objectsDir=$(findObjectDir .) || exit 1 # Fatal
# With the -a/-all option replace the current platform with a wildcard # With the -a/-all option replace the current platform with a wildcard
if [ "$all" = all ] if [ "$all" = all ]
@ -152,14 +152,15 @@ files)
if [ "$#" -eq 0 ] if [ "$#" -eq 0 ]
then then
echo "removing all .dep files ..." echo "removing all .dep files ..."
find $objectsDir -name '*.dep' -print | xargs -t rm 2>/dev/null find $objectsDir -type f -name '*.dep' -print | xargs -t rm 2>/dev/null
else else
echo "removing .o files corresponding to" echo "removing .o files corresponding to"
echo " $@ ..." echo " $@ ..."
for file for file
do do
find $objectsDir -name '*.dep' -exec grep -q "$file" '{}' \; \ find $objectsDir -type f -name '*.dep' \
-exec rm '{}' \; -print -exec grep -q "$file" '{}' \; \
-exec rm '{}' \; -print
done done
fi fi
;; ;;
@ -172,9 +173,9 @@ oldFolders)
for checkDir for checkDir
do do
findObjectDir $checkDir objectsDir=$(findObjectDir $checkDir)
if [ -d $objectsDir ] if [ -d "$objectsDir" ]
then then
echo " searching: $objectsDir" echo " searching: $objectsDir"
else else
@ -182,9 +183,9 @@ oldFolders)
continue continue
fi fi
find $objectsDir -name '*.dep' -print | while read depFile find $objectsDir -type f -name '*.dep' -print | while read depFile
do do
depToSource $depFile sourceFile=$(depToSource $depFile)
# Check C++ or Flex source file exists # Check C++ or Flex source file exists
if [ ! -r "$sourceFile" ] if [ ! -r "$sourceFile" ]
@ -204,7 +205,7 @@ updateMode)
fi fi
echo "Removing dep files corresponding to source files that no longer exist..." echo "Removing dep files corresponding to source files that no longer exist..."
fileNameList=$(find -L src applications -name '*.[CHL]' -type l) fileNameList=$(find -L src applications -type l -name '*.[CHL]')
for filePathAndName in $fileNameList for filePathAndName in $fileNameList
do do

View File

@ -62,7 +62,7 @@ USAGE
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Default to processing only the current platform # Default to processing only the current platform
unset all unset platform
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
@ -72,7 +72,7 @@ do
;; ;;
# All platforms # All platforms
-a | -all | all) -a | -all | all)
all=all platform=all
shift shift
;; ;;
-*) -*)
@ -92,10 +92,10 @@ checkEnv
# Remove the selected .o files from the object tree # Remove the selected .o files from the object tree
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
findObjectDir . objectsDir=$(findObjectDir .) || exit 1 # Fatal
# With the -a/-all option replace the current platform with a wildcard # With the -a/-all option replace the current platform with a wildcard
if [ "$all" = all ] if [ "$platform" = all ]
then then
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% ) objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% )
fi fi
@ -103,7 +103,7 @@ fi
if [ "$#" -eq 0 ] if [ "$#" -eq 0 ]
then then
echo "removing all .o files ..." echo "removing all .o files ..."
find $objectsDir -name '*.o' -print | xargs -t rm 2>/dev/null find $objectsDir -type f -name '*.o' -print | xargs -t rm 2>/dev/null
else else
echo "removing .o files corresponding to" echo "removing .o files corresponding to"
echo " $@ ..." echo " $@ ..."