[gjs: 10/16] CI: Add cppcheck config file




commit 1074a575e55f5b85b1e2e35e7fe110248ad282ce
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Nov 20 16:06:23 2020 -0800

    CI: Add cppcheck config file
    
    This is needed because we are about to upgrade to a newer version of
    cppcheck than the one on the DockerHub image. It ships a "library file"
    for the GNOME platform, enabling some extra checks when using GLib and GTK
    APIs. It also requires configuration of some of the macros that we use.

 .gitlab-ci.yml        |  2 +-
 tools/cppcheck.cfg    | 14 ++++++++++++++
 tools/run_cppcheck.sh |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 48211ace..c68b1033 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -136,7 +136,7 @@ cppcheck:
   image: uilianries/docker-cppcheck
   stage: source_check
   script:
-    - cppcheck . -v -f -q -UHAVE_PRINTF_ALTERNATIVE_INT --error-exitcode=1 --inline-suppr --library=gtk 
--enable=warning,performance,portability
+    - cppcheck . -v -f -q -UHAVE_PRINTF_ALTERNATIVE_INT --error-exitcode=1 --inline-suppr 
--library=gtk,tools/cppcheck.cfg --enable=warning,performance,portability
   except:
     refs:
       - schedules
diff --git a/tools/cppcheck.cfg b/tools/cppcheck.cfg
new file mode 100644
index 00000000..184edee1
--- /dev/null
+++ b/tools/cppcheck.cfg
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<def>
+  <define name="GJS_DEFINE_PRIV_FROM_JS" value=""/>
+  <define name="GJS_DEFINE_PROTO_ABSTRACT_WITH_PARENT" value=""/>
+  <!-- These are available in cppcheck 2.0 -->
+  <define name="g_assert_true(expr)" value="g_assert(expr)"/>
+  <define name="g_assert_cmpstr(s1, cmp, s2)" value="g_assert_true(g_strcmp0 ((s1), (s2)) cmp 0)"/>
+  <define name="g_assert_cmpint(n1, cmp, n2)" value="g_assert_true((n1) cmp (n2))"/>
+  <define name="g_assert_cmpuint(n1, cmp, n2)" value="g_assert_true((n1) cmp (n2))"/>
+  <define name="g_assert_cmphex(n1, cmp, n2)" value="g_assert_true((n1) cmp (n2))"/>
+  <define name="g_assert_cmpfloat(n1, cmp, n2)" value="g_assert_true((n1) cmp (n2))"/>
+  <!-- These should be added to cppcheck upstream -->
+  <define name="G_DEFINE_QUARK" value=""/>
+</def>
diff --git a/tools/run_cppcheck.sh b/tools/run_cppcheck.sh
index 1f542141..8d4860db 100755
--- a/tools/run_cppcheck.sh
+++ b/tools/run_cppcheck.sh
@@ -5,4 +5,4 @@ ninja -C _build
 cppcheck --project=_build/compile_commands.json --inline-suppr \
     --enable=warning,performance,portability,missingInclude \
     -UHAVE_PRINTF_ALTERNATIVE_INT \
-    --library=gtk --force --quiet $@
+    --library=gtk,tools/cppcheck.cfg --force --quiet $@


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]