mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: openfoam shell session - improved and relocated
- '-c' option (as per shell), '-Dkey[=value]' option to provide
preferences via the command-line. For example,
etc/openfoam -DWM_COMPILER=Clang -int64 ./Allwmake -j -s -l
These can also be combined with other options. Eg,
etc/openfoam -DWM_COMPILER=Clang \
-c 'wmake -show-path-cxx -show-cxxflags'
- relocated from bin/tools/ => etc/ for easier access
- bin/tools/openfoam.in : for autoconfig-style installation
- Auto-detect if the shell script was executed with openfoam and
interpret accordingly.
Simple example,
--------------
#!/usr/bin/openfoam
cd "${0%/*}" || exit # Run -*-sh-*- from this dir
blockMesh
simpleFoam
--------------
Note it is NOT currently possible to provide any other parameters
this way. Eg,
`#!/usr/bin/openfoam -sp` (NOT)
This will either fail to run, or result in infinite recursion.
This commit is contained in:
@ -5,34 +5,36 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# bin/tools/source-bashrc
|
||||
#
|
||||
# Description
|
||||
# Source user ~/.bashrc and OpenFOAM etc/bashrc
|
||||
# Source user ~/.bashrc and OpenFOAM etc/bashrc.
|
||||
# Not normally sourced manually, but from bash with the --rcfile option.
|
||||
#
|
||||
# This file is normally not sourced manually,
|
||||
# but from bash with the --rcfile option.
|
||||
#------------------------------------------------------------------------------
|
||||
# Hard-coded value (eg, with autoconfig)
|
||||
# Hard-coded directory path (eg, autoconfig)
|
||||
projectDir="@PROJECT_DIR@"
|
||||
|
||||
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
|
||||
then
|
||||
# Auto-detect (as per OpenFOAM etc/bashrc)
|
||||
# Auto-detect location (as per OpenFOAM etc/bashrc)
|
||||
# --
|
||||
# Assuming this file is $WM_PROJECT_DIR/bin/tools/source-bashrc,
|
||||
# the next lines should work when sourced by BASH or ZSH shells.
|
||||
# --
|
||||
|
||||
projectDir="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
|
||||
[ -n "$projectDir" ] && projectDir="$(\cd $(dirname $projectDir)/../.. && \pwd -L)" || unset projectDir
|
||||
if [ -n "$projectDir" ]
|
||||
then
|
||||
projectDir="$(\cd "$(dirname "$projectDir")"/../.. && \pwd -L)" || \
|
||||
unset projectDir
|
||||
fi
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -66,7 +68,7 @@ then
|
||||
# Some feedback
|
||||
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
|
||||
then
|
||||
info="$(foamEtcFile -show-patch 2>/dev/null)"
|
||||
info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
|
||||
|
||||
# echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2
|
||||
echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2
|
||||
|
||||
Reference in New Issue
Block a user