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

wmakeLnInclude: improvements and bugfix

  - fixed typo: had skipped '-Make' instead of 'Make' directory

  - remove broken links first
    * helps when file locations have changed

  - filter out trailing 'lnInclude' from the <dir> spec
    * this makes it easier to update existing lnInclude dirs:
         find -name lnInclude -exec wmakeLnInclude -f {} \;

  - reduced output noise when re-creating an identical link
parent b4363c71
Branches
Tags
No related merge requests found
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# #
# Script # Script
# wmakeLnInclude # wcleanLnIncludeAll
# #
# Description # Description
# Delete all the lnInclude directories in the tree. # Delete all the lnInclude directories in the tree.
......
...@@ -80,8 +80,18 @@ do ...@@ -80,8 +80,18 @@ do
done done
baseDir=$1 baseDir=$1
# convert incorrect path/dir/lnInclude to something sensible
while [ "${baseDir##*/}" = lnInclude ]
do
baseDir="${baseDir%/*}"
if [ "$baseDir" = lnInclude ]
then
baseDir="."
fi
done
incDir=$baseDir/lnInclude incDir=$baseDir/lnInclude
if [ $# -eq 1 ] if [ $# -eq 1 ]
then then
lnOpt="-s" lnOpt="-s"
...@@ -89,7 +99,7 @@ elif [ $# -eq 2 ] ...@@ -89,7 +99,7 @@ elif [ $# -eq 2 ]
then then
lnOpt="$2" lnOpt="$2"
else else
usage "ERROR: wrong number of arguments" usage "ERROR: incorrect number of arguments"
fi fi
...@@ -101,7 +111,6 @@ fi ...@@ -101,7 +111,6 @@ fi
if [ -d $incDir ] if [ -d $incDir ]
then then
# could change force to remove lnInclude first
if [ ! "$forceUpdate" ] if [ ! "$forceUpdate" ]
then then
# echo $Script: include directory $incDir already exists, exiting. # echo $Script: include directory $incDir already exists, exiting.
...@@ -117,24 +126,34 @@ then ...@@ -117,24 +126,34 @@ then
exit 0 exit 0
fi fi
cd $incDir || exit 1
# Link include files # Link include files
# ~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~
echo $Script: linking include files to $incDir echo $Script: linking include files to $incDir
echo
cd $incDir
find .. $findOpt \
\( -name lnInclude -o -name -Make -o -name config \) -prune \
-o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \) \
-a ! -name ".#*" \
-exec ln $lnOpt {} . \;
# #
# remove any broken links # remove any broken links first (this helps when file locations have moved)
# #
find -L . -type l -exec rm \{\} \; find -L . -type l -exec rm \{\} \;
#
# create links, avoid recreating links unless necessary
#
find .. $findOpt \
\( -name lnInclude -o -name Make -o -name config \) -prune \
-o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \) \
-a ! -name ".#*" \
-print | \
while read src
do
link=$(readlink ${src##*/})
if [ "$link" != "$src" ]
then
rm $link 2>/dev/null
ln $lnOpt $src .
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