mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support FOAM_MODULE_PREFIX to guide location of module builds (#1721)
- When compiling additional modules or user code, we need more control
for the installation locations beyond the usual FOAM_USER_LIBBIN,
FOAM_SITE_LIBBIN, FOAM_LIBBIN, and wish to have these values be
modifiable without editing files.
- provide wmake rules for handling standard defaults:
* GENERAL_RULES/module-path-user
* GENERAL_RULES/module-path-group
* GENERAL_RULES/module-path-project
which are incorporated as follows:
Make/options:
include $(GENERAL_RULES)/module-path-user
Make/files:
LIB = $(FOAM_MODULE_LIBBIN)/libMyLibrary
By default these would compile into FOAM_USER_{APPBIN,LIBBIN} but
could be adjusted at compilation time. For example,
```
wmake -module-prefix=/path/my-install-location
```
Or
```
./Allwmake -module-prefix=/path/my-install-location
./Allwmake -prefix=/path/my-install-location
```
Or
```
FOAM_MODULE_PREFIX=/path/my-install-location ./Allwmake
```
ENH: add -no-recursion option for AllwmakeParseArguments
- more descriptive naming than the -fromWmake option (still supported)
- remove wmake/scripts/wmake.{cmake,wmake}-args since the -prefix
handling and -no-recursion is now directly handled by AllwmakeParseArguments
This commit is contained in:
@ -28,9 +28,15 @@
|
||||
# Parsed options (wmake)
|
||||
# -debug
|
||||
# -q | -queue
|
||||
# -module-prefix=...
|
||||
# Exports FOAM_MODULE_PREFIX value.
|
||||
# Unsets FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN.
|
||||
# Handles (user|group|openfoam) or (u|g|o) as per foamEtcFile,
|
||||
# or absolute/relative paths
|
||||
#
|
||||
# Parsed options (special)
|
||||
# -l | -log | -log=FILE
|
||||
# -prefix=... same as -module-prefix=...
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# Check environment
|
||||
@ -54,11 +60,15 @@ Executing ${0##*/} is equivalent to
|
||||
|
||||
wmake -all [OPTIONS]
|
||||
|
||||
With these additional options:
|
||||
-l | -log | -log=name
|
||||
With additional options:
|
||||
-l | -log Tee output to log.\$WM_OPTIONS
|
||||
-log=NAME Tee output to given filename
|
||||
-prefix=... Identical to wmake -module-prefix
|
||||
-no-recursion Prevent recursive call (do NOT call 'wmake -all')
|
||||
-fromWmake Same as -no-recursion
|
||||
|
||||
See
|
||||
wmake -help (or wmake -help-full)
|
||||
wmake -help (or wmake -help-full)
|
||||
|
||||
USAGE
|
||||
exit 0 # clean exit
|
||||
@ -69,7 +79,7 @@ USAGE
|
||||
# Parse the arguments and options
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
unset fromWmake optDebug optLog optQueue
|
||||
unset optDebug optLog optNonRecursive optPrefix optQueue
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
@ -80,19 +90,58 @@ do
|
||||
-h | -help*)
|
||||
usage
|
||||
;;
|
||||
-fromWmake)
|
||||
# If called from wmake (to avoid recursion)
|
||||
fromWmake=true
|
||||
|
||||
-no-recurs* | -fromWmake)
|
||||
# Avoid recursion (eg, if called from wmake)
|
||||
optNonRecursive=true
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
-prefix=* | -module-prefix=*)
|
||||
optPrefix="${arg#*=}"
|
||||
case "$optPrefix" in
|
||||
# Prefix: user
|
||||
(u | user)
|
||||
export FOAM_MODULE_PREFIX="${FOAM_USER_LIBBIN%/*}"
|
||||
;;
|
||||
|
||||
# Prefix: group
|
||||
(g | group)
|
||||
export FOAM_MODULE_PREFIX="${FOAM_SITE_LIBBIN%/*}"
|
||||
;;
|
||||
|
||||
# Prefix: openfoam (other)
|
||||
(o | openfoam)
|
||||
export FOAM_MODULE_PREFIX="${FOAM_LIBBIN%/*}"
|
||||
;;
|
||||
|
||||
# Prefix: custom (absolute or relative)
|
||||
(*)
|
||||
export FOAM_MODULE_PREFIX="$optPrefix"
|
||||
: "${FOAM_MODULE_PREFIX:=/usr/local}" # Default (autoconf)
|
||||
|
||||
# Require absolute path
|
||||
[ "${FOAM_MODULE_PREFIX#/}" != "${FOAM_MODULE_PREFIX}" ] || \
|
||||
FOAM_MODULE_PREFIX="${PWD}/${FOAM_MODULE_PREFIX}"
|
||||
;;
|
||||
esac
|
||||
|
||||
unset FOAM_MODULE_APPBIN FOAM_MODULE_LIBBIN
|
||||
echo "Module prefix = $FOAM_MODULE_PREFIX" 1>&2
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
-k | -keep-going | -non-stop)
|
||||
# Keep going, ignoring errors
|
||||
export WM_CONTINUE_ON_ERROR=true
|
||||
continue # Permanently remove arg
|
||||
;;
|
||||
|
||||
-l | -log)
|
||||
optLog="log.${WM_OPTIONS:-build}"
|
||||
continue # Permanently remove arg
|
||||
;;
|
||||
|
||||
-log=*)
|
||||
optLog="${arg##*=}"
|
||||
if [ -d "$optLog" ]
|
||||
@ -104,17 +153,20 @@ do
|
||||
fi
|
||||
continue # Permanently remove arg
|
||||
;;
|
||||
|
||||
-debug)
|
||||
optDebug="-debug"
|
||||
continue # Permanently remove arg
|
||||
;;
|
||||
|
||||
-q | -queue)
|
||||
optQueue="-queue"
|
||||
continue # Permanently remove arg
|
||||
;;
|
||||
|
||||
lib | libo | libso | dep | objects)
|
||||
# Target type
|
||||
targetType=$arg
|
||||
targetType="$arg"
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -127,7 +179,7 @@ done
|
||||
# Execute wmake -all if not called from wmake
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$fromWmake" ]
|
||||
if [ -z "$optNonRecursive" ]
|
||||
then
|
||||
if [ -z "$optLog" ]
|
||||
then
|
||||
@ -140,7 +192,7 @@ then
|
||||
# Need to cleanup after the tee
|
||||
rc=$? # Error code from tee (not wmake), but not entirely important
|
||||
echo "Done logging to '$optLog'" 1>&2
|
||||
exit $rc
|
||||
exit "$rc"
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -159,7 +211,7 @@ fi
|
||||
# Cleanup local variables and functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
unset fromWmake optDebug optLog optQueue
|
||||
unset optNonRecursive optDebug optLog optPrefix optQueue
|
||||
unset -f usage
|
||||
|
||||
|
||||
|
||||
@ -1,120 +0,0 @@
|
||||
#----------------------------------*-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.cmake-args
|
||||
#
|
||||
# Description
|
||||
# Special-purpose argument parser (eg, for Allwmake scripts)
|
||||
# that handles -prefix=... and some other simpler tasks
|
||||
#
|
||||
# Usage
|
||||
# # Parse the arguments by sourcing this script
|
||||
# . ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.cmake-args
|
||||
#
|
||||
# Options
|
||||
# -prefix=...
|
||||
# Exports CMAKE_INSTALL_PREFIX value.
|
||||
# Handles u(ser), g(roup), o(ther) short-cuts (see foamEtcFile),
|
||||
# absolute or relative paths
|
||||
#
|
||||
# -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
|
||||
|
||||
# Install prefix: user
|
||||
-prefix=u | -prefix=user)
|
||||
export CMAKE_INSTALL_PREFIX="${FOAM_USER_LIBBIN%/*}"
|
||||
echo "Install prefix = user ($CMAKE_INSTALL_PREFIX)" 1>&2
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
# Install prefix: group
|
||||
-prefix=g | -prefix=group)
|
||||
export CMAKE_INSTALL_PREFIX="${FOAM_SITE_LIBBIN%/*}"
|
||||
echo "Install prefix = group ($CMAKE_INSTALL_PREFIX)" 1>&2
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
# Install prefix: other/openfoam
|
||||
-prefix=o | -prefix=other | -prefix=openfoam)
|
||||
export CMAKE_INSTALL_PREFIX="${FOAM_LIBBIN%/*}"
|
||||
echo "Install prefix = openfoam ($CMAKE_INSTALL_PREFIX)" 1>&2
|
||||
continue # Handled argument
|
||||
;;
|
||||
|
||||
# Install prefix: custom
|
||||
-prefix=*)
|
||||
export CMAKE_INSTALL_PREFIX="${arg#*=}"
|
||||
: "${CMAKE_INSTALL_PREFIX:=/usr/local}" # Default as per autoconf
|
||||
|
||||
# Require as absolute path
|
||||
[ "${CMAKE_INSTALL_PREFIX#/}" != "${CMAKE_INSTALL_PREFIX}" ] || \
|
||||
CMAKE_INSTALL_PREFIX="${PWD}/${CMAKE_INSTALL_PREFIX}"
|
||||
|
||||
echo "Install prefix = $CMAKE_INSTALL_PREFIX" 1>&2
|
||||
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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,90 +0,0 @@
|
||||
#----------------------------------*-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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user