updated on Mon Jan 16 00:01:41 UTC 2012
[aur-mirror.git] / bitten-svn / bitten-cppcheck.patch
blob2f044892c84db71dfb2488447d349f8c64ba5180
1 Add support for cppcheck lint checking.
3 diff -r 9a4f617d6a04 bitten/build/ctools.py
4 --- a/bitten/build/ctools.py Mon Nov 30 16:38:38 2009 +0100
5 +++ b/bitten/build/ctools.py Wed Dec 02 13:18:05 2009 +0100
6 @@ -208,6 +208,52 @@
7 print e
8 log.warning('Error parsing CppUnit results file (%s)', e)
10 +def cppcheck (ctxt, file_=None):
11 + """Collect Cppcheck XML data.
13 + :param: ctxt: the build context
14 + :type ctxt: `Context`
15 + :param file\_: path of the file containing the Cppcheck results.
16 + """
17 + assert file_, 'Missing required attribute "file"'
19 + try:
20 + fileobj = file(ctxt.resolve(file_), 'r')
21 + try:
22 + results = xmlio.Fragment()
23 + log_elem = xmlio.Fragment()
24 + def info (msg):
25 + log.info (msg)
26 + log_elem.append (xmlio.Element ('message', level='info')[msg])
27 + info ("Analyzing cppcheck results...")
28 + categories = { "error": "error", "possible error": "warning",
29 + "style": "convention", "possible style": "convention" }
30 + for node in xmlio.parse(fileobj):
31 + if node.name != 'error':
32 + continue
33 + results.append (
34 + xmlio.Element (
35 + 'problem',
36 + category = categories.get (node.attr["severity"], "error"),
37 + type = node.attr["id"],
38 + line = node.attr["line"],
39 + file = node.attr["file"])
40 + [node.attr["msg"]])
41 + info ("%s (%s): (%s) %s"
42 + % (node.attr["file"],
43 + node.attr["line"],
44 + node.attr["severity"],
45 + node.attr["msg"]))
46 + ctxt.report ('lint', results)
47 + ctxt.log (log_elem)
48 + finally:
49 + fileobj.close()
50 + except IOError, e:
51 + log.warning('Error opening Cppcheck results file (%s)', e)
52 + except xmlio.ParseError, e:
53 + log.warning('Error parsing Cppcheck results file (%s)', e)
56 def cunit (ctxt, file_=None, srcdir=None):
57 """Collect CUnit XML data.
59 diff -r 9a4f617d6a04 setup.py
60 --- a/setup.py Mon Nov 30 16:38:38 2009 +0100
61 +++ b/setup.py Wed Dec 02 13:18:05 2009 +0100
62 @@ -35,6 +35,7 @@
63 'c#autoreconf = bitten.build.ctools:autoreconf',
64 'c#cppunit = bitten.build.ctools:cppunit',
65 'c#cunit = bitten.build.ctools:cunit',
66 + 'c#cppcheck = bitten.build.ctools:cppcheck',
67 'c#gcov = bitten.build.ctools:gcov',
68 'c#make = bitten.build.ctools:make',
69 'mono#nunit = bitten.build.monotools:nunit',