mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: additional wmake adjustments
- scripts/wmake.wmake-args partial logic for Allwmake scripts. - handle '-quiet' as synonym for '-silent' - Do not specify '-j' option for wrapped cmake creation to avoid the warning: make[1]: warning: -jN forced in submake: disabling jobserver mode.
This commit is contained in:
@ -81,7 +81,7 @@ cmakeVersioned()
|
||||
|
||||
mkdir -p "$objectsDir" \
|
||||
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
||||
make "-j${WM_NCOMPPROCS:-1}" ) \
|
||||
make ) \
|
||||
&& storeDependency "$sentinel" "$depend" $@
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ cmakeVersionedInstall()
|
||||
|
||||
mkdir -p "$objectsDir" \
|
||||
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
||||
make "-j${WM_NCOMPPROCS:-1}" install ) \
|
||||
make install ) \
|
||||
&& storeDependency "$sentinel" "$depend" $@
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ options:
|
||||
-curr | -current Use \$WM_OPTIONS ($WM_OPTIONS)
|
||||
-comp | -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER)
|
||||
-compiler=NAME Use \$WM_ARCH<NAME>* ($WM_ARCH<NAME>*)
|
||||
-h | -help Print the usage
|
||||
-help Print the usage
|
||||
|
||||
Deletes specified $targetDir object file directories from project top-level:
|
||||
Project: $WM_PROJECT_DIR
|
||||
|
||||
90
wmake/scripts/wmake.wmake-args
Normal file
90
wmake/scripts/wmake.wmake-args
Normal file
@ -0,0 +1,90 @@
|
||||
#----------------------------------*-sh-*--------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# wmake/scripts/wmake.wmake-args
|
||||
#
|
||||
# Description
|
||||
# Reduced argument parser (eg, for scripts using wmake)
|
||||
# that handles some common parameters
|
||||
#
|
||||
# Usage
|
||||
# # Parse the arguments by sourcing this script
|
||||
# . ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.wmake-args
|
||||
#
|
||||
# Options
|
||||
# -s | -silent | -quiet
|
||||
# Exports WM_QUIET=true
|
||||
#
|
||||
# -j | -jN | -j N
|
||||
# Compile using all or specified N cores/hyperthreads
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# NB: nArgs to track the current processing position to avoid wraparound
|
||||
# when checking for optional parameters (eg, the -j processing)
|
||||
|
||||
nArgs="$#"
|
||||
for arg in "$@"
|
||||
do
|
||||
shift; nArgs="$((nArgs - 1))" # Drop argument
|
||||
|
||||
case "$arg" in
|
||||
|
||||
# Silent operation
|
||||
-s | -silent | -quiet)
|
||||
export WM_QUIET=true
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
# Parallel compilation (all or specified number of cores)
|
||||
-j)
|
||||
export WM_NCOMPPROCS=0
|
||||
if [ "$nArgs" -gt 0 ]
|
||||
then
|
||||
case "$1" in
|
||||
[0-9]*)
|
||||
if WM_NCOMPPROCS="$(expr 0 + "$1" 2>/dev/null)"
|
||||
then
|
||||
shift; nArgs="$((nArgs - 1))" # Drop argument
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
|
||||
then
|
||||
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
|
||||
WM_NCOMPPROCS=1
|
||||
fi
|
||||
|
||||
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
# Parallel compilation (specified number of cores)
|
||||
-j[0-9]*)
|
||||
export WM_NCOMPPROCS="${arg#-j}"
|
||||
if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
|
||||
then
|
||||
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
|
||||
WM_NCOMPPROCS=1
|
||||
fi
|
||||
|
||||
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
|
||||
continue # Handled argument
|
||||
;;
|
||||
esac
|
||||
|
||||
set -- "$@" "$arg" # Reinsert unhandled argument
|
||||
done
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -52,7 +52,7 @@ Usage: $Script [OPTION] [dir]
|
||||
options:
|
||||
-a | -all All subdirectories, uses Allwclean, Allclean if they exist
|
||||
-s | -silent Silent mode (ignored - for compatibility with wmake)
|
||||
-h | -help Display short help and exit
|
||||
-help Display short help and exit
|
||||
-help-full Display full help and exit
|
||||
|
||||
subcommands (wclean subcommand -help for more information):
|
||||
@ -136,7 +136,7 @@ do
|
||||
-a | -all | all)
|
||||
targetType=all
|
||||
;;
|
||||
-s | -silent) # Ignored - for compatibility with wmake
|
||||
-s | -silent | -quiet)
|
||||
export WM_QUIET=true
|
||||
;;
|
||||
-*)
|
||||
|
||||
@ -100,7 +100,7 @@ fi
|
||||
cat<<TAIL_OPTIONS
|
||||
-pwd Print root directory containing a Make/ directory
|
||||
-version | --version Print version (same as -show-api)
|
||||
-h | -help Display short help and exit
|
||||
-help Display short help and exit
|
||||
-help-full Display full help and exit
|
||||
|
||||
subcommands (wmake subcommand -help for more information):
|
||||
@ -219,7 +219,7 @@ do
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-s | -silent)
|
||||
-s | -silent | -quiet)
|
||||
optQuiet=true
|
||||
export WM_QUIET=true
|
||||
;;
|
||||
|
||||
@ -40,7 +40,7 @@ options:
|
||||
-u | -update Update existing lnInclude directories
|
||||
-s | -silent Silent mode (do not echo command)
|
||||
-pwd Locate root directory containing Make/ directory
|
||||
-h | -help Print the usage
|
||||
-help Print the usage
|
||||
|
||||
Link source files in specified dir(s) into their respective
|
||||
lnInclude directories. With '-update', items are relinked with 'ln -sf'
|
||||
@ -71,7 +71,7 @@ die()
|
||||
# Option for 'ln'
|
||||
optLink="-s"
|
||||
|
||||
unset optForce optQuiet optUpdate optPwd
|
||||
unset optForce optUpdate optPwd
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
@ -87,8 +87,8 @@ do
|
||||
optUpdate=true
|
||||
optLink="-sf"
|
||||
;;
|
||||
-s | -silent)
|
||||
optQuiet=true
|
||||
-s | -silent | -quiet)
|
||||
export WM_QUIET=true
|
||||
;;
|
||||
-pwd)
|
||||
optPwd=true
|
||||
|
||||
@ -36,23 +36,38 @@
|
||||
# and execute 'wmakeLnInclude' for each one
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
Script=${0##*/}
|
||||
Script="${0##*/}" # Need 'Script' for wmakeFunctions messages
|
||||
|
||||
usage() {
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
printHelp() {
|
||||
cat<<USAGE
|
||||
|
||||
Usage: $Script [OPTION] [dir1 .. dirN]
|
||||
Usage: ${0##*/} [OPTION] [dir1 .. dirN]
|
||||
|
||||
options:
|
||||
-j Compile using all local cores/hyperthreads
|
||||
-jN or -j N Compile using N cores/hyperthreads
|
||||
-h | -help Print the usage
|
||||
-f | -force Force remove of existing lnInclude before recreating
|
||||
-u | -update Update existing lnInclude directories
|
||||
-j Use all local cores/hyperthreads
|
||||
-jN | -j N Use N cores/hyperthreads
|
||||
-help Display short help and exit
|
||||
|
||||
Find directories with a 'Make/files' containing a 'LIB =' directive
|
||||
and execute 'wmakeLnInclude -update' for each one
|
||||
and execute 'wmakeLnInclude' for each.
|
||||
|
||||
USAGE
|
||||
exit 0 # clean exit
|
||||
}
|
||||
|
||||
|
||||
# Report error and exit
|
||||
die()
|
||||
{
|
||||
exec 1>&2
|
||||
echo
|
||||
echo "Error encountered:"
|
||||
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||
echo
|
||||
echo "See '${0##*/} -help' for usage"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -61,35 +76,53 @@ USAGE
|
||||
# Parse arguments and options
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
findName=lnInclude
|
||||
# Parallel operation requested
|
||||
nCores=0
|
||||
|
||||
# Default 'wmakeLnInclude' option
|
||||
unset wmLnOpt
|
||||
unset optForce optUpdate
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help*)
|
||||
usage
|
||||
printHelp
|
||||
;;
|
||||
-f | -force)
|
||||
optForce=true
|
||||
;;
|
||||
-u | -update)
|
||||
wmLnOpt="-update"
|
||||
optUpdate=true
|
||||
;;
|
||||
-s | -silent | -quiet)
|
||||
export WM_QUIET=true
|
||||
;;
|
||||
# Parallel execution on WM_NCOMPPROCS cores
|
||||
-j)
|
||||
nCores=${WM_NCOMPPROCS:-0}
|
||||
test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \
|
||||
&& shift && nCores=$1
|
||||
|
||||
[ "$nCores" = 0 ] && nCores=1
|
||||
nJobs=0
|
||||
case "$2" in
|
||||
[0-9]*)
|
||||
if nJobs="$(expr 0 + "$2" 2>/dev/null)"
|
||||
then
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${nJobs:=0}" -gt 0 ]
|
||||
then
|
||||
nCores="$nJobs"
|
||||
else
|
||||
nCores="${WM_NCOMPPROCS:-1}"
|
||||
[ "$nCores" -gt 0 ] || nCores=1
|
||||
fi
|
||||
;;
|
||||
|
||||
# Parallel compilation on specified number of cores
|
||||
-j[1-9]*)
|
||||
nCores=${1#-j}
|
||||
nCores="${1#-j}"
|
||||
;;
|
||||
-*)
|
||||
usage "unknown option: '$1'"
|
||||
die "unknown option: '$1'"
|
||||
;;
|
||||
*)
|
||||
break
|
||||
@ -98,6 +131,7 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
# Default search is from CWD, with special handling of the top-level
|
||||
# project directory: {applications,src} directories
|
||||
if [ "$#" -eq 0 ]
|
||||
@ -112,14 +146,14 @@ fi
|
||||
|
||||
if [ "$nCores" -gt 0 ]
|
||||
then
|
||||
echo "$Script: starting wmakeLnInclude processes on $nCores cores"
|
||||
echo "${0##*/}: starting wmakeLnInclude processes on $nCores cores"
|
||||
else
|
||||
echo "$Script: running wmakeLnInclude"
|
||||
echo "${0##*/}: running wmakeLnInclude"
|
||||
fi
|
||||
|
||||
for checkDir
|
||||
do
|
||||
if [ -d $checkDir ]
|
||||
if [ -d "$checkDir" ]
|
||||
then
|
||||
echo " searching $checkDir for 'Make' directories"
|
||||
else
|
||||
@ -127,7 +161,7 @@ do
|
||||
continue
|
||||
fi
|
||||
|
||||
find $checkDir -depth -name Make -type d -print | while read MakeDir
|
||||
find "$checkDir" -depth -name Make -type d -print | while read MakeDir
|
||||
do
|
||||
topDir=${MakeDir%/Make} # trim /Make from the end
|
||||
if [ -d "$topDir" ]
|
||||
@ -145,9 +179,9 @@ do
|
||||
wait -n
|
||||
joblist=($(jobs -p))
|
||||
done
|
||||
wmakeLnInclude $wmLnOpt $topDir &
|
||||
wmakeLnInclude ${optForce:+-force} ${optUpdate:+-update} $topDir &
|
||||
else
|
||||
wmakeLnInclude $wmLnOpt $topDir
|
||||
wmakeLnInclude ${optForce:+-force} ${optUpdate:+-update} $topDir
|
||||
fi
|
||||
elif [ -d "$topDir/lnInclude" ]
|
||||
then
|
||||
@ -160,7 +194,7 @@ done
|
||||
|
||||
if [ "$nCores" -gt 0 ]
|
||||
then
|
||||
# Wait for all of the wmakeLnInclude jobs to finish
|
||||
# Wait for wmakeLnInclude jobs to finish
|
||||
wait
|
||||
|
||||
# Synchronize the file system to ensure that all of the links exist
|
||||
|
||||
Reference in New Issue
Block a user