mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use new foamEtcFile options to simplify syntax when sourcing files
Can now use this:
_foamSourceEtc config.sh/scotch
_foamSourceEtc config.csh/scotch
instead of this:
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/scotch`
In the bash/sh version, leave the _foamSource function for now, since
ThirdParty is still relying on it.
STYLE: elminate while-loop for _foamAddPath etc since this type of
construct isn't readily possible for csh and isn't being used anywhere.
This commit is contained in:
28
etc/bashrc
28
etc/bashrc
@ -136,10 +136,10 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
|
|||||||
. $WM_PROJECT_DIR/etc/config.sh/functions
|
. $WM_PROJECT_DIR/etc/config.sh/functions
|
||||||
|
|
||||||
# Add in preset user or site preferences:
|
# Add in preset user or site preferences:
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile prefs.sh)
|
_foamSourceEtc prefs.sh
|
||||||
|
|
||||||
# Evaluate command-line parameters and record settings for later
|
# Evaluate command-line parameters and record settings for later.
|
||||||
# these can be used to set/unset values, or specify alternative pref files
|
# These can be used to set/unset values, or specify alternative pref files.
|
||||||
export FOAM_SETTINGS="$@"
|
export FOAM_SETTINGS="$@"
|
||||||
_foamEval $@
|
_foamEval $@
|
||||||
|
|
||||||
@ -162,22 +162,22 @@ export PATH LD_LIBRARY_PATH MANPATH
|
|||||||
|
|
||||||
# Source project setup files
|
# Source project setup files
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
_foamSource $WM_PROJECT_DIR/etc/config.sh/settings
|
_foamSourceEtc config.sh/settings
|
||||||
_foamSource $WM_PROJECT_DIR/etc/config.sh/aliases
|
_foamSourceEtc config.sh/aliases
|
||||||
|
|
||||||
|
|
||||||
# Source user setup files for optional packages
|
# Source user setup files for optional packages
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi)
|
_foamSourceEtc config.sh/mpi
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview)
|
_foamSourceEtc config.sh/paraview
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk)
|
_foamSourceEtc config.sh/vtk
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight)
|
_foamSourceEtc config.sh/ensight
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools)
|
_foamSourceEtc config.sh/gperftools
|
||||||
|
|
||||||
##_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS)
|
#_foamSourceEtc config.sh/ADIOS
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
|
_foamSourceEtc config.sh/CGAL
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
|
_foamSourceEtc config.sh/scotch
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW)
|
_foamSourceEtc config.sh/FFTW
|
||||||
|
|
||||||
|
|
||||||
# Clean environment paths again. Only remove duplicates
|
# Clean environment paths again. Only remove duplicates
|
||||||
|
|||||||
@ -53,7 +53,7 @@ case SYSTEMOPENMPI:
|
|||||||
case OPENMPI:
|
case OPENMPI:
|
||||||
setenv FOAM_MPI openmpi-1.10.4
|
setenv FOAM_MPI openmpi-1.10.4
|
||||||
# Optional configuration tweaks:
|
# Optional configuration tweaks:
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/openmpi`
|
_foamSourceEtc config.csh/openmpi
|
||||||
|
|
||||||
setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI
|
setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,7 @@ if ( ! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system
|
|||||||
|
|
||||||
# Load configured compiler versions, regardless of the compiler type
|
# Load configured compiler versions, regardless of the compiler type
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/compiler`
|
_foamSourceEtc config.csh/compiler
|
||||||
|
|
||||||
switch ("$WM_COMPILER_TYPE")
|
switch ("$WM_COMPILER_TYPE")
|
||||||
case system:
|
case system:
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM.
|
# This file is part of OpenFOAM.
|
||||||
@ -36,20 +36,31 @@ then
|
|||||||
# Temporary environment variable for automatically (un)loading functions
|
# Temporary environment variable for automatically (un)loading functions
|
||||||
WM_BASH_FUNCTIONS=loaded
|
WM_BASH_FUNCTIONS=loaded
|
||||||
|
|
||||||
# Source files, possibly with some verbosity
|
# Source a file, possibly with some verbosity
|
||||||
_foamSource()
|
_foamSource()
|
||||||
{
|
{
|
||||||
while [ $# -ge 1 ]
|
if [ $# -gt 0 -a -f "$1" ]
|
||||||
do
|
then
|
||||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
|
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2
|
||||||
. $1
|
. $1
|
||||||
shift
|
fi
|
||||||
done
|
}
|
||||||
|
|
||||||
|
# Source an etc file, possibly with some verbosity
|
||||||
|
_foamSourceEtc()
|
||||||
|
{
|
||||||
|
local file
|
||||||
|
if [ $# -gt 0 ] && file=$($WM_PROJECT_DIR/bin/foamEtcFile "$@")
|
||||||
|
then
|
||||||
|
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $file" 1>&2
|
||||||
|
. $file
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Evaluate command-line parameters
|
# Evaluate command-line parameters
|
||||||
_foamEval()
|
_foamEval()
|
||||||
{
|
{
|
||||||
|
local file
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -71,9 +82,10 @@ then
|
|||||||
# Filename: source it
|
# Filename: source it
|
||||||
if [ -f "$1" ]
|
if [ -f "$1" ]
|
||||||
then
|
then
|
||||||
_foamSource "$1"
|
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2
|
||||||
|
. "$1"
|
||||||
else
|
else
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile -silent "$1")
|
_foamSourceEtc -silent "$1"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -84,31 +96,19 @@ then
|
|||||||
# Prefix to PATH
|
# Prefix to PATH
|
||||||
_foamAddPath()
|
_foamAddPath()
|
||||||
{
|
{
|
||||||
while [ $# -ge 1 ]
|
[ $# -gt 0 ] && export PATH=$1:$PATH;
|
||||||
do
|
|
||||||
export PATH=$1:$PATH
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prefix to LD_LIBRARY_PATH
|
# Prefix to LD_LIBRARY_PATH
|
||||||
_foamAddLib()
|
_foamAddLib()
|
||||||
{
|
{
|
||||||
while [ $# -ge 1 ]
|
[ $# -gt 0 ] && export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
|
||||||
do
|
|
||||||
export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prefix to MANPATH
|
# Prefix to MANPATH
|
||||||
_foamAddMan()
|
_foamAddMan()
|
||||||
{
|
{
|
||||||
while [ $# -ge 1 ]
|
[ $# -gt 0 ] && export MANPATH=$1:$MANPATH
|
||||||
do
|
|
||||||
export MANPATH=$1:$MANPATH
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -117,6 +117,9 @@ else
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~
|
||||||
unset WM_BASH_FUNCTIONS
|
unset WM_BASH_FUNCTIONS
|
||||||
unset -f _foamAddPath _foamAddLib _foamAddMan
|
unset -f _foamAddPath _foamAddLib _foamAddMan
|
||||||
unset -f _foamSource _foamEval
|
unset -f _foamSourceEtc _foamEval
|
||||||
|
unset -f _foamSource
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -56,7 +56,7 @@ SYSTEMOPENMPI)
|
|||||||
OPENMPI)
|
OPENMPI)
|
||||||
export FOAM_MPI=openmpi-1.10.4
|
export FOAM_MPI=openmpi-1.10.4
|
||||||
# Optional configuration tweaks:
|
# Optional configuration tweaks:
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/openmpi)
|
_foamSourceEtc config.sh/openmpi
|
||||||
|
|
||||||
export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI
|
export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI
|
||||||
|
|
||||||
|
|||||||
@ -211,7 +211,7 @@ unset GMP_ARCH_PATH MPFR_ARCH_PATH
|
|||||||
|
|
||||||
# Load configured compiler versions, regardless of the compiler type
|
# Load configured compiler versions, regardless of the compiler type
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
|
_foamSourceEtc config.sh/compiler
|
||||||
|
|
||||||
case "$WM_COMPILER_TYPE" in
|
case "$WM_COMPILER_TYPE" in
|
||||||
system)
|
system)
|
||||||
|
|||||||
44
etc/cshrc
44
etc/cshrc
@ -144,20 +144,23 @@ endif
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
||||||
|
|
||||||
|
# Source etc files, possibly with some verbosity
|
||||||
# Source files, possibly with some verbosity
|
if ($?FOAM_VERBOSE && $?prompt) then
|
||||||
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*'
|
alias _foamSourceEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`'
|
||||||
|
else
|
||||||
|
alias _foamSourceEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh \!*`'
|
||||||
|
endif
|
||||||
|
|
||||||
# Add in preset user or site preferences:
|
# Add in preset user or site preferences:
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
_foamSourceEtc prefs.csh
|
||||||
|
|
||||||
# Evaluate command-line parameters and record settings for later
|
# Evaluate command-line parameters and record settings for later.
|
||||||
# these can be used to set/unset values, or specify alternative pref files
|
# These can be used to set/unset values, or specify alternative pref files.
|
||||||
setenv FOAM_SETTINGS "${*}"
|
setenv FOAM_SETTINGS "${*}"
|
||||||
while ( $#argv > 0 )
|
while ( $#argv > 0 )
|
||||||
switch ($argv[1])
|
switch ($argv[1])
|
||||||
case -*:
|
case -*:
|
||||||
# stray option (not meant for us here) -> get out
|
# Stray option (not meant for us here) -> get out
|
||||||
break
|
break
|
||||||
breaksw
|
breaksw
|
||||||
case *=:
|
case *=:
|
||||||
@ -171,11 +174,12 @@ while ( $#argv > 0 )
|
|||||||
eval "setenv $argv[1]:s/=/ /"
|
eval "setenv $argv[1]:s/=/ /"
|
||||||
breaksw
|
breaksw
|
||||||
default:
|
default:
|
||||||
# filename: source it
|
# Filename: source it
|
||||||
if ( -f "$1" ) then
|
if ( -f "$1" ) then
|
||||||
_foamSource "$1"
|
if ($?FOAM_VERBOSE && $?prompt) echo "Using: $1"
|
||||||
|
source "$1"
|
||||||
else
|
else
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"`
|
_foamSourceEtc -silent "$1"
|
||||||
endif
|
endif
|
||||||
breaksw
|
breaksw
|
||||||
endsw
|
endsw
|
||||||
@ -208,19 +212,19 @@ if ( $status == 0 ) setenv MANPATH $cleaned
|
|||||||
|
|
||||||
# Source project setup files
|
# Source project setup files
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
_foamSource $WM_PROJECT_DIR/etc/config.csh/settings
|
_foamSourceEtc config.csh/settings
|
||||||
_foamSource $WM_PROJECT_DIR/etc/config.csh/aliases
|
_foamSourceEtc config.csh/aliases
|
||||||
|
|
||||||
# Source user setup files for optional packages
|
# Source user setup files for optional packages
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi`
|
_foamSourceEtc config.csh/mpi
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/paraview`
|
_foamSourceEtc config.csh/paraview
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/vtk`
|
_foamSourceEtc config.csh/vtk
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/ensight`
|
_foamSourceEtc config.csh/ensight
|
||||||
|
|
||||||
##_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/ADIOS`
|
#_foamSourceEtc config.csh/ADIOS
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/CGAL`
|
_foamSourceEtc config.csh/CGAL
|
||||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/FFTW`
|
_foamSourceEtc config.csh/FFTW
|
||||||
|
|
||||||
|
|
||||||
# Clean environment paths again. Only remove duplicates
|
# Clean environment paths again. Only remove duplicates
|
||||||
@ -247,6 +251,6 @@ endif
|
|||||||
# Cleanup environment:
|
# Cleanup environment:
|
||||||
# ~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~
|
||||||
unset cleaned foamClean foamOldDirs
|
unset cleaned foamClean foamOldDirs
|
||||||
unalias _foamSource
|
unalias _foamSourceEtc
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user