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
|
||||
|
||||
# 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
|
||||
# these can be used to set/unset values, or specify alternative pref files
|
||||
# Evaluate command-line parameters and record settings for later.
|
||||
# These can be used to set/unset values, or specify alternative pref files.
|
||||
export FOAM_SETTINGS="$@"
|
||||
_foamEval $@
|
||||
|
||||
@ -162,22 +162,22 @@ export PATH LD_LIBRARY_PATH MANPATH
|
||||
|
||||
# Source project setup files
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
_foamSource $WM_PROJECT_DIR/etc/config.sh/settings
|
||||
_foamSource $WM_PROJECT_DIR/etc/config.sh/aliases
|
||||
_foamSourceEtc config.sh/settings
|
||||
_foamSourceEtc config.sh/aliases
|
||||
|
||||
|
||||
# Source user setup files for optional packages
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools)
|
||||
_foamSourceEtc config.sh/mpi
|
||||
_foamSourceEtc config.sh/paraview
|
||||
_foamSourceEtc config.sh/vtk
|
||||
_foamSourceEtc config.sh/ensight
|
||||
_foamSourceEtc config.sh/gperftools
|
||||
|
||||
##_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW)
|
||||
#_foamSourceEtc config.sh/ADIOS
|
||||
_foamSourceEtc config.sh/CGAL
|
||||
_foamSourceEtc config.sh/scotch
|
||||
_foamSourceEtc config.sh/FFTW
|
||||
|
||||
|
||||
# Clean environment paths again. Only remove duplicates
|
||||
|
||||
@ -53,7 +53,7 @@ case SYSTEMOPENMPI:
|
||||
case OPENMPI:
|
||||
setenv FOAM_MPI openmpi-1.10.4
|
||||
# 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
|
||||
|
||||
|
||||
@ -212,7 +212,7 @@ if ( ! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system
|
||||
|
||||
# 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")
|
||||
case system:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# \\/ M anipulation |
|
||||
# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
@ -36,20 +36,31 @@ then
|
||||
# Temporary environment variable for automatically (un)loading functions
|
||||
WM_BASH_FUNCTIONS=loaded
|
||||
|
||||
# Source files, possibly with some verbosity
|
||||
# Source a file, possibly with some verbosity
|
||||
_foamSource()
|
||||
{
|
||||
while [ $# -ge 1 ]
|
||||
do
|
||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
|
||||
if [ $# -gt 0 -a -f "$1" ]
|
||||
then
|
||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2
|
||||
. $1
|
||||
shift
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# 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
|
||||
_foamEval()
|
||||
{
|
||||
local file
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
@ -71,9 +82,10 @@ then
|
||||
# Filename: source it
|
||||
if [ -f "$1" ]
|
||||
then
|
||||
_foamSource "$1"
|
||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2
|
||||
. "$1"
|
||||
else
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile -silent "$1")
|
||||
_foamSourceEtc -silent "$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@ -84,31 +96,19 @@ then
|
||||
# Prefix to PATH
|
||||
_foamAddPath()
|
||||
{
|
||||
while [ $# -ge 1 ]
|
||||
do
|
||||
export PATH=$1:$PATH
|
||||
shift
|
||||
done
|
||||
[ $# -gt 0 ] && export PATH=$1:$PATH;
|
||||
}
|
||||
|
||||
# Prefix to LD_LIBRARY_PATH
|
||||
_foamAddLib()
|
||||
{
|
||||
while [ $# -ge 1 ]
|
||||
do
|
||||
export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
|
||||
shift
|
||||
done
|
||||
[ $# -gt 0 ] && export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
|
||||
}
|
||||
|
||||
# Prefix to MANPATH
|
||||
_foamAddMan()
|
||||
{
|
||||
while [ $# -ge 1 ]
|
||||
do
|
||||
export MANPATH=$1:$MANPATH
|
||||
shift
|
||||
done
|
||||
[ $# -gt 0 ] && export MANPATH=$1:$MANPATH
|
||||
}
|
||||
|
||||
else
|
||||
@ -117,6 +117,9 @@ else
|
||||
# ~~~~~~~~~~~~~~~~~~~~
|
||||
unset WM_BASH_FUNCTIONS
|
||||
unset -f _foamAddPath _foamAddLib _foamAddMan
|
||||
unset -f _foamSource _foamEval
|
||||
unset -f _foamSourceEtc _foamEval
|
||||
unset -f _foamSource
|
||||
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -56,7 +56,7 @@ SYSTEMOPENMPI)
|
||||
OPENMPI)
|
||||
export FOAM_MPI=openmpi-1.10.4
|
||||
# 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
|
||||
|
||||
|
||||
@ -211,7 +211,7 @@ unset GMP_ARCH_PATH MPFR_ARCH_PATH
|
||||
|
||||
# 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
|
||||
system)
|
||||
|
||||
44
etc/cshrc
44
etc/cshrc
@ -144,20 +144,23 @@ endif
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~
|
||||
setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
||||
|
||||
|
||||
# Source files, possibly with some verbosity
|
||||
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*'
|
||||
# Source etc files, possibly with some verbosity
|
||||
if ($?FOAM_VERBOSE && $?prompt) then
|
||||
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:
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
||||
_foamSourceEtc prefs.csh
|
||||
|
||||
# Evaluate command-line parameters and record settings for later
|
||||
# these can be used to set/unset values, or specify alternative pref files
|
||||
# Evaluate command-line parameters and record settings for later.
|
||||
# These can be used to set/unset values, or specify alternative pref files.
|
||||
setenv FOAM_SETTINGS "${*}"
|
||||
while ( $#argv > 0 )
|
||||
switch ($argv[1])
|
||||
case -*:
|
||||
# stray option (not meant for us here) -> get out
|
||||
# Stray option (not meant for us here) -> get out
|
||||
break
|
||||
breaksw
|
||||
case *=:
|
||||
@ -171,11 +174,12 @@ while ( $#argv > 0 )
|
||||
eval "setenv $argv[1]:s/=/ /"
|
||||
breaksw
|
||||
default:
|
||||
# filename: source it
|
||||
# Filename: source it
|
||||
if ( -f "$1" ) then
|
||||
_foamSource "$1"
|
||||
if ($?FOAM_VERBOSE && $?prompt) echo "Using: $1"
|
||||
source "$1"
|
||||
else
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"`
|
||||
_foamSourceEtc -silent "$1"
|
||||
endif
|
||||
breaksw
|
||||
endsw
|
||||
@ -208,19 +212,19 @@ if ( $status == 0 ) setenv MANPATH $cleaned
|
||||
|
||||
# Source project setup files
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
_foamSource $WM_PROJECT_DIR/etc/config.csh/settings
|
||||
_foamSource $WM_PROJECT_DIR/etc/config.csh/aliases
|
||||
_foamSourceEtc config.csh/settings
|
||||
_foamSourceEtc config.csh/aliases
|
||||
|
||||
# Source user setup files for optional packages
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/paraview`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/vtk`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/ensight`
|
||||
_foamSourceEtc config.csh/mpi
|
||||
_foamSourceEtc config.csh/paraview
|
||||
_foamSourceEtc config.csh/vtk
|
||||
_foamSourceEtc config.csh/ensight
|
||||
|
||||
##_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/ADIOS`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/CGAL`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/FFTW`
|
||||
#_foamSourceEtc config.csh/ADIOS
|
||||
_foamSourceEtc config.csh/CGAL
|
||||
_foamSourceEtc config.csh/FFTW
|
||||
|
||||
|
||||
# Clean environment paths again. Only remove duplicates
|
||||
@ -247,6 +251,6 @@ endif
|
||||
# Cleanup environment:
|
||||
# ~~~~~~~~~~~~~~~~~~~~
|
||||
unset cleaned foamClean foamOldDirs
|
||||
unalias _foamSource
|
||||
unalias _foamSourceEtc
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user