Skip to content
Snippets Groups Projects
Commit 0e51d263 authored by Henry's avatar Henry
Browse files

wrmdepold: Updated rmdepold to handle out-of-tree .dep and .o files

parent fb1b5ffa
Branches
Tags
No related merge requests found
......@@ -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
# -----------------------------------------------------------------------------
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