ENH: fix wcleanAll, wcleanMachine to work with new platforms/ layout

This commit is contained in:
Mark Olesen
2011-02-15 18:51:23 +01:00
parent 28e6389173
commit b9f7726095
2 changed files with 47 additions and 28 deletions

View File

@ -3,7 +3,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) 2004-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -30,33 +30,44 @@
# directories of all machines and delete them. # directories of all machines and delete them.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$1" = "-h" -o "$1" = "-help" ] usage() {
then exec 1>&2
echo "Usage: ${0##*/}" while [ "$#" -ge 1 ]; do echo "$1"; shift; done
echo cat<<USAGE
echo " Remove all object files and *.dep files" usage: ${0##*/}
exit 1
fi
[ -d bin -a -d src ] || { Remove all object files and *.dep files
echo "${0##*/}: not in the project top level directory"
USAGE
exit 1 exit 1
} }
for dir in lib bin applications/bin # parse options
while [ "$#" -gt 0 ]
do do
echo "Removing non-tools directories from $dir/" case "$1" in
if [ -d $dir ] -h | -help)
then usage
find $dir -mindepth 1 -type d \! -name tools | xargs rm -rf ;;
fi *)
usage "unknown option/argument: '$*'"
;;
esac
done done
[ -d bin -a -d src ] || usage "not in the project top level directory"
echo "Removing platforms/ subdirectores"
rm -rf platforms/*
echo "Removing *.dep files" echo "Removing *.dep files"
find . -name '*.dep' -exec rm {} \; find . -name '*.dep' -exec rm {} \;
echo "Cleaning Make subdirectories" echo "Cleaning Make subdirectories"
find `find . -depth \( -name "Make.[A-Za-z]*" -o -name Make \) -type d -print` -depth \( -type d ! -name "*Make.[A-Za-z]*" ! -name "*Make" \) -exec rm -rf {} \; find . -depth \( -name Make -o -name "Make.[A-Za-z]*" \) -type d -print | \
xargs -i find '{}' -mindepth 1 -maxdepth 1 -type d -print | \
xargs rm -rf
echo "Removing lnInclude and intermediate directories" echo "Removing lnInclude and intermediate directories"
find . -depth -type d \( -name lnInclude -o -name ii_files -o -name Templates.DB \) -exec rm -rf {} \; find . -depth -type d \( -name lnInclude -o -name ii_files -o -name Templates.DB \) -exec rm -rf {} \;

View File

@ -3,7 +3,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) 2004-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -33,6 +33,7 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: ${0##*/} machineType [... machineTypeN] usage: ${0##*/} machineType [... machineTypeN]
@ -40,32 +41,39 @@ usage: ${0##*/} machineType [... machineTypeN]
Searches the directories below the current directory for the object file Searches the directories below the current directory for the object file
directories of the specified machine type(s) and deletes them directories of the specified machine type(s) and deletes them
Note:
can also use '-current' for the current value of \$WM_OPTIONS
USAGE USAGE
exit 1 exit 1
} }
# needs some machine types ... or provide immediate help # needs some machine types ... or provide immediate help
if [ "$#" -lt 1 -o "$1" = "-h" -o "$1" = "-help" ] if [ "$#" -lt 1 -o "$1" = "-h" -o "$1" = "-help" ]
then then
usage usage
fi fi
[ -d lib -a -d src ] || usage "not in the project top level directory" [ -d bin -a -d src ] || usage "not in the project top level directory"
for machType for machType
do do
if [ "$machType" = "-current" ]
then
machType="$WM_OPTIONS"
echo "Using current = $machType"
[ -n "$machType" ] || continue
fi
echo "Cleaning machine type: $machType" echo "Cleaning machine type: $machType"
find `find . -depth \( -name "Make.[A-Za-z]*" -o -name Make \) -type d -print` \ find . -depth \( -name Make -o -name "Make.[A-Za-z]*" \) -type d -print | \
-depth \( -type d -name "*$machType" -o -name "*$machType$WM_MPLIB" \) -exec rm -r {} \; xargs -i find '{}' -mindepth 1 -maxdepth 1 \
\( -type d -name "*$machType" -o -name "*$machType$WM_MPLIB" \) -print |
xargs rm -rf
# find . -depth -type d \( -name ii_files -o -name Templates.DB \) -exec rm -rf {} \; rm -rf platforms/$machType
for dir in lib/$machType bin/$machType applications/bin/$machType
do
[ -d $dir ] && rm -rf $dir
done
done done