Skip to content
Snippets Groups Projects
Commit 10f5e808 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add -make option to touchdep, toucho

- restricts selection to Make/$WM_OPTIONS* subdirectories, which is
  useful when multiple compilers are in use
parent 96edf6f3
Branches
Tags
No related merge requests found
......@@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
......@@ -28,25 +28,71 @@
# Description
# touch all .dep files
#------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
# default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " touch all .dep files"
Usage: ${0##*/} [OPTION] [dir1] .. [dirN]
options:
-make limit selection to 'Make/\$WM_OPTIONS*' (Make/$WM_OPTIONS*)
-help print the usage
Find and touch all .dep files in the specified directories.
Uses the cwd by default if no directories are specified.
Current value of WM_OPTIONS=$WM_OPTIONS
NOTE The '-make' is a future feature.
This is currently no separation of .dep files by platforms.
USAGE
exit 1
fi
}
unset restrictOpt
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-m | -make)
[ -n "$WM_OPTIONS" ] || usage "Error: -make option only valid when \$WM_OPTIONS is set"
restrictOpt=true
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# no directories specified: default is pwd
[ "$#" -gt 0 ] || set -- .
for i
do
if [ -d "$i" ]
then
echo "touching all .dep files: $i"
find $i -name '*.dep' -print | xargs -t touch
if [ "$restrictOpt" = true ]
then
echo "touching all .dep files under Make/$WM_OPTIONS* : $i"
find -depth -name Make -type d -print | \
xargs -i find '{}' -depth -name "$WM_OPTIONS*" -type d -print | \
xargs -i find '{}' -name '*.dep' -type f -print | \
xargs -t touch
else
echo "touching all .dep files: $i"
find $i -name '*.dep' -type f -print | xargs -t touch
fi
else
echo "no directory: $i"
fi
......
......@@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
......@@ -28,27 +28,70 @@
# Description
# touch all .o files
#------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
# default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " touch all .o files"
Usage: ${0##*/} [OPTION] [dir1] .. [dirN]
options:
-make limit selection to 'Make/\$WM_OPTIONS*'
-help print the usage
Find and touch all .o files in the specified directories.
Uses the cwd by default if no directories are specified.
Current value of WM_OPTIONS=$WM_OPTIONS
USAGE
exit 1
fi
}
unset restrictOpt
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-m | -make)
[ -n "$WM_OPTIONS" ] || usage "Error: -make option only valid when \$WM_OPTIONS is set"
restrictOpt=true
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# no directories specified: default is pwd
[ "$#" -gt 0 ] || set -- .
for i
do
if [ -d "$i" ]
then
echo "touching all .o files: $i"
find $i -name '*.o' -print | xargs -t touch
if [ "$restrictOpt" = true ]
then
echo "touching all .o files under Make/$WM_OPTIONS* : $i"
find -depth -name Make -type d -print | \
xargs -i find '{}' -depth -name "$WM_OPTIONS*" -type d -print | \
xargs -i find '{}' -name '*.o' -type f -print | \
xargs -t touch
else
echo "touching all .o files: $i"
find $i -name '*.o' -type f -print | xargs -t touch
fi
else
echo "no directory: $i"
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