summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-05-26 02:08:52 +0000
committermidipix <writeonce@midipix.org>2021-05-26 14:37:23 +0000
commitf7d9b6402edbb2cd2c82dfa215301159861f5c76 (patch)
tree06dba393d0f9eeb51f9665c504551659d827f0e2
parentda1dbee7070df27f2c40820c70cb9c008126f6c1 (diff)
downloadbcparser-f7d9b6402edbb2cd2c82dfa215301159861f5c76.tar.bz2
bcparser-f7d9b6402edbb2cd2c82dfa215301159861f5c76.tar.xz
build system: cfgtest framework: added cfgtest_compiler_switch().
-rw-r--r--sofort/cfgtest/cfgtest.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh
index 87fb4f3..736abdd 100644
--- a/sofort/cfgtest/cfgtest.sh
+++ b/sofort/cfgtest/cfgtest.sh
@@ -109,6 +109,11 @@ cfgtest_epilog()
printf '\n\ncfgtest: could not determine size of type `%s.\n' "${3}'" >&3
printf '%s\n' '------------------------' >&3
return 1
+ elif [ "${1}" = 'switch' ] && [ "${2}" = '(error)' ]; then
+ printf '\n\ncfgtest: the switch `%s is not supported by the %s compiler.\n' \
+ "${3}'" "$mb_cfgtest_cfgtype" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
elif [ "${2}" = '(error)' ]; then
printf '\n\ncfgtest: %s `%s is not defined or cannot be used.\n' "${1}" "${3}'" >&3
printf '%s\n' '------------------------' >&3
@@ -194,27 +199,40 @@ cfgtest_common_init()
cfgtest_fmt='%s -S -xc - -o -'
fi
+
if [ "$cfgtest_type" = 'lib' ]; then
cfgtest_cmd=$(printf "$cfgtest_fmt %s %s %s" \
"$mb_cfgtest_cc" \
"$mb_cfgtest_cflags" \
"$mb_cfgtest_ldflags" \
"$cfgtest_libs")
+
+ elif [ "$cfgtest_type" = 'switch' ]; then
+ cfgtest_cmd=$(printf "$cfgtest_fmt %s %s" \
+ "$mb_cfgtest_cc" \
+ "$mb_cfgtest_cflags" \
+ "$cfgtest_switches")
else
cfgtest_cmd=$(printf "$cfgtest_fmt %s" \
"$mb_cfgtest_cc" \
"$mb_cfgtest_cflags")
fi
+
if [ -z "$mb_cfgtest_headers" ] || [ "$cfgtest_type" = 'lib' ]; then
cfgtest_inc=
cfgtest_src="$cfgtest_code_snippet"
+
+ elif [ "$cfgtest_type" = 'switch' ]; then
+ cfgtest_inc=
+ cfgtest_src=
else
cfgtest_inc=$(printf '#include <%s>\n' $mb_cfgtest_headers)
cfgtest_src=$(printf '%s\n_\n' "$cfgtest_inc" \
| m4 -D_="$cfgtest_code_snippet")
fi
+
# config.log
printf "$cfgtest_fmt" "$mb_cfgtest_cc" >&3
@@ -226,6 +244,11 @@ cfgtest_common_init()
for cfgtest_lib in $cfgtest_libs; do
printf ' \\\n\t%s' "$cfgtest_lib" >&3
done
+
+ elif [ "$cfgtest_type" = 'switch' ]; then
+ for cfgtest_switch in $cfgtest_switches; do
+ printf ' \\\n\t%s' "$cfgtest_switch" >&3
+ done
fi
printf ' \\\n' >&3
@@ -513,6 +536,45 @@ cfgtest_library_presence()
}
+cfgtest_compiler_switch()
+{
+ # init
+ cfgtest_switches=
+ cfgtest_spc=
+
+ for cfgtest_switch in ${@}; do
+ cfgtest_switches="$cfgtest_switches$cfgtest_spc$cfgtest_switch"
+ cfgtest_spc=' '
+ done
+
+ if [ "${1}" = "$cfgtest_switches" ]; then
+ cfgtest_prolog 'compiler switch' "$cfgtest_switches"
+ else
+ cfgtest_prolog 'compiler switch combination' "$cfgtest_switches"
+ fi
+
+ cfgtest_code_snippet=
+
+ cfgtest_common_init 'switch'
+
+ # execute
+ printf '%s' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'switch' '(error)' "$@" \
+ || return 1
+
+ # result
+ printf 'cfgtest: the switch `%s was accepted by the compier.\n' \
+ "$cfgtest_switches'" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'switch' '(accepted)'
+
+ return 0
+}
+
+
cfgtest_unit_header_presence()
{
cfgtest_internal_unit_test='unit_test'