ENH: split up internals of wmake/scripts/have_XXX functions

- adds some more flexibility
This commit is contained in:
Mark Olesen
2020-05-15 13:58:16 +02:00
committed by Andrew Heather
parent c156125669
commit f8ef85b72f
14 changed files with 679 additions and 480 deletions

View File

@ -20,7 +20,7 @@
# config.sh/ccmio
#
# Functions provided
# have_ccmio, no_ccmio, echo_ccmio, query_ccmio
# have_ccmio, no_ccmio, echo_ccmio, query_ccmio, search_ccmio
#
# Variables set on success
# HAVE_CCMIO
@ -33,7 +33,7 @@
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_ccmio()
{
unset HAVE_CCMIO CCMIO_INC_DIR CCMIO_LIB_DIR
@ -50,44 +50,19 @@ 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
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR
have_ccmio()
search_ccmio()
{
local warn="==> skip ccmio"
local config="config.sh/ccmio"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
# Link with static libccmio only (fewer issues)
local prefix="$CCMIO_ARCH_PATH"
local incName="libccmio/ccmio.h"
local libName="libccmio.a"
# Link with static libccmio only (fewer issues)
local prefix="${1:-system}"
local header library
# ----------------------------------
@ -153,7 +128,45 @@ have_ccmio()
}
# Reset variables
# Output as per search_* function
have_ccmio()
{
local warn="==> skip ccmio"
local config="config.sh/ccmio"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_ccmio "$CCMIO_ARCH_PATH"
}
# Query settings
query_ccmio()
{
local config="config.sh/ccmio"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query ccmio "$CCMIO_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "ccmio=unknown"
fi
}
#------------------------------------------------------------------------------
# Reset
no_ccmio
# Test/query