[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40254] trunk/blender: new convenience makefile targets for static source code cheching: check_splint/check_sparse/check_cppcheck

Campbell Barton ideasman42 at gmail.com
Fri Sep 16 08:58:20 CEST 2011


Revision: 40254
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40254
Author:   campbellbarton
Date:     2011-09-16 06:58:20 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
new convenience makefile targets for static source code cheching: check_splint/check_sparse/check_cppcheck

Modified Paths:
--------------
    trunk/blender/GNUmakefile

Added Paths:
-----------
    trunk/blender/build_files/cmake/cmake_static_check_cppcheck.py
    trunk/blender/build_files/cmake/cmake_static_check_sparse.py
    trunk/blender/build_files/cmake/cmake_static_check_splint.py
    trunk/blender/build_files/cmake/project_source_info.py

Modified: trunk/blender/GNUmakefile
===================================================================
--- trunk/blender/GNUmakefile	2011-09-16 06:56:50 UTC (rev 40253)
+++ trunk/blender/GNUmakefile	2011-09-16 06:58:20 UTC (rev 40254)
@@ -126,6 +126,11 @@
 	@echo "  * test_pep8       - checks all python script are pep8 which are tagged to use the stricter formatting"
 	@echo "  * test_deprecated - checks for deprecation tags in our code which may need to be removed"
 	@echo ""
+	@echo "Static Source Code Checking (not assosiated with building blender)"
+	@echo "  * check_cppcheck  - run blender source through cppcheck (C & C++)"
+	@echo "  * check_splint    - run blenders source through splint (C only)"
+	@echo "  * check_sparse    - run blenders source through sparse (C only)"
+	@echo ""
 
 # -----------------------------------------------------------------------------
 # Packages
@@ -176,6 +181,20 @@
 	cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR)
 
 
+# -----------------------------------------------------------------------------
+# Static Checking
+#
+
+check_cppcheck:
+	cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py
+
+check_splint:
+	cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py
+
+check_sparse:
+	cd $(BUILD_DIR) ; python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py
+
+
 clean:
 	$(MAKE) -C $(BUILD_DIR) clean
 

Added: trunk/blender/build_files/cmake/cmake_static_check_cppcheck.py
===================================================================
--- trunk/blender/build_files/cmake/cmake_static_check_cppcheck.py	                        (rev 0)
+++ trunk/blender/build_files/cmake/cmake_static_check_cppcheck.py	2011-09-16 06:58:20 UTC (rev 40254)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+
+# $Id:
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Campbell Barton
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# <pep8 compliant>
+
+CHECKER_IGNORE_PREFIX = [
+    "extern",
+    "intern/moto",
+    ]
+
+CHECKER_BIN = "cppcheck"
+
+CHECKER_ARGS = [
+    "-I/dsk/data/src/blender/blender/extern/glew/include",
+    #  "--check-config", # when includes are missing
+    #  "--enable=all",  # if you want sixty hundred pedantic suggestions
+    ]
+
+import project_source_info
+import subprocess
+import sys
+
+def main():
+    source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
+
+    check_commands = []
+    for c, inc_dirs, defs in source_info:
+        cmd = ([CHECKER_BIN] +
+                CHECKER_ARGS +
+               [c] +
+               [("-I%s" % i) for i in inc_dirs] +
+               [("-D%s" % d) for d in defs]
+              )
+
+        check_commands.append((c, cmd))
+
+    for i, (c, cmd) in enumerate(check_commands):
+        percent = 100.0 * (i / (len(check_commands)-1))
+        percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+        
+        # if percent < 27.9:
+        #    continue
+        
+        # let cppcheck finish the line off...
+        sys.stdout.write("%s " % percent_str)
+
+        sys.stdout.flush()
+        process = subprocess.Popen(cmd)
+        process.wait()
+
+
+if __name__ == "__main__":
+    main()

Added: trunk/blender/build_files/cmake/cmake_static_check_sparse.py
===================================================================
--- trunk/blender/build_files/cmake/cmake_static_check_sparse.py	                        (rev 0)
+++ trunk/blender/build_files/cmake/cmake_static_check_sparse.py	2011-09-16 06:58:20 UTC (rev 40254)
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+
+# $Id:
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Campbell Barton
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# <pep8 compliant>
+
+CHECKER_IGNORE_SUFFIX = [
+    "extern",
+    "intern/moto",
+    ]
+
+CHECKER_BIN = "sparse"
+CHECKER_ARGS = [
+    ]
+
+import project_source_info
+import subprocess
+import sys
+
+
+def main():
+    source_info = project_source_info.build_info(use_cxx=False, ignore_prefix_list=CHECKER_IGNORE_PREFIX)
+
+    check_commands = []
+    for c, inc_dirs, defs in source_info:
+
+        cmd = ([CHECKER_BIN] +
+                CHECKER_ARGS +
+               [c] +
+               [("-I%s" % i) for i in inc_dirs] +
+               [("-D%s" % d) for d in defs]
+              )
+
+        check_commands.append((c, cmd))
+
+    for i, (c, cmd) in enumerate(check_commands):
+        percent = 100.0 * (i / (len(check_commands) - 1))
+        percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+
+        sys.stdout.write("%s %s\n" % (percent_str, c))
+        sys.stdout.flush()
+
+        process = subprocess.Popen(cmd)
+        process.wait()
+
+if __name__ == "__main__":
+    main()

Added: trunk/blender/build_files/cmake/cmake_static_check_splint.py
===================================================================
--- trunk/blender/build_files/cmake/cmake_static_check_splint.py	                        (rev 0)
+++ trunk/blender/build_files/cmake/cmake_static_check_splint.py	2011-09-16 06:58:20 UTC (rev 40254)
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+
+# $Id:
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Campbell Barton
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# <pep8 compliant>
+
+CHECKER_IGNORE_PREFIX = [
+    "extern",
+    "intern/moto",
+    ]
+
+CHECKER_BIN = "splint"
+
+CHECKER_ARGS = [
+    "-weak",
+    "-posix-lib",
+    "-linelen", "10000",
+    "+ignorequals",
+    "+relaxtypes",
+    "-retvalother",
+    "+matchanyintegral",
+    "+longintegral",
+    "+ignoresigns",
+    "-nestcomment",
+    "-predboolothers",
+    "-ifempty",
+    "-unrecogcomments",
+
+    # we may want to remove these later
+    "-type",
+    "-fixedformalarray",
+    "-fullinitblock",
+    "-fcnuse",
+    "-initallelements",
+    "-castfcnptr",
+    # -forcehints,
+    "-bufferoverflowhigh",  # warns a lot about sprintf()
+
+    # re-definitions, rna causes most of these
+    "-redef",
+    "-syntax",
+    ]
+
+
+import project_source_info
+import subprocess
+import sys
+
+
+def main():
+    source_info = project_source_info.build_info(use_cxx=False, ignore_prefix_list=CHECKER_IGNORE_PREFIX)
+
+    check_commands = []
+    for c, inc_dirs, defs in source_info:
+        cmd = ([CHECKER_BIN] +
+                CHECKER_ARGS +
+               [c] +
+               [("-I%s" % i) for i in inc_dirs] +
+               [("-D%s" % d) for d in defs]
+              )
+
+        check_commands.append((c, cmd))
+
+    for i, (c, cmd) in enumerate(check_commands):
+        percent = 100.0 * (i / (len(check_commands) - 1))
+        percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
+
+        sys.stdout.write("%s %s\n" % (percent_str, c))
+        sys.stdout.flush()
+
+        process = subprocess.Popen(cmd)
+        process.wait()
+
+if __name__ == "__main__":
+    main()

Added: trunk/blender/build_files/cmake/project_source_info.py
===================================================================
--- trunk/blender/build_files/cmake/project_source_info.py	                        (rev 0)
+++ trunk/blender/build_files/cmake/project_source_info.py	2011-09-16 06:58:20 UTC (rev 40254)
@@ -0,0 +1,165 @@
+# $Id:
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Campbell Barton
+#
+# ***** END GPL LICENSE BLOCK *****
+
+# <pep8 compliant>
+
+__all__ = (
+    "build_info",
+    "SOURCE_DIR",
+    )
+
+import os
+import sys
+from os.path import join, dirname, normpath, abspath
+
+SOURCE_DIR = join(dirname(__file__), "..", "..")
+SOURCE_DIR = normpath(SOURCE_DIR)
+SOURCE_DIR = abspath(SOURCE_DIR)
+
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list