Commit 553c01d5 authored by Mark Olesen's avatar Mark Olesen
Browse files

CONFIG: bin/tools/query-versions

- Query the etc/config.sh values for ThirdParty software.
  Usable without an active OpenFOAM environment.
parent 739bc3c4
#!/bin/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.
#
# Script
# query-versions
#
# Description
# Query (ThirdParty) versions based on their etc/config.sh values
# Executes their respective -query.
#
# TODO
# cmake, vtk, paraview
#
#------------------------------------------------------------------------------
# Hard-coded value (eg, with autoconfig)
projectDir="@PROJECT_DIR@"
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
then
# Auto-detect from location
toolsDir="${0%/*}" # The bin/tools dir
projectDir="${toolsDir%/bin/tools}" # Project dir
case "$projectDir" in
(/bin | /usr/bin | /usr/local/bin)
# This shouldn't happen.
# If copied to a system dir, should also be using hard-coded values!
echo "Warning: suspicious looking project dir: $projectDir" 1>&2
;;
("$toolsDir")
# Eg, called as ./openfoam etc - need to try harder
projectDir="$(\cd $(dirname $0)/../.. && \pwd -L)" || unset projectDir
;;
esac
fi
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION]
options:
-h, -help Print the usage
Query (ThirdParty) versions based on their etc/config.sh values.
Uses OpenFOAM wmake/scripts/have_* scripts.
USAGE
exit 1
}
#------------------------------------------------------------------------------
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
# Print help
(-h | -help*)
usage
;;
(*)
echo "Ignore unknown option/argument: $@" 1>&2
break
;;
esac
shift
done
#------------------------------------------------------------------------------
scriptsDir="$projectDir/wmake/scripts"
[ -d "$scriptsDir" ] || {
echo "No such directory: $scriptsDir" 1>&2
exit 2
}
# Allow operation without an active OpenFOAM environment
export WM_PROJECT_DIR="$projectDir"
#------------------------------------------------------------------------------
# Examine the "wmake/scripts/have_..." scripts for query_...() functions,
# assume they also have a -query option
for script in grep -l -e '^query_' "$scriptsDir"/have_*
do
if [ -f "$script" ]
then
bash "$script" -query
fi
done
#------------------------------------------------------------------------------
......@@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_adios2
......@@ -21,7 +20,7 @@
# ADIOS2_ARCH_PATH
#
# Functions provided
# have_adios2, no_adios2, echo_adios2, hint_adios2
# have_adios2, no_adios2, echo_adios2, hint_adios2, query_adios2
#
# Variables set on success
# HAVE_ADIOS2
......@@ -68,19 +67,37 @@ INFORMATION
}
# Query settings
query_adios2()
{
local config="config.sh/adios2"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query adios2 "$ADIOS2_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "adios2=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR
have_adios2()
{
local config="config.sh/adios2"
local prefix header library incName libName settings warn
# warn="==> skip adios2"
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/adios2)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/adios2 settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
......@@ -135,11 +152,15 @@ have_adios2()
# Force reset of old variables
no_adios2
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_adios2
echo_adios2
fi
;;
-query)
query_adios2
;;
esac
#------------------------------------------------------------------------------
......@@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_boost
#
# Description
# Detection/setup of Boost
# Detection/setup of BOOST
#
# Requires
# BOOST_ARCH_PATH
#
# Functions provided
# have_boost, no_boost, echo_boost
# have_boost, no_boost, echo_boost, query_boost
#
# Variables set on success
# HAVE_BOOST
......@@ -52,6 +51,23 @@ echo_boost()
}
# Query settings (from CGAL setup)
query_boost()
{
local config="config.sh/CGAL"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query boost "$BOOST_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "boost=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR
have_boost()
......@@ -114,11 +130,15 @@ have_boost()
# Force reset of old variables
no_boost
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_boost
echo_boost
fi
;;
-query)
query_boost
;;
esac
#------------------------------------------------------------------------------
......@@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_ccmio
#
# Description
# Detection/setup of ccmio
# Detection/setup of CCMIO
#
# Requires
# config.sh/ccmio
#
# Functions provided
# have_ccmio, no_ccmio, echo_ccmio
# have_ccmio, no_ccmio, echo_ccmio, query_ccmio
#
# Variables set on success
# HAVE_CCMIO
......@@ -51,19 +50,36 @@ echo_ccmio()
}
# Query settings
query_ccmio()
{
local config="config.sh/ccmio"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query ccmio "$CCMIO_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "ccmio=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR
have_ccmio()
{
local config="config.sh/ccmio"
local prefix header library incName libName settings warn
warn="==> skip ccmio"
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/ccmio settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
......@@ -140,11 +156,15 @@ have_ccmio()
# Force reset of old variables
no_ccmio
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_ccmio
echo_ccmio
fi
;;
-query)
query_ccmio
;;
esac
#------------------------------------------------------------------------------
......@@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_cgal
......@@ -21,7 +20,7 @@
# CGAL_ARCH_PATH
#
# Functions provided
# have_cgal, no_cgal, echo_cgal
# have_cgal, no_cgal, echo_cgal, query_cgal
#
# Variables set on success
# HAVE_CGAL
......@@ -52,6 +51,23 @@ echo_cgal()
}
# Query settings (from CGAL setup)
query_cgal()
{
local config="config.sh/CGAL"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query cgal "$CGAL_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "cgal=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR
have_cgal()
......@@ -114,11 +130,15 @@ have_cgal()
# Force reset of old variables
no_cgal
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_cgal
echo_cgal
fi
;;
-query)
query_cgal
;;
esac
#------------------------------------------------------------------------------
......@@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_fftw
......@@ -21,7 +20,7 @@
# FFTW_ARCH_PATH
#
# Functions provided
# have_fftw, no_fftw, echo_fftw
# have_fftw, no_fftw, echo_fftw, query_fftw
#
# Variables set on success
# HAVE_FFTW
......@@ -52,6 +51,23 @@ echo_fftw()
}
# Query settings
query_fftw()
{
local config="config.sh/FFTW"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query fftw "$FFTW_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "fftw=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw()
......@@ -112,11 +128,15 @@ have_fftw()
# Force reset of old variables
no_fftw
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_fftw
echo_fftw
fi
;;
-query)
query_fftw
;;
esac
#------------------------------------------------------------------------------
......@@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_hypre
......@@ -21,7 +20,7 @@
# HYPRE_ARCH_PATH
#
# Functions provided
# have_hypre, no_hypre, echo_hypre
# have_hypre, no_hypre, echo_hypre, query_hypre
#
# Variables set on success
# HAVE_HYPRE
......@@ -52,21 +51,39 @@ echo_hypre()
}
# Query settings
query_hypre()
{
local config="config.sh/hypre"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query hypre "$HYPRE_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "hypre=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR
have_hypre()
{
local config="config.sh/hypre"
local prefix header library incName libName settings warn
warn="==> skip hypre"
# Setup - prefer current environment value? (TDB)
if [ ! -d "$HYPRE_ARCH_PATH" ]
then
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/hypre)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/hypre settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
......@@ -122,11 +139,15 @@ have_hypre()
# Force reset of old variables
no_hypre
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_hypre
echo_hypre
fi
;;
-query)
query_hypre
;;
esac
#------------------------------------------------------------------------------
......@@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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.
#
# Script
# have_kahip
......@@ -21,7 +20,7 @@
# config.sh/kahip
#
# Functions provided
# have_kahip, no_kahip, echo_kahip
# have_kahip, no_kahip, echo_kahip, query_kahip
#
# Variables set on success
# HAVE_KAHIP
......@@ -53,19 +52,36 @@ echo_kahip()
}
# Query settings
query_kahip()
{
local config="config.sh/kahip"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query kahip "$KAHIP_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "kahip=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR
have_kahip()
{
local config="config.sh/kahip"
local prefix header library incName libName settings warn
warn="==> skip kahip"
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/kahip settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 1
fi
......@@ -123,11 +139,15 @@ have_kahip()
# Force reset of old variables
no_kahip
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_kahip
echo_kahip
fi
;;
-query)
query_kahip
;;
esac
#------------------------------------------------------------------------------