Skip to content
Snippets Groups Projects
Commit ad8d932a authored by Jö Fahlke's avatar Jö Fahlke
Browse files

[dune.module] Remove half-support for ',' as a dependency list separator.

Also: Improve error message in case dependency list parsing ends up with some
weird module name (e.g. empty or ',') by quoting it in the diagnostic output.
parent d36cdb63
No related branches found
No related tags found
No related merge requests found
...@@ -309,6 +309,29 @@ sort_modules() { ...@@ -309,6 +309,29 @@ sort_modules() {
done done
} }
# strip any leading spaces, tabs, or newlines
_ltrim()
{
local val="$1"
local tab=" "
local nl="
"
while :; do
case $val in
" "*|"$tab"*|"$nl"*)
val=${val#?}
;;
*)
break
;;
esac
done
# if this is used inside `...` or $(...), any trailing newlines will be
# stripped, no matter what we do. Setting a variable to the result would
# work around this, but is not a common idiom.
printf "%s" "$val"
}
_check_deps() _check_deps()
{ {
local module="$1" local module="$1"
...@@ -326,13 +349,12 @@ _check_deps() ...@@ -326,13 +349,12 @@ _check_deps()
fi fi
eval deps=\$${mode}_$module eval deps=\$${mode}_$module
#initially remove leading space #initially remove leading space
deps=`echo ${deps//^[, ]}` deps=$(_ltrim "$deps")
while test -n "$deps"; do while test -n "$deps"; do
#the end of the name is marked either by space, opening parenthesis, #the end of the name is marked either by space or opening parenthesis
#or comma name="${deps%%[ (]*}"
name="${deps%%[ (,]*}"
#remove the name and adjacent whitespace #remove the name and adjacent whitespace
deps=`echo "$deps" | sed 's/^[^ (,]* *//'` deps=$(_ltrim "${deps#"$name"}")
#check whether there is a dependency version #check whether there is a dependency version
case "$deps" in case "$deps" in
'('*) deps="${deps#(}" '('*) deps="${deps#(}"
...@@ -342,23 +364,24 @@ _check_deps() ...@@ -342,23 +364,24 @@ _check_deps()
*) depver= *) depver=
;; ;;
esac esac
#remove any leading whitespace or commas for the next iteration #remove any leading whitespace for the next iteration
deps=`echo ${deps//^[, ]}` deps=$(_ltrim "$deps")
dep=$(fix_variable_name $name) dep=$(fix_variable_name $name)
if ! check_modname $dep; then if ! check_modname $dep; then
echo "ERROR: invalid module name $name ($dependency of $module)" >&2 echo "ERROR: invalid module name '$name' ($dependency of '$module')" >&2
exit 1 exit 1
fi fi
if eval test x\$HAVE_$dep != "x"; then if eval test x\$HAVE_$dep != "x"; then
eval ver=\$VERS_$dep eval ver=\$VERS_$dep
if test "$SKIPVERSIONCHECK" != "yes" && ! check_version "$ver" "$depver"; then if test "$SKIPVERSIONCHECK" != "yes" && ! check_version "$ver" "$depver"; then
echo "$report: version mismatch." >&2 echo "$report: version mismatch." >&2
echo " $modname $requires $name $depver," >&2 echo " $modname $requires '$name $depver'," >&2
echo " but only $name = $ver is available." >&2 echo " but only '$name' = '$ver' is available." >&2
if test "x$mode" = "xDEPS"; then if test "x$mode" = "xDEPS"; then
exit 1 exit 1
else else
echo "Skipping $name!" >&2 echo "Skipping '$name'!" >&2
continue continue
fi fi
fi fi
...@@ -367,26 +390,26 @@ _check_deps() ...@@ -367,26 +390,26 @@ _check_deps()
# perhaps this module is installed, # perhaps this module is installed,
# then it should be handled via pkg-config # then it should be handled via pkg-config
if ! pkg-config $name; then if ! pkg-config $name; then
echo "$report: could not find module $name," >&2 echo "$report: could not find module '$name'," >&2
echo " module is also unknown to pkg-config." >&2 echo " module is also unknown to pkg-config." >&2
echo " Maybe you need to adjust PKG_CONFIG_PATH!" >&2 echo " Maybe you need to adjust PKG_CONFIG_PATH!" >&2
echo " $name is $required by $modname" >&2 echo " '$name' is $required by $modname" >&2
if test "x$mode" = "xDEPS"; then if test "x$mode" = "xDEPS"; then
exit 1 exit 1
else else
echo "Skipping $name!" >&2 echo "Skipping '$name'!" >&2
continue continue
fi fi
else else
eval ver=$(pkg-config $name --modversion) eval ver=$(pkg-config $name --modversion)
if test "$SKIPVERSIONCHECK" != "yes" && ! check_version "$ver" "$depver"; then if test "$SKIPVERSIONCHECK" != "yes" && ! check_version "$ver" "$depver"; then
echo "$report: version mismatch." >&2 echo "$report: version mismatch." >&2
echo " $modname $requires $name $depver," >&2 echo " $modname $requires '$name $depver'," >&2
echo " but only $name = $ver is installed." >&2 echo " but only '$name' = '$ver' is installed." >&2
if test "x$mode" = "xDEPS"; then if test "x$mode" = "xDEPS"; then
exit 1 exit 1
else else
echo "Skipping $name!" >&2 echo "Skipping '$name'!" >&2
continue continue
fi fi
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment