wmake: add "dwim" target

dwim (do what I mean): search up directories tree for Make sub-directory and build the target
    specified in Make/files
This commit is contained in:
Henry
2013-06-11 12:58:19 +01:00
parent 850816f829
commit e66cd871b5

View File

@ -50,6 +50,7 @@ The 'target' is a Makefile target:
e.g., Make/linux64GccDPOpt/fvMesh.o e.g., Make/linux64GccDPOpt/fvMesh.o
or a special target: or a special target:
dwim search up directories tree for Make sub-directory and build
all all subdirectories, uses any Allwmake files if they exist all all subdirectories, uses any Allwmake files if they exist
exe build statically linked executable exe build statically linked executable
lib build statically linked archive lib (.a) lib build statically linked archive lib (.a)
@ -136,7 +137,7 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# check arguments and change to the directory in which to run wmake # Check arguments and change to the directory in which to run wmake
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset dir makeType unset dir makeType
@ -167,6 +168,51 @@ then
fi fi
#------------------------------------------------------------------------------
# Search up directories tree for the Make sub-directory and build there
#------------------------------------------------------------------------------
unset dir
MakeDir=Make
expandpath()
{
dir=`dirname $1`
cwd=$PWD
cd $dir
exPath=$PWD
cd $cwd
}
find_target()
{
expandpath $1
if [ "$exPath" = "$WM_PROJECT_DIR" -o "$exPath" = "$HOME" -o "$exPath" = "/" ]; then
echo "$Script error: could not find Make directory"
elif [ -d "$1/Make" ]; then
echo Target $1
dir=$1
else
find_target "$1/.."
fi
}
if [ "$makeType" = dwim ]
then
find_target .
makeType=
if [ "$dir" ]
then
cd $dir 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
fi
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Recurse the application directories tree # Recurse the application directories tree
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -254,8 +300,9 @@ $make -s -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/dontInc
rc=$? rc=$?
[ $rc -eq 0 ] || exit $rc [ $rc -eq 0 ] || exit $rc
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# make the object files and link # Make the object files and link
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
cmd="$make -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/includeDeps $makeType" cmd="$make -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/includeDeps $makeType"