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" \
|
mkdir -p "$objectsDir" \
|
||||||
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
||||||
make "-j${WM_NCOMPPROCS:-1}" ) \
|
make ) \
|
||||||
&& storeDependency "$sentinel" "$depend" $@
|
&& storeDependency "$sentinel" "$depend" $@
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ cmakeVersionedInstall()
|
|||||||
|
|
||||||
mkdir -p "$objectsDir" \
|
mkdir -p "$objectsDir" \
|
||||||
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
||||||
make "-j${WM_NCOMPPROCS:-1}" install ) \
|
make install ) \
|
||||||
&& storeDependency "$sentinel" "$depend" $@
|
&& storeDependency "$sentinel" "$depend" $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,7 @@ options:
|
|||||||
-curr | -current Use \$WM_OPTIONS ($WM_OPTIONS)
|
-curr | -current Use \$WM_OPTIONS ($WM_OPTIONS)
|
||||||
-comp | -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER)
|
-comp | -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER)
|
||||||
-compiler=NAME Use \$WM_ARCH<NAME>* ($WM_ARCH<NAME>*)
|
-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:
|
Deletes specified $targetDir object file directories from project top-level:
|
||||||
Project: $WM_PROJECT_DIR
|
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:
|
options:
|
||||||
-a | -all All subdirectories, uses Allwclean, Allclean if they exist
|
-a | -all All subdirectories, uses Allwclean, Allclean if they exist
|
||||||
-s | -silent Silent mode (ignored - for compatibility with wmake)
|
-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
|
-help-full Display full help and exit
|
||||||
|
|
||||||
subcommands (wclean subcommand -help for more information):
|
subcommands (wclean subcommand -help for more information):
|
||||||
@ -136,7 +136,7 @@ do
|
|||||||
-a | -all | all)
|
-a | -all | all)
|
||||||
targetType=all
|
targetType=all
|
||||||
;;
|
;;
|
||||||
-s | -silent) # Ignored - for compatibility with wmake
|
-s | -silent | -quiet)
|
||||||
export WM_QUIET=true
|
export WM_QUIET=true
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
|
|||||||
@ -100,7 +100,7 @@ fi
|
|||||||
cat<<TAIL_OPTIONS
|
cat<<TAIL_OPTIONS
|
||||||
-pwd Print root directory containing a Make/ directory
|
-pwd Print root directory containing a Make/ directory
|
||||||
-version | --version Print version (same as -show-api)
|
-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
|
-help-full Display full help and exit
|
||||||
|
|
||||||
subcommands (wmake subcommand -help for more information):
|
subcommands (wmake subcommand -help for more information):
|
||||||
@ -219,7 +219,7 @@ do
|
|||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-s | -silent)
|
-s | -silent | -quiet)
|
||||||
optQuiet=true
|
optQuiet=true
|
||||||
export WM_QUIET=true
|
export WM_QUIET=true
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -40,7 +40,7 @@ options:
|
|||||||
-u | -update Update existing lnInclude directories
|
-u | -update Update existing lnInclude directories
|
||||||
-s | -silent Silent mode (do not echo command)
|
-s | -silent Silent mode (do not echo command)
|
||||||
-pwd Locate root directory containing Make/ directory
|
-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
|
Link source files in specified dir(s) into their respective
|
||||||
lnInclude directories. With '-update', items are relinked with 'ln -sf'
|
lnInclude directories. With '-update', items are relinked with 'ln -sf'
|
||||||
@ -71,7 +71,7 @@ die()
|
|||||||
# Option for 'ln'
|
# Option for 'ln'
|
||||||
optLink="-s"
|
optLink="-s"
|
||||||
|
|
||||||
unset optForce optQuiet optUpdate optPwd
|
unset optForce optUpdate optPwd
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -87,8 +87,8 @@ do
|
|||||||
optUpdate=true
|
optUpdate=true
|
||||||
optLink="-sf"
|
optLink="-sf"
|
||||||
;;
|
;;
|
||||||
-s | -silent)
|
-s | -silent | -quiet)
|
||||||
optQuiet=true
|
export WM_QUIET=true
|
||||||
;;
|
;;
|
||||||
-pwd)
|
-pwd)
|
||||||
optPwd=true
|
optPwd=true
|
||||||
|
|||||||
@ -36,23 +36,38 @@
|
|||||||
# and execute 'wmakeLnInclude' for each one
|
# and execute 'wmakeLnInclude' for each one
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
Script=${0##*/}
|
Script="${0##*/}" # Need 'Script' for wmakeFunctions messages
|
||||||
|
|
||||||
usage() {
|
printHelp() {
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
||||||
cat<<USAGE
|
cat<<USAGE
|
||||||
|
|
||||||
Usage: $Script [OPTION] [dir1 .. dirN]
|
Usage: ${0##*/} [OPTION] [dir1 .. dirN]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-j Compile using all local cores/hyperthreads
|
-f | -force Force remove of existing lnInclude before recreating
|
||||||
-jN or -j N Compile using N cores/hyperthreads
|
-u | -update Update existing lnInclude directories
|
||||||
-h | -help Print the usage
|
-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
|
Find directories with a 'Make/files' containing a 'LIB =' directive
|
||||||
and execute 'wmakeLnInclude -update' for each one
|
and execute 'wmakeLnInclude' for each.
|
||||||
|
|
||||||
USAGE
|
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
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,35 +76,53 @@ USAGE
|
|||||||
# Parse arguments and options
|
# Parse arguments and options
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
findName=lnInclude
|
# Parallel operation requested
|
||||||
nCores=0
|
nCores=0
|
||||||
|
|
||||||
# Default 'wmakeLnInclude' option
|
unset optForce optUpdate
|
||||||
unset wmLnOpt
|
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | -help*)
|
-h | -help*)
|
||||||
usage
|
printHelp
|
||||||
|
;;
|
||||||
|
-f | -force)
|
||||||
|
optForce=true
|
||||||
;;
|
;;
|
||||||
-u | -update)
|
-u | -update)
|
||||||
wmLnOpt="-update"
|
optUpdate=true
|
||||||
|
;;
|
||||||
|
-s | -silent | -quiet)
|
||||||
|
export WM_QUIET=true
|
||||||
;;
|
;;
|
||||||
# Parallel execution on WM_NCOMPPROCS cores
|
# Parallel execution on WM_NCOMPPROCS cores
|
||||||
-j)
|
-j)
|
||||||
nCores=${WM_NCOMPPROCS:-0}
|
nJobs=0
|
||||||
test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \
|
case "$2" in
|
||||||
&& shift && nCores=$1
|
[0-9]*)
|
||||||
|
if nJobs="$(expr 0 + "$2" 2>/dev/null)"
|
||||||
|
then
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
[ "$nCores" = 0 ] && nCores=1
|
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
|
# Parallel compilation on specified number of cores
|
||||||
-j[1-9]*)
|
-j[1-9]*)
|
||||||
nCores=${1#-j}
|
nCores="${1#-j}"
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
usage "unknown option: '$1'"
|
die "unknown option: '$1'"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
@ -98,6 +131,7 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Default search is from CWD, with special handling of the top-level
|
# Default search is from CWD, with special handling of the top-level
|
||||||
# project directory: {applications,src} directories
|
# project directory: {applications,src} directories
|
||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
@ -112,14 +146,14 @@ fi
|
|||||||
|
|
||||||
if [ "$nCores" -gt 0 ]
|
if [ "$nCores" -gt 0 ]
|
||||||
then
|
then
|
||||||
echo "$Script: starting wmakeLnInclude processes on $nCores cores"
|
echo "${0##*/}: starting wmakeLnInclude processes on $nCores cores"
|
||||||
else
|
else
|
||||||
echo "$Script: running wmakeLnInclude"
|
echo "${0##*/}: running wmakeLnInclude"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for checkDir
|
for checkDir
|
||||||
do
|
do
|
||||||
if [ -d $checkDir ]
|
if [ -d "$checkDir" ]
|
||||||
then
|
then
|
||||||
echo " searching $checkDir for 'Make' directories"
|
echo " searching $checkDir for 'Make' directories"
|
||||||
else
|
else
|
||||||
@ -127,7 +161,7 @@ do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $checkDir -depth -name Make -type d -print | while read MakeDir
|
find "$checkDir" -depth -name Make -type d -print | while read MakeDir
|
||||||
do
|
do
|
||||||
topDir=${MakeDir%/Make} # trim /Make from the end
|
topDir=${MakeDir%/Make} # trim /Make from the end
|
||||||
if [ -d "$topDir" ]
|
if [ -d "$topDir" ]
|
||||||
@ -145,9 +179,9 @@ do
|
|||||||
wait -n
|
wait -n
|
||||||
joblist=($(jobs -p))
|
joblist=($(jobs -p))
|
||||||
done
|
done
|
||||||
wmakeLnInclude $wmLnOpt $topDir &
|
wmakeLnInclude ${optForce:+-force} ${optUpdate:+-update} $topDir &
|
||||||
else
|
else
|
||||||
wmakeLnInclude $wmLnOpt $topDir
|
wmakeLnInclude ${optForce:+-force} ${optUpdate:+-update} $topDir
|
||||||
fi
|
fi
|
||||||
elif [ -d "$topDir/lnInclude" ]
|
elif [ -d "$topDir/lnInclude" ]
|
||||||
then
|
then
|
||||||
@ -160,7 +194,7 @@ done
|
|||||||
|
|
||||||
if [ "$nCores" -gt 0 ]
|
if [ "$nCores" -gt 0 ]
|
||||||
then
|
then
|
||||||
# Wait for all of the wmakeLnInclude jobs to finish
|
# Wait for wmakeLnInclude jobs to finish
|
||||||
wait
|
wait
|
||||||
|
|
||||||
# Synchronize the file system to ensure that all of the links exist
|
# Synchronize the file system to ensure that all of the links exist
|
||||||
|
|||||||
Reference in New Issue
Block a user