1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
# \\/ 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/>.
#
# File
# wmake/scripts/AllwmakeParseArguments
#
# Description
# Allwmake argument parser
#
# Usage
# # Declare the targetType and set to default for library building
# targetType=libso # lib, libo or libso
#
# # Declare genDoc and set to default if documentation building is supported
# genDoc=0 # 0 or 1
#
# # Parse the arguments by sourcing this script
# . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
# Print normal usage options
cat<<USAGE
Usage: $Script [OPTIONS]
options:
-h or -help Print list of Allwmake options
-k or -non-stop Compile without stopping when errors occur
-j Compile using all local cores/hyperthreads
-jN or -j N Compile using N cores/hyperthreads
-no-scheduler Compile without wmakeScheduler
-update Update lnInclude directories, dep files, remove deprecated
files and directories
USAGE
# Print options for building code documentation
test -n "$genDoc" && cat<<USAGE_DOC
doc Compile code documentation (requires Doxygen)
USAGE_DOC
# Print options for building libraries
test -n "$targetType" && cat<<USAGE_LIB
lib Compile statically linked archive lib (.a)
libo Compile statically linked lib (.o)
libso Compile dynamically linked lib (.so)
dep Compile dependency files
USAGE_LIB
exit 1
}
#------------------------------------------------------------------------------
# Set WM_NCOMPPROCS to number of cores on local machine
#------------------------------------------------------------------------------
setWM_NCOMPPROCS()
{
export WM_NCOMPPROCS
}
#------------------------------------------------------------------------------
# Parse the arguments and options
#------------------------------------------------------------------------------
while [ "$#" -gt 0 ]
do
case "$1" in
# Print help
-h | -help)
usage
;;
# Parallel compilation on all cores of local machine
-j)
setWM_NCOMPPROCS
test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \
&& shift && export WM_NCOMPPROCS=$1
echo "Compiling enabled on $WM_NCOMPPROCS cores"
;;
# Parallel compilation on specified number of cores
-j*)
export WM_NCOMPPROCS=${1#-j}
echo "Compiling enabled on $WM_NCOMPPROCS cores"
;;
# Non-stop compilation, ignoring errors
-k | -non-stop)
export WM_CONTINUE_ON_ERROR=1
;;
# Disable scheduled parallel compilation
-no-scheduler)
unset WM_SCHEDULER
;;
# Meant to be used following a pull, this will:
# - remove dep files that depend on deleted files;
# - remove stale dep files;
# - update lnInclude directories;
# - remove empty directories, along with deprecated object directories
# and respective binaries.
-update)
wrmdep -update
wrmdep -old
wmakeLnIncludeAll
wclean empty
# Set WM_UPDATE_DEPENDENCIES, so that wmake will pick up on it
export WM_UPDATE_DEPENDENCIES=yes
;;
# Generate documentation
doc)
test -n "$genDoc" || usage "invalid option '$1'"
genDoc=1
;;
# Specify target type
lib | libo | libso | dep)
test -n "$targetType" || usage "invalid option '$1'"
targetType=$1
;;
--)
shift
break
;;
-* | *)
usage "invalid option '$1'"
;;
esac
shift
done
#------------------------------------------------------------------------------
# If WM_CONTINUE_ON_ERROR not set activate the shell option "stop on error"
#------------------------------------------------------------------------------
if [ -z "${WM_CONTINUE_ON_ERROR}" ]
then
set -e
fi
#------------------------------------------------------------------------------
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage setWM_NCOMPPROCS
#------------------------------------------------------------------------------
|