Skip to content

Commit 719f2e3

Browse files
authored
test/cfg/runtests.sh: some refactoring / handle unversioned LUA package config (danmar#7620)
1 parent 5f4423f commit 719f2e3

File tree

1 file changed

+69
-54
lines changed

1 file changed

+69
-54
lines changed

test/cfg/runtests.sh

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,28 @@ function get_pkg_config_cflags {
6363
echo "$PKGCONFIG"
6464
}
6565

66+
function cc_syntax {
67+
${CC} "${CC_OPT[@]}" "$@"
68+
}
69+
70+
function cxx_syntax {
71+
${CXX} "${CXX_OPT[@]}" "$@"
72+
}
73+
74+
function cppcheck_run {
75+
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "$@"
76+
}
77+
6678
# posix.c
6779
function posix_fn {
6880
echo "POSIX assumed to be present, checking syntax with ${CC} now."
69-
${CC} "${CC_OPT[@]}" ${DIR}posix.c
81+
cc_syntax ${DIR}posix.c
7082
}
7183

7284
# gnu.c
7385
function gnu_fn {
7486
echo "GNU assumed to be present, checking syntax with ${CC} now."
75-
${CC} "${CC_OPT[@]}" ${DIR}gnu.c
87+
cc_syntax ${DIR}gnu.c
7688
}
7789

7890
# qt.cpp
@@ -92,7 +104,7 @@ function qt_fn {
92104
exit_if_strict
93105
else
94106
echo "Qt found and working, checking syntax with ${CXX} now."
95-
${CXX} "${CXX_OPT[@]}" ${QTCONFIG} ${DIR}qt.cpp
107+
cxx_syntax ${QTCONFIG} ${DIR}qt.cpp
96108
fi
97109
else
98110
echo "Qt not present, skipping syntax check with ${CXX}."
@@ -110,19 +122,19 @@ function bsd_fn {
110122
# std.c
111123
function std_c_fn {
112124
echo "C standard library assumed to be present, checking syntax with ${CC} now."
113-
${CC} "${CC_OPT[@]}" "${DIR}"std.c
125+
cc_syntax "${DIR}"std.c
114126
}
115127

116128
# std.cpp
117129
function std_cpp_fn {
118130
echo "C++ standard library assumed to be present, checking syntax with ${CXX} now."
119-
${CXX} "${CXX_OPT[@]}" "${DIR}"std.cpp
131+
cxx_syntax "${DIR}"std.cpp
120132
}
121133

122134
# windows.cpp
123135
function windows_fn {
124136
# TODO: Syntax check via g++ does not work because it can not find a valid windows.h
125-
#${CXX} "${CXX_OPT[@]}" ${DIR}windows.cpp
137+
#cxx_syntax ${DIR}windows.cpp
126138
true
127139
}
128140

@@ -153,7 +165,7 @@ function wxwidgets_fn {
153165
exit_if_strict
154166
else
155167
echo "wxWidgets found, checking syntax with ${CXX} now."
156-
${CXX} "${CXX_OPT[@]}" ${WXCONFIG} -Wno-deprecated-declarations "${DIR}"wxwidgets.cpp
168+
cxx_syntax ${WXCONFIG} -Wno-deprecated-declarations "${DIR}"wxwidgets.cpp
157169
fi
158170
fi
159171
}
@@ -172,14 +184,14 @@ function gtk_fn {
172184
GTKCHECK_RETURNCODE=$?
173185
set -e
174186
if [ $GTKCHECK_RETURNCODE -ne 0 ]; then
175-
echo "GTK+ not completely present or not working, skipping syntax check with ${CXX}."
187+
echo "GTK+ not completely present or not working, skipping syntax check with ${CC}."
176188
exit_if_strict
177189
else
178-
echo "GTK+ found and working, checking syntax with ${CXX} now."
179-
${CC} "${CC_OPT[@]}" ${GTKCONFIG} "${DIR}"gtk.c
190+
echo "GTK+ found and working, checking syntax with ${CC} now."
191+
cc_syntax ${GTKCONFIG} "${DIR}"gtk.c
180192
fi
181193
else
182-
echo "GTK+ not present, skipping syntax check with ${CXX}."
194+
echo "GTK+ not present, skipping syntax check with ${CC}."
183195
exit_if_strict
184196
fi
185197
fi
@@ -189,15 +201,15 @@ function gtk_fn {
189201
function boost_fn {
190202
# TODO: get rid of the error enabling/disabling?
191203
set +e
192-
echo -e "#include <boost/config.hpp>" | ${CXX} "${CXX_OPT[@]}" -x c++ -
204+
echo -e "#include <boost/config.hpp>" | ${CXX} "${CXX_OPT[@]}" -x c++ -
193205
BOOSTCHECK_RETURNCODE=$?
194206
set -e
195207
if [ ${BOOSTCHECK_RETURNCODE} -ne 0 ]; then
196208
echo "Boost not completely present or not working, skipping syntax check with ${CXX}."
197209
exit_if_strict
198210
else
199211
echo "Boost found and working, checking syntax with ${CXX} now."
200-
${CXX} "${CXX_OPT[@]}" "${DIR}"boost.cpp
212+
cxx_syntax "${DIR}"boost.cpp
201213
fi
202214
}
203215

@@ -216,7 +228,7 @@ function sqlite3_fn {
216228
exit_if_strict
217229
else
218230
echo "SQLite3 found and working, checking syntax with ${CC} now."
219-
${CC} "${CC_OPT[@]}" ${SQLITE3CONFIG} "${DIR}"sqlite3.c
231+
cc_syntax ${SQLITE3CONFIG} "${DIR}"sqlite3.c
220232
fi
221233
else
222234
echo "SQLite3 not present, skipping syntax check with ${CC}."
@@ -230,7 +242,7 @@ function openmp_fn {
230242
# MacOS compiler has no OpenMP by default
231243
if ! command -v sw_vers; then
232244
echo "OpenMP assumed to be present, checking syntax with ${CC} now."
233-
${CC} "${CC_OPT[@]}" -fopenmp ${DIR}openmp.c
245+
cc_syntax -fopenmp ${DIR}openmp.c
234246
fi
235247
}
236248

@@ -249,7 +261,7 @@ function python_fn {
249261
exit_if_strict
250262
else
251263
echo "Python 3 found and working, checking syntax with ${CC} now."
252-
${CC} "${CC_OPT[@]}" ${PYTHON3CONFIG} "${DIR}"python.c
264+
cc_syntax ${PYTHON3CONFIG} "${DIR}"python.c
253265
fi
254266
else
255267
echo "Python 3 not present, skipping syntax check with ${CC}."
@@ -261,7 +273,10 @@ function python_fn {
261273
# lua.c
262274
function lua_fn {
263275
if [ $HAS_PKG_CONFIG -eq 1 ]; then
264-
LUACONFIG=$(get_pkg_config_cflags lua-5.3)
276+
LUACONFIG=$(get_pkg_config_cflags lua)
277+
if [ -z "$LUACONFIG" ]; then
278+
LUACONFIG=$(get_pkg_config_cflags lua-5.3)
279+
fi
265280
if [ -n "$LUACONFIG" ]; then
266281
# TODO: get rid of the error enabling/disabling?
267282
set +e
@@ -273,7 +288,7 @@ function lua_fn {
273288
exit_if_strict
274289
else
275290
echo "Lua found and working, checking syntax with ${CC} now."
276-
${CC} "${CC_OPT[@]}" ${LUACONFIG} "${DIR}"lua.c
291+
cc_syntax ${LUACONFIG} "${DIR}"lua.c
277292
fi
278293
else
279294
echo "Lua not present, skipping syntax check with ${CC}."
@@ -297,7 +312,7 @@ function libcurl_fn {
297312
exit_if_strict
298313
else
299314
echo "libcurl found and working, checking syntax with ${CC} now."
300-
${CC} "${CC_OPT[@]}" ${LIBCURLCONFIG} "${DIR}"libcurl.c
315+
cc_syntax ${LIBCURLCONFIG} "${DIR}"libcurl.c
301316
fi
302317
else
303318
echo "libcurl not present, skipping syntax check with ${CC}."
@@ -321,7 +336,7 @@ function cairo_fn {
321336
exit_if_strict
322337
else
323338
echo "cairo found and working, checking syntax with ${CC} now."
324-
${CC} "${CC_OPT[@]}" ${CAIROCONFIG} "${DIR}"cairo.c
339+
cc_syntax ${CAIROCONFIG} "${DIR}"cairo.c
325340
fi
326341
else
327342
echo "cairo not present, skipping syntax check with ${CC}."
@@ -354,15 +369,15 @@ function kde_fn {
354369
else
355370
# TODO: get rid of the error enabling/disabling?
356371
set +e
357-
echo -e "#include <KDE/KGlobal>\n" | ${CXX} "${CXX_OPT[@]}" -I${KDECONFIG} ${KDEQTCONFIG} -x c++ -
372+
echo -e "#include <KDE/KGlobal>\n" | ${CXX} "${CXX_OPT[@]}" -isystem${KDECONFIG} ${KDEQTCONFIG} -x c++ -
358373
KDECHECK_RETURNCODE=$?
359374
set -e
360375
if [ $KDECHECK_RETURNCODE -ne 0 ]; then
361376
echo "KDE headers not completely present or not working, skipping syntax check with ${CXX}."
362377
exit_if_strict
363378
else
364379
echo "KDE found, checking syntax with ${CXX} now."
365-
${CXX} "${CXX_OPT[@]}" -I${KDECONFIG} ${KDEQTCONFIG} "${DIR}"kde.cpp
380+
cxx_syntax -isystem${KDECONFIG} ${KDEQTCONFIG} "${DIR}"kde.cpp
366381
fi
367382
fi
368383
fi
@@ -383,7 +398,7 @@ function libsigcpp_fn {
383398
exit_if_strict
384399
else
385400
echo "libsigc++ found and working, checking syntax with ${CXX} now."
386-
${CXX} "${CXX_OPT[@]}" ${LIBSIGCPPCONFIG} "${DIR}"libsigc++.cpp
401+
cxx_syntax ${LIBSIGCPPCONFIG} "${DIR}"libsigc++.cpp
387402
fi
388403
else
389404
echo "libsigc++ not present, skipping syntax check with ${CXX}."
@@ -407,7 +422,7 @@ function openssl_fn {
407422
exit_if_strict
408423
else
409424
echo "OpenSSL found and working, checking syntax with ${CC} now."
410-
${CC} "${CC_OPT[@]}" ${OPENSSLCONFIG} "${DIR}"openssl.c
425+
cc_syntax ${OPENSSLCONFIG} "${DIR}"openssl.c
411426
fi
412427
else
413428
echo "OpenSSL not present, skipping syntax check with ${CC}."
@@ -431,7 +446,7 @@ function opencv2_fn {
431446
exit_if_strict
432447
else
433448
echo "OpenCV found and working, checking syntax with ${CXX} now."
434-
${CXX} "${CXX_OPT[@]}" ${OPENCVCONFIG} "${DIR}"opencv2.cpp
449+
cxx_syntax ${OPENCVCONFIG} "${DIR}"opencv2.cpp
435450
fi
436451
else
437452
echo "OpenCV not present, skipping syntax check with ${CXX}."
@@ -448,15 +463,15 @@ function cppunit_fn {
448463
exit_if_strict
449464
else
450465
echo "cppunit found, checking syntax with ${CXX} now."
451-
${CXX} "${CXX_OPT[@]}" -Wno-deprecated-declarations "${DIR}"cppunit.cpp
466+
cxx_syntax -Wno-deprecated-declarations "${DIR}"cppunit.cpp
452467
fi
453468
fi
454469
}
455470

456471
# emscripten.cpp
457472
function emscripten_fn {
458473
# TODO: Syntax check via g++ does not work because it can not find a valid emscripten.h
459-
# ${CXX} "${CXX_OPT[@]}" ${DIR}emscripten.cpp
474+
# cxx_syntax ${DIR}emscripten.cpp
460475
true
461476
}
462477

@@ -472,109 +487,109 @@ function check_file {
472487
case $f in
473488
boost.cpp)
474489
boost_fn
475-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
490+
cppcheck_run --library="$lib" "${DIR}""$f"
476491
;;
477492
bsd.c)
478493
bsd_fn
479-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
494+
cppcheck_run --library="$lib" "${DIR}""$f"
480495
;;
481496
cairo.c)
482497
cairo_fn
483-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
498+
cppcheck_run --library="$lib" "${DIR}""$f"
484499
;;
485500
cppunit.cpp)
486501
cppunit_fn
487-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
502+
cppcheck_run --library="$lib" "${DIR}""$f"
488503
;;
489504
emscripten.cpp)
490505
emscripten_fn
491-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
506+
cppcheck_run --library="$lib" "${DIR}""$f"
492507
;;
493508
gnu.c)
494509
gnu_fn
495510
# TODO: posix needs to specified first or it has a different mmap() config
496511
# TODO: get rid of posix dependency
497-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library=posix,"$lib" "${DIR}"gnu.c
512+
cppcheck_run --library=posix,"$lib" "${DIR}"gnu.c
498513
;;
499514
googletest.cpp)
500515
googletest_fn
501-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
516+
cppcheck_run --library="$lib" "${DIR}""$f"
502517
;;
503518
gtk.c)
504519
gtk_fn
505-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
520+
cppcheck_run --library="$lib" "${DIR}""$f"
506521
;;
507522
kde.cpp)
508523
# TODO: "kde-4config" is no longer commonly available in recent distros
509524
#kde_fn
510-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" --library=qt "${DIR}""$f"
525+
cppcheck_run --library="$lib" --library=qt "${DIR}""$f"
511526
;;
512527
libcurl.c)
513528
libcurl_fn
514-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
529+
cppcheck_run --library="$lib" "${DIR}""$f"
515530
;;
516531
libsigc++.cpp)
517532
libsigcpp_fn
518-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
533+
cppcheck_run --library="$lib" "${DIR}""$f"
519534
;;
520535
lua.c)
521536
lua_fn
522-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
537+
cppcheck_run --library="$lib" "${DIR}""$f"
523538
;;
524539
mfc.cpp)
525540
mfc_fn
526-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win64 --library="$lib" "${DIR}""$f"
541+
cppcheck_run --platform=win64 --library="$lib" "${DIR}""$f"
527542
;;
528543
opencv2.cpp)
529544
# TODO: "opencv.pc" is not commonly available in distros
530545
#opencv2_fn
531-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
546+
cppcheck_run --library="$lib" "${DIR}""$f"
532547
;;
533548
openmp.c)
534549
openmp_fn
535-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
550+
cppcheck_run --library="$lib" "${DIR}""$f"
536551
;;
537552
openssl.c)
538553
openssl_fn
539-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
554+
cppcheck_run --library="$lib" "${DIR}""$f"
540555
;;
541556
posix.c)
542557
posix_fn
543-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
558+
cppcheck_run --library="$lib" "${DIR}""$f"
544559
;;
545560
python.c)
546561
python_fn
547-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
562+
cppcheck_run --library="$lib" "${DIR}""$f"
548563
;;
549564
qt.cpp)
550565
qt_fn
551-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
566+
cppcheck_run --library="$lib" "${DIR}""$f"
552567
;;
553568
selinux.c)
554569
selinux_fn
555-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
570+
cppcheck_run --library="$lib" "${DIR}""$f"
556571
;;
557572
sqlite3.c)
558573
sqlite3_fn
559-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
574+
cppcheck_run --library="$lib" "${DIR}""$f"
560575
;;
561576
std.c)
562577
std_c_fn
563-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "${DIR}""$f"
578+
cppcheck_run "${DIR}""$f"
564579
;;
565580
std.cpp)
566581
std_cpp_fn
567-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "${DIR}""$f"
582+
cppcheck_run "${DIR}""$f"
568583
;;
569584
windows.cpp)
570585
windows_fn
571-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win32A --library="$lib" "${DIR}""$f"
572-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win32W --library="$lib" "${DIR}""$f"
573-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win64 --library="$lib" "${DIR}""$f"
586+
cppcheck_run --platform=win32A --library="$lib" "${DIR}""$f"
587+
cppcheck_run --platform=win32W --library="$lib" "${DIR}""$f"
588+
cppcheck_run --platform=win64 --library="$lib" "${DIR}""$f"
574589
;;
575590
wxwidgets.cpp)
576591
wxwidgets_fn
577-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
592+
cppcheck_run --library="$lib" "${DIR}""$f"
578593
;;
579594
*)
580595
echo "Unhandled file $f"

0 commit comments

Comments
 (0)