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