ENH: wmakeRoot for locating the root directory

This commit is contained in:
Mark Olesen 2019-01-18 10:58:07 +01:00
parent 3c81aec0e2
commit 1dd7362aed
4 changed files with 123 additions and 6 deletions

View File

@ -91,7 +91,7 @@ shift 2
if [ "${printOpt:-false}" = true ]
then
cat $Template$subType$Type
cat "$Template$subType$Type"
else
fileName="$className$Type"
@ -106,11 +106,11 @@ else
# process class name
sed -e "s/CLASSNAME/$className/g" \
-e "s/YEAR/$(date +%Y)/g" \
$Template$subType$Type > $fileName
"$Template$subType$Type" > "$fileName"
if [ "$subType" = App -a ! -d Make ]
then
wmakeFilesAndOptions
"${WM_DIR:-$WM_PROJECT_DIR/wmake}/wmakeFilesAndOptions"
fi
fi

View File

@ -31,7 +31,7 @@
# Usage : makeFiles
#
#------------------------------------------------------------------------------
dirToString="$WM_DIR/platforms/$WM_ARCH$WM_COMPILER"/dirToString
dirToString="${WM_DIR:-$WM_PROJECT_DIR/wmake}/platforms/$WM_ARCH$WM_COMPILER/dirToString"
if [ -r Make/files ]
then
@ -46,8 +46,10 @@ fi
[ -d Make ] || mkdir Make
rm -f Make/files
#------------------------------------------------------------------------------
echo "Creating Make/files"
echo "Creating Make/files ..."
for dir in $(find . -mindepth 1 -type d -print)
do
@ -68,7 +70,7 @@ do
if [ -n "$pathName" ]
then
echo '$('$pathName')/'"${file##*/}"
echo '$('"$pathName"')/'"${file##*/}"
else
echo "${file##*/}"
fi

View File

@ -40,7 +40,9 @@ fi
[ -d Make ] || mkdir Make
rm -f Make/options
#------------------------------------------------------------------------------
echo "Creating Make/options"
echo 'EXE_INC = \

113
wmake/wmakeRoot Executable file
View File

@ -0,0 +1,113 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# wmakeRoot
#
# Description
# Locate the root directory that has a Make/ directory.
#
# See Also
# wmake
#
#------------------------------------------------------------------------------
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions
. "${0%/*}/scripts/wmakeFunctions" # Source wmake functions
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] [dir]
options:
-h | -help Print the usage
Locate the root directory that has a Make/ directory.
USAGE
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
;;
--)
shift
break
;;
-*)
usage "unknown option: '$1'"
;;
*)
break
;;
esac
shift
done
#------------------------------------------------------------------------------
unset dir
if [ $# -ge 1 ]
then
if [ -d "$1" ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
else
echo "$Script error: not a file or directory" 1>&2
exit 1
fi
cd "$dir" 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
fi
# Locate target with Make/ directory
if dir="$(findTarget .)"
then
(cd "$dir" && pwd -L)
else
exit 2
fi
#------------------------------------------------------------------------------