From 8207fb7b145027da8f9cf23b72b8bbd3e6c98789 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 19 Sep 2019 08:48:04 +0200 Subject: [PATCH] cairo.cfg: Add library configuration/tests/... for cairo library (#2176) Reference: https://www.cairographics.org/ --- .travis.yml | 2 +- cfg/cairo.cfg | 88 ++++++++++++++++++++++++++++++++++++++++++++ test/cfg/cairo.c | 26 +++++++++++++ test/cfg/runtests.sh | 27 ++++++++++++++ tools/donate-cpu.py | 1 + 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 cfg/cairo.cfg create mode 100644 test/cfg/cairo.c diff --git a/.travis.yml b/.travis.yml index e589ce6f5..5f42231d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: before_install: # install needed deps - travis_retry sudo apt-get update -qq - - travis_retry sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet python3-dev liblua5.3-dev libcurl3 + - travis_retry sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet python3-dev liblua5.3-dev libcurl3 libcairo2-dev - travis_retry python2 -m pip install --user pytest==4.6.4 - travis_retry python2 -m pip install --user pylint - travis_retry python2 -m pip install --user unittest2 diff --git a/cfg/cairo.cfg b/cfg/cairo.cfg new file mode 100644 index 000000000..85c2a8e09 --- /dev/null +++ b/cfg/cairo.cfg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + + + + + + false + + + + + + + + + false + + + + + + + + + + false + + + + + + + diff --git a/test/cfg/cairo.c b/test/cfg/cairo.c new file mode 100644 index 000000000..27702c0dc --- /dev/null +++ b/test/cfg/cairo.c @@ -0,0 +1,26 @@ + +// Test library configuration for cairo.cfg +// +// Usage: +// $ cppcheck --check-library --library=cairo --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/cairo.c +// => +// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 +// + +#include + +void validCode(cairo_surface_t *target) +{ + cairo_t * cairo1 = cairo_create(target); + cairo_move_to(cairo1, 1.0, 2.0); + cairo_line_to(cairo1, 5.0, 6.0); + cairo_destroy(cairo1); +} + +void ignoredReturnValue(cairo_surface_t *target) +{ + // cppcheck-suppress ignoredReturnValue + cairo_create(target); + // cppcheck-suppress ignoredReturnValue + cairo_status_to_string(CAIRO_STATUS_READ_ERROR); +} diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index a870090d1..b487c734d 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -253,6 +253,33 @@ else fi ${CPPCHECK} ${CPPCHECK_OPT} --library=libcurl ${DIR}libcurl.c +# cairo.c +set +e +pkg-config --version +PKGCONFIG_RETURNCODE=$? +set -e +if [ $PKGCONFIG_RETURNCODE -ne 0 ]; then + echo "pkg-config needed to retrieve cairo configuration is not available, skipping syntax check." +else + set +e + CAIROCONFIG=$(pkg-config --cflags cairo) + CAIROCONFIG_RETURNCODE=$? + set -e + if [ $CAIROCONFIG_RETURNCODE -eq 0 ]; then + set +e + echo -e "#include " | ${CC} ${CC_OPT} ${CAIROCONFIG} -x c - + CAIROCONFIG_RETURNCODE=$? + set -e + if [ $CAIROCONFIG_RETURNCODE -ne 0 ]; then + echo "cairo not completely present or not working, skipping syntax check with ${CC}." + else + echo "cairo found and working, checking syntax with ${CC} now." + ${CC} ${CC_OPT} ${CAIROCONFIG} ${DIR}cairo.c + fi + fi +fi +${CPPCHECK} ${CPPCHECK_OPT} --library=cairo ${DIR}cairo.c + # Check the syntax of the defines in the configuration files set +e xmlstarlet --version diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index feb33ad7d..e47cdcdea 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -432,6 +432,7 @@ def upload_info(package, info_output, server_address): def get_libraries(): libraries = ['posix', 'gnu'] library_includes = {'boost': [''], <= enable after release of version 1.90 'cppunit': [''], 'gtk': ['', '', ''],