mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
wrmdepold: Updated rmdepold to handle out-of-tree .dep and .o files
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
# wdepFunctions
|
||||
#
|
||||
# Description
|
||||
# Functions to check wmake environment and find dep files
|
||||
# Functions to check wmake environment and find .dep and .o files
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -51,11 +51,12 @@ checkEnv()
|
||||
|
||||
expandPath()
|
||||
{
|
||||
dir=$(dirname $1)
|
||||
cwd=$PWD
|
||||
cd $dir
|
||||
exPath=$PWD
|
||||
cd $cwd
|
||||
if [ -d "$1" ]
|
||||
then
|
||||
exPath=$(cd "$1" && pwd -P)
|
||||
else
|
||||
exPath=$(cd $(dirname "$1") && pwd -P)
|
||||
fi
|
||||
}
|
||||
|
||||
findTarget()
|
||||
@ -97,5 +98,10 @@ findObjectDir()
|
||||
fi
|
||||
}
|
||||
|
||||
depToSource()
|
||||
{
|
||||
sourceFile=$(echo ${depFile%.dep} | \
|
||||
sed -e s%platforms/${WM_OPTIONS}/%% -e s%Make/${WM_OPTIONS}/%% )
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -23,21 +23,28 @@
|
||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# rmdepold
|
||||
# wrmdepold
|
||||
#
|
||||
# Description
|
||||
# Usage: rmdepold [dir1 .. dirN]
|
||||
# Usage: wrmdepold [dir1 .. dirN]
|
||||
#
|
||||
# Remove *.dep files that are without a corresponding .C or .L file.
|
||||
# Remove *.dep files that are without a corresponding .C or .L source file.
|
||||
# This often occurs when a directory has been moved.
|
||||
# - print questionable directory and the *.dep file
|
||||
# - optionally remove empty directories
|
||||
#------------------------------------------------------------------------------
|
||||
Script=${0##*/}
|
||||
|
||||
# Source the wdep functions
|
||||
. ${0%/*}/wmakeFunctions
|
||||
|
||||
set -x
|
||||
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
Usage: ${0##*/} [OPTION] [dir1 .. dirN]
|
||||
Usage: $Script [OPTION] [dir1 .. dirN]
|
||||
options:
|
||||
-rmdir find and remove empty directories (recursively)
|
||||
|
||||
@ -50,6 +57,11 @@ USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Parse arguments and options
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
unset optRmdir
|
||||
|
||||
# parse options
|
||||
@ -72,38 +84,52 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# default is the current directory
|
||||
# Check environment variables
|
||||
checkEnv
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Default is the current directory
|
||||
[ "$#" -gt 0 ] || set -- .
|
||||
|
||||
for checkDir
|
||||
do
|
||||
if [ -d $checkDir ]
|
||||
findObjectDir $checkDir
|
||||
|
||||
if [ -d $objectsDir ]
|
||||
then
|
||||
echo "searching: $checkDir"
|
||||
echo "Searching: $objectsDir"
|
||||
else
|
||||
echo "skipping non-dir: $checkDir"
|
||||
echo "Skipping non-dir: $objectsDir"
|
||||
continue
|
||||
fi
|
||||
|
||||
find $checkDir -name '*.dep' -print | while read depFile
|
||||
find $objectsDir -name '*.dep' -print | while read depFile
|
||||
do
|
||||
# check C++ and Flex files
|
||||
if [ ! -r "${depFile%dep}C" -a ! -r "${depFile%dep}L" ];
|
||||
depToSource $depFile
|
||||
|
||||
# Check C++ or Flex source file exists
|
||||
if [ ! -r "$sourceFile" ];
|
||||
then
|
||||
echo "rm $depFile"
|
||||
rm -f $depFile 2>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# remove empty dirs
|
||||
# Remove empty dirs
|
||||
if [ "$optRmdir" ]
|
||||
then
|
||||
# get subdirs ourselves so we can avoid particular directories
|
||||
for dir in $(find $checkDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
|
||||
for dir in $(find $objectsDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
|
||||
do
|
||||
echo "check dir: $dir"
|
||||
find $dir -depth -type d -empty -exec rmdir {} \; -print
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user