cairo.cfg: Add library configuration/tests/... for cairo library (#2176)

Reference: https://www.cairographics.org/
This commit is contained in:
Sebastian 2019-09-19 08:48:04 +02:00 committed by GitHub
parent 3d3f62aefd
commit 8207fb7b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 143 additions and 1 deletions

View File

@ -18,7 +18,7 @@ env:
before_install: before_install:
# install needed deps # install needed deps
- travis_retry sudo apt-get update -qq - 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 pytest==4.6.4
- travis_retry python2 -m pip install --user pylint - travis_retry python2 -m pip install --user pylint
- travis_retry python2 -m pip install --user unittest2 - travis_retry python2 -m pip install --user unittest2

88
cfg/cairo.cfg Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0"?>
<def format="2">
<!-- cairo Library Configuration https://www.cairographics.org/ -->
<!-- The cairo library is typically included by "#include <cairo.h>" -->
<!-- ########## cairo Types ########## -->
<define name="cairo_bool_t" value="int"/>
<!-- TODO: Configure cairo_status_t as an enum when this is implemented in Cppcheck -->
<podtype name="cairo_status_t"/>
<!-- ########## cairo Macros / Defines ########## -->
<define name="CAIRO_HAS_MIME_SURFACE" value="1"/>
<define name="CAIRO_MIME_TYPE_CCITT_FAX" value="&quot;image/g3fax&quot;"/>
<define name="CAIRO_MIME_TYPE_CCITT_FAX_PARAMS" value="&quot;application/x-cairo.ccitt.params&quot;"/>
<define name="CAIRO_MIME_TYPE_EPS" value="&quot;application/postscript&quot;"/>
<define name="CAIRO_MIME_TYPE_EPS_PARAMS" value="&quot;application/x-cairo.eps.params&quot;"/>
<define name="CAIRO_MIME_TYPE_JBIG2" value="&quot;application/x-cairo.jbig2&quot;"/>
<define name="CAIRO_MIME_TYPE_JBIG2_GLOBAL" value="&quot;application/x-cairo.jbig2-global&quot;"/>
<define name="CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID" value="&quot;application/x-cairo.jbig2-global-id&quot;"/>
<define name="CAIRO_MIME_TYPE_JP2" value="&quot;image/jp2&quot;"/>
<define name="CAIRO_MIME_TYPE_JPEG" value="&quot;image/jpeg&quot;"/>
<define name="CAIRO_MIME_TYPE_PNG" value="&quot;image/png&quot;"/>
<define name="CAIRO_MIME_TYPE_URI" value="&quot;text/x-uri&quot;"/>
<define name="CAIRO_MIME_TYPE_UNIQUE_ID" value="&quot;application/x-cairo.uuid&quot;"/>
<!-- ########## cairo Allocation / Deallocation ########## -->
<!-- ########## cairo Functions ########## -->
<!-- cairo_t * cairo_create (cairo_surface_t *target); -->
<function name="cairo_create">
<noreturn>false</noreturn>
<returnValue type="cairo_t *"/>
<use-retval/>
<arg nr="1">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void cairo_destroy (cairo_t *cr); -->
<function name="cairo_destroy">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void cairo_line_to (cairo_t *cr, double x, double y); -->
<!-- void cairo_move_to (cairo_t *cr, double x, double y); -->
<function name="cairo_line_to,cairo_move_to">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
</arg>
</function>
<!-- cairo_status_t cairo_status (cairo_t *cr); -->
<function name="cairo_status">
<noreturn>false</noreturn>
<returnValue type="cairo_status_t"/>
<use-retval/>
<arg nr="1">
<not-uninit/>
</arg>
</function>
<!-- const char * cairo_status_to_string (cairo_status_t status); -->
<function name="cairo_status_to_string">
<noreturn>false</noreturn>
<returnValue type="const char *"/>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void cairo_stroke (cairo_t *cr); -->
<function name="cairo_stroke">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
</function>
</def>

26
test/cfg/cairo.c Normal file
View File

@ -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 <cairo.h>
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);
}

View File

@ -253,6 +253,33 @@ else
fi fi
${CPPCHECK} ${CPPCHECK_OPT} --library=libcurl ${DIR}libcurl.c ${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 <cairo.h>" | ${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 # Check the syntax of the defines in the configuration files
set +e set +e
xmlstarlet --version xmlstarlet --version

View File

@ -432,6 +432,7 @@ def upload_info(package, info_output, server_address):
def get_libraries(): def get_libraries():
libraries = ['posix', 'gnu'] libraries = ['posix', 'gnu']
library_includes = {'boost': ['<boost/'], library_includes = {'boost': ['<boost/'],
# 'cairo': ['<cairo.h>'], <= enable after release of version 1.90
'cppunit': ['<cppunit/'], 'cppunit': ['<cppunit/'],
'googletest': ['<gtest/gtest.h>'], 'googletest': ['<gtest/gtest.h>'],
'gtk': ['<gtk/gtk.h>', '<glib.h>', '<glib/', '<gnome.h>'], 'gtk': ['<gtk/gtk.h>', '<glib.h>', '<glib/', '<gnome.h>'],