Commit Graph

24 Commits

Author SHA1 Message Date
Mark Olesen
e2148b587e CONFIG: inline _foamEval within <etc/config.sh/setup>
- previously a function (unlike the csh version) but since bashrc and
  setup have been split -> replace with inline definition

STYLE: formatting/wording for openfoam starters

TUT: simplify controlDict modification, add default substitution

ENH: accept '/' for end-of-options terminator (etc/openfoam)

- makes the application or service more apparent.
  * eg.  /usr/bin/openfoam / blockMesh
  * vs.  /usr/bin/openfoam -- blockMesh

  Accept lone '-' as the end-of-options terminator, as per bash

- Adjust handling of openfoam '-c' option to flag that a command-string
  will appear, but continue with option parsing.
  Consistent with bash definition.
2021-06-18 17:14:22 +02:00
Mark Olesen
f01ad2f187 CONFIG: improve config files for Darwin (#1667), BSD-csh syntax (#1668)
- use Clang instead of Gcc for Darwin since this is its system
  compiler. The user can force use of Gcc by using Gcc92 etc.

- make etc/cshrc sed check more robust.

- replace tcsh (${%var}) syntax with ("${var}" != "")

[Fixes and ideas from Alexey Matveichev]

CONFIG: do not source the gperftools environment by default

- this is now an used feature, but can be re-enabled by advanced users
  if required.
2020-04-08 11:38:18 +02:00
Mark Olesen
5ba2cbc54f CONFIG: improve prefix matching for system libraries (#1607)
- missed detection of system libraries when installed with multiarch
  paths like /usr/lib/x86_64-linux-gnu

CONFIG: improve handling of group/user config files (#928)

- changed bashrc handling of FOAM_CONFIG_NOUSER to use
  FOAM_CONFIG_MODE instead. Propagate into foamEtcFile to make this
  a stickier control.

  This change allows better control, but also enables cluster
  installations to define their own value within the OpenFOAM prefs.sh
  file to prevent users accidentally mis-configuring things if
  necessary.

- remove undocumented handling of an (a)ll mode in foamEtcFile to
  avoid potential pitfalls.

- add support for FOAM_CONFIG_ETC handling.
  This allows injection of an extra search layer when finding
  project etc files

ENH: improvements to foamConfigurePaths (#928)

- handle FOAM_CONFIG_ETC implicitly, or explicitly with the new
  -etc option.

STYLE: more explicit wording in foamConfigurePaths usage (#1602)

- document that an absolute path (eg, -scotch-path) overrides/ignores
  the equivalent ThirdParty setting (eg, -scotch)

- longer options -system-compiler and -third-compiler for -system
  and -third, respectively. Clearer as to their purpose.

- adjust the location sanity check to look for META-INFO directory.
2020-02-24 16:00:16 +01:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
170baf4d3b STYLE: use '&&', '||' instead of '-a' and '-o' for some shell commands 2018-12-10 15:13:15 +01:00
Mark Olesen
6c68c34e1a ENH: update handling of versioning and make control (issue #1010)
- Use the OPENFOAM define (eg, 1806, 1812), which normally corresponds
  to a major release, to define an API level. This remains consistent
  within a release cycle and means that it is possible to manage
  several sub-versions and continue to have a consistent lookup.

  The current API value is updated automatically during the build
  and cached as meta data for later use, even when the wmake/ directory
  is missing or OpenFOAM has not yet be initialized.

  The version information reported on program start or with -help
  usage adjusted to reflect this. The build tag from git now also
  carries the date as being more meaningful to trace than a hash
  value.

- Update etc/bashrc and etc/cshrc to obtain the project directory
  directly instead of via its prefix directory. The value obtained
  corresponds to an absolute path, from which the prefix directory
  can be obtained.

  The combination of these changes removes the reliance on any
  particular directory naming convention.
  For example,

     With an 1812 version (API level):

     WM_PROJECT_VERSION=myVersion

     installed as /some/path/somewhere/openfoam-mySandbox

  This makes the -prefix, -foamInstall, -projectVersion, -version
  values of foamEtcFiles, and similar entries for foamConfigurePaths
  superfluous.

  WM_PROJECT_INST_DIR is no longer required or used

ENH: improve handling and discovery of ThirdParty

- improve the flexibility and reusability of ThirdParty packs to cover
  various standard use cases:

    1. Unpacking initial release tar files with two parallel directories
       - OpenFOAM-v1812/
       - ThirdParty-v1812/

    2. With an adjusted OpenFOAM directory name, for whatever reason
       - OpenFOAM-v1812-myCustom/
       - openfoam-1812-other-info/

    3. Operating with/without ThirdParty directory

  To handle these use cases, the following discovery is used.

  Note PROJECT = the OpenFOAM directory `$WM_PROJECT_DIR`
       PREFIX = the parent directory
       VERSION = `$WM_PROJECT_VERSION`
       API = `$WM_PROJECT_API`, as per `foamEtcFiles -show-api`

   0. PROJECT/ThirdParty
      - for single-directory installations

   1. PREFIX/ThirdParty-VERSION
      - this corresponds to the traditional approach

   2. PREFIX/ThirdParty-vAPI
      - allows for an updated value of VERSION (eg, v1812-myCustom)
        without requiring a renamed ThirdParty. The API value
        would still be '1812' and the original ThirdParty-v1812/
        would be found.

   3. PREFIX/ThirdParty-API
      - this is the same as the previous example, but using an unadorned
        API value. This also makes sense if the chosen version name also
        uses the unadorned API value in its naming
        (eg, 1812-patch190131, 1812.19W03)

   4. PREFIX/ThirdParty-common
      - permits maximum reuse for various versions, but only for
        experienced user who are aware of potential version
        incompatibilities

   Directory existence is checked as is the presence of an Allwmake file
   or a platforms/ directory. This reduces the potential of false positive
   matches and limits the selection to directories that are either
   with sources (has the Allwmake file), or pre-compiled binaries (has
   the platforms/ directory).

   If none of the explored directories are found to be suitable,
   it reverts to using a PROJECT/ThirdParty dummy location since
   this is within the project source tree and can be trusted to
   have no negative side-effects.

ENH: add csh support to foamConfigurePaths

- this removes the previously experienced inconsistence in config file
  contents.

REMOVED: foamExec

- was previously used when switching versions and before the
  bashrc/cshrc discovery logic was added. It is now obsolete.
2018-12-02 18:25:57 +01:00
Mark Olesen
d45d7ca8c3 STYLE: adjust looping parameter for _foamEval 2018-11-29 12:45:45 +01:00
Mark Olesen
50852b3392 CONFIG: improve shell env handling of paths with spaces (#1007, #1008)
- foamCleanPath now only splits the environment variable on ':', which
  allows other directories with spaces or '(..)' etc to pass through
  without major issue.

- The filter arguments are split on whitespace, colons or semi-colons.
2018-10-15 21:37:46 +02:00
Mark Olesen
957d8dc38d CONFIG: force loading of shell functions (issue #944)
- this avoids a situation when an aborted sourcing of the etc/bashrc
  file can leave WM_SHELL_FUNCTIONS defined, which causes all
  subsequent sourcing to fail.
2018-07-19 16:57:38 +02:00
Mark Olesen
a225d5f87a ENH: more tuning parameters for user environment
- FOAM_CONFIG_NOUSER
  Suppress use of user/group configuration files.
  This is useful when packaging for a central installation.

- allow additional user tuning of compiler settings.
  Per-compiler overrides in "compiler-$WM_COMPILER" files
2018-07-18 10:25:55 +02:00
Mark Olesen
b4d38ab468 ENH: improve handling of ThirdParty packages
- generalize some of the library extensions (.so vs .dylib).
  Provide as wmake 'sysFunctions'

- added note about unsupported/incomplete system support

- centralize detection of ThirdParty packages into wmake/ subdirectory
  by providing a series of scripts in the spirit of GNU autoconfig.
  For example,

      have_boost, have_readline, have_scotch, ...

  Each of the `have_<package>` scripts will generally provide the
  following type of functions:

      have_<package>          # detection
      no_<package>            # reset
      echo_<package>          # echoing

  and the following type of variables:

      HAVE_<package>          # unset or 'true'
      <package>_ARCH_PATH     # root for <package>
      <package>_INC_DIR       # include directory for <package>
      <package>_LIB_DIR       # library directory for <package>

  This simplifies the calling scripts:

      if have_metis
      then
          wmake metisDecomp
      fi

  As well as reducing clutter in the corresponding Make/options:

      EXE_INC = \
          -I$(METIS_INC_DIR) \
          -I../decompositionMethods/lnInclude

      LIB_LIBS = \
          -L$(METIS_LIB_DIR) -lmetis

  Any additional modifications (platform-specific or for an external build
  system) can now be made centrally.
2018-04-24 14:51:19 +02:00
Mark Olesen
110b00f048 ENH: improved handling of gmp/mpfr library settings (issue #674)
- export library path for gmp/mpfr from CGAL config files.
  This is required when non-system gmp/mpfr libraries are being
  used, but not using a ThirdParty compiler installation.

- automatically handle lib/ vs lib64/ (eg, for central installations)
  for packages such as boost, CGAL, etc. While the ThirdParty
  compilation of these will normally land in lib64/, this may not be
  the case when they are supplied by another means.

- reworked the handling of foamEtcFile and foamCleanPath for less
  clutter in the configuration files.
  Added the bin/tools/lib-dir script to handle logic that is
  too complex to easily manage in csh.
2018-01-11 01:30:23 +01:00
Mark Olesen
05a8fe5dd3 STYLE: compact license text in config files for easier reading/editing 2017-11-20 09:00:10 +01:00
Mark Olesen
7f01a4beda CONFIG: address differences between shells
- suppress error messages that appear with zsh.
  According to unset(1p), 'unset -f' unsets a function.
  If the function was not previously defined, this is a no-op.
  This is similar for zsh, but there it emits a warning if the
  function was not previously defined.

- avoid 'local' in functions sources from etc/bashrc.
  ksh does not support this.

- use 'command' shell builtin instead of 'type'.
  Seems to be more consistent between shell flavours.
2017-04-20 11:02:54 +02:00
Mark Olesen
b970ba0901 ENH: minor improvements to environment
- handle sourcing bashrc with a relative path (issue #383)
- handle sourcing from bash and zsh.
  Still need manual intervention when sourcing dash, sh, or ksh.
- replace grep in etc/cshrc with sed only
- logical instead of physical path for WM_PROJECT_DIR (issue #431).
  Doesn't seem to be possible for csh/tcsh.

  * Continue using physical locations when comparing directories,
    but not for the top-level FOAM_INST_DIR, WM_PROJECT_DIR.

- relocate WM_CC, WM_CXX overrides from etc/config.*/compiler
  to etc/config.*/settings to ensure that they are left untouched
  when etc/config.sh/compiler is sourced while making third-party
  packages (eg, gcc, llvm, CGAL).

- provide fallback FOAM_TUTORIALS setting in RunFunctions

STYLE: remove "~OpenFOAM" fallback as being too rare, non-obvious
2017-03-20 08:57:12 +01:00
Mark Olesen
4339d93c8e STYLE: drop _foamSource definition (unneeded). 2017-03-14 17:24:23 +01:00
Mark Olesen
c84b9aaac6 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.
2017-02-23 15:55:38 +01:00
Mark Olesen
07ec2b3abd STYLE: eliminate most use of _foamSource outside of the etc/ hierarchy 2017-02-23 10:58:55 +01:00
Mark Olesen
d3911dd167 STYLE: avoid old-style shell backticks in various places 2017-02-20 09:30:58 +01:00
Andrew Heather
9fbd612672 GIT: Initial state after latest Foundation merge 2016-09-20 14:49:08 +01:00
Mark Olesen
9c0a04d8be BUG: need 'unset -f' to unset functions (issue #170)
- triggered by dash.
2016-07-01 17:55:03 +02:00
Henry Weller
ce81c49d2e etc/bashrc, etc/cshrc: Filter $WM_PROJECT_DIR from paths rather than $FOAM_INST_DIR
Additionally filter $ParaView_DIR from paths in config.sh/paraview and config.csh/paraview

Resolves bug-report http://bugs.openfoam.org/view.php?id=2031
2016-05-05 15:37:00 +01:00
Henry Weller
4409a0ea5a etc/bashrc, etc/config.sh: Updates provided by Bruno Santos:
1. "foamCompiler" was changed to a more permanent "WM_COMPILER_TYPE"
    environment variable, so that it can be used by 3rd party
    installation scripts, such as "makeGcc", "makeLLVM" and so on. More
    on this will be provided in issue #1215.

 2. The script functions such as "_foamSource()" and "_foamAddPath()"
    were moved to a new file "etc/config.sh/functions". It has the
    ability to set or unset, depending on whether "WM_BASH_FUNCTIONS" is
    defined or not. This allows for these functions to be reused by
    other scripts, such as "makeGcc".

 3. The script "etc/config.sh/CGAL" relies on whether a local
    environment variable "SOURCE_CGAL_VERSIONS_ONLY" is defined or not,
    so that it will load only the version settings if it's defined. This
    is to make it easier to call this script from "makeCGAL". Although
    it still feels a bit of a clunky hack, but I didn't manage to deduce
    any other way we could do this :( I didn't add indentation within
    the if-block, to make it easier to read the changes. In addition,
    the local variable "common_path" is used to shorten the length of
    the lines and use slightly less repeated code.

 4. Added another new script "etc/config.sh/compiler", which has only
    the version numbers for the compilers taken out from the "settings"
    file. It currently depends on "WM_COMPILER_TYPE" for setting the
    variables, the same way it did with "foamCompiler". This script is
    now always sourced from the "settings" file, for the following
    reasons:

   - "makeGCC" and "makeLLVM" can now take advantage of this script file.

   - The example "compiler" script (detailed next) can rely on this
     script file and then override parameters on-demand, as well as
     allowing for system compilers to have dedicated settings, such as
     setting "WM_CC". This is similar to how the example environment
     script for "paraview" works.

 5. To the script "etc/config.sh/example/compiler" were added a few more examples:

   - It now starts with a block where it first loads the default "compiler" script.

   - Has a "WM_COMPILER=Gcc48u" case example for when we try to use GCC
     4.8 in Ubuntu 15.10. This is just to give the idea that in a
     particular system, we might have several system-wide compiler
     versions. For example, in Ubuntu 15.10, there is GCC 4.7, 4.8 and
     5.2, which could be used for testing performances or compatibility
     with some other 3rd party library.

   - Has the "WM_COMPILER=Icc" case example, related to the original bug
     report, where "WM_CC=icc" and "WM_CXX=icpc", so that the user then
     simply copies this file to their own local preferences folder.

 6. Small bug fix in "etc/config.sh/mpi", where unsetting "minBufferSize" was missing at the end of the script.

 7. Small change in "etc/config.sh/paraview", where "CMAKE_ROOT" is set
    along with "CMAKE_HOME". This is due to a rare issue that occurs on
    people's systems where they have a custom system-wide CMake version
    installed and which is used by having "CMAKE_ROOT" set on that
    environment. This can mess up OpenFOAM's custom ParaView builds,
    given that conflicting CMake versions can lead to not building
    ParaView at all.

   - For more details about "CMAKE_ROOT":
     https://cmake.org/Wiki/CMake_Useful_Variables [^]

 8. The scripts "_foamAddPath _foamAddLib _foamAddMan" were not being
    unset at the end of "settings". They are now unset at the end of
    "bashrc", through a call to the new double-use "functions" script.

Additionally all references to "foamCompiler" have been changed to
"WM_COMPILER_TYPE".

See also http://www.openfoam.org/mantisbt/view.php?id=1232
2016-03-09 09:01:09 +00:00