Import dEQP.
[platform/upstream/VK-GL-CTS.git] / scripts / cppcheck.py
1 # -*- coding: utf-8 -*-
2
3 import os
4 import sys
5 import shlex
6 import subprocess
7
8 SRC_DIRS = [
9         "delibs/debase",
10         "delibs/deimage",
11         "delibs/depool",
12         "delibs/dethread",
13         "delibs/deutil",
14         "delibs/decpp",
15
16         "deqp/execserver",
17         "deqp/executor",
18         "deqp/modules/candytest",
19         "deqp/modules/egl",
20         "deqp/modules/gles2",
21         "deqp/modules/gles3",
22         "deqp/modules/gles31",
23         "deqp/modules/gl3",
24         "deqp/modules/glshared",
25         "deqp/modules/glusecases",
26         "deqp/modules/opencl",
27         "deqp/modules/internal",
28         "deqp/framework/qphelper",
29         "deqp/framework/common",
30         "deqp/framework/egl",
31         "deqp/framework/opengl",
32         "deqp/framework/opencl",
33         "deqp/framework/platform",
34         "deqp/framework/randomshaders",
35         "deqp/framework/referencerenderer",
36         "deqp/wrappers/dynlib",
37         "deqp/wrappers/gles3",
38
39         "gapir",
40 ]
41
42 INCLUDE_DIRS = [
43         "delibs/libpng",
44         "delibs/libzip",
45         "delibs/zlib",
46
47         "deqp/wrappers/dynlib/inc",
48         "deqp/wrappers/gles3/inc",
49         "deqp/modules/gles2/accuracy",
50         "deqp/modules/gles2/functional",
51         "deqp/modules/gles2/performance",
52         "deqp/modules/gles2/stress",
53         "deqp/modules/gles2/usecases",
54         "deqp/modules/gles3/accuracy",
55         "deqp/modules/gles3/functional",
56         "deqp/modules/gles3/stress",
57         "deqp/modules/gles3/usecases",
58         "deqp/modules/gles3/performance",
59         "deqp/modules/gles31/functional",
60         "deqp/modules/gles31/stress",
61         "deqp/modules/gl3/functional",
62         "deqp/modules/gl3/performance",
63         "deqp/modules/gl3/stress",
64         "deqp/framework/opengl/simplereference",
65         "deqp/framework/opencl/inc",
66         "deqp/framework/opengl/wrapper",
67         "deqp/framework/opengl/simplereference",
68
69         "gapir/base",
70         "gapir/egl",
71         "gapir/gles2",
72         "gapir/util",
73
74         "domeni/eigen2",
75         "domeni/base",
76         "domeni/engine",
77         "domeni/m3g",
78         "domeni/m3g_adapter",
79         "domeni/renderer",
80         "domeni/resource",
81         "domeni/tools"
82 ] + SRC_DIRS
83
84 ARGS = [
85         "--enable=all,style",
86         "--xml-version=2",
87         "--platform=win64",
88         "-D__cplusplus",
89         "-D_M_X64",
90         "-D_WIN32",
91         "-D_MSC_VER=1600",
92         "-DDE_DEBUG=1",
93         "-DDE_COMPILER=1", # Is preprocessor buggy in recent cppcheck?
94         "-DDE_OS=1",
95         "-DDE_CPU=1",
96         "-DDE_PTR_SIZE=4",
97         "-DAB_COMPILER=1",
98         "-DAB_OS=1",
99         "-DDEQP_SUPPORT_GLES2=1",
100         "-DDEQP_SUPPORT_GLES3=1",
101         "-DDEQP_SUPPORT_OPENCL=1",
102         "-DDEQP_SUPPORT_OPENGL=1",
103         "-DDEQP_TARGET_NAME=\"Cppcheck\"",
104         "-D_XOPEN_SOURCE=600",
105         "--suppress=arrayIndexOutOfBounds:deqp/framework/common/tcuVector.hpp",
106         "--suppress=invalidPointerCast:deqp/framework/common/tcuTexture.cpp",
107         "--suppress=*:deqp/framework/opencl/cl.hpp",
108         "--suppress=invalidPointerCast:deqp/modules/opencl/tclSIRLogger.cpp",
109         "--suppress=preprocessorErrorDirective:deqp/framework/platform/android/tcuAndroidMain.cpp",
110         "--suppress=invalidPointerCast:deqp/modules/gles3/functional/es3fTransformFeedbackTests.cpp",
111         "--suppress=invalidPointerCast:deqp/modules/gles3/functional/es3fUniformBlockCase.cpp",
112         "--suppress=unusedStructMember",
113         "--suppress=postfixOperator",
114         "--suppress=unusedFunction",
115         "--suppress=unusedPrivateFunction",
116         "--rule-file=deqp/scripts/no_empty_fail.rule"
117 ]
118
119 def runCppCheck (srcBaseDir, dstFile):
120         fullDstFile     = os.path.realpath(dstFile)
121         command         = '"C:\\Program Files (x86)\\Cppcheck\\cppcheck.exe"'
122
123         for arg in ARGS + ["--xml"]:
124                 command += " %s" % arg
125
126         for path in INCLUDE_DIRS:
127                 command += " -I %s" % path
128
129         for path in SRC_DIRS:
130                 command += " %s" % path
131
132         command += ' 2> "%s"' % fullDstFile
133
134         os.chdir(srcBaseDir)
135         os.system('"%s"' % command) # Double-quotes needed for some reason
136
137 if __name__ == "__main__":
138         if len(sys.argv) != 2:
139                 print "%s: [reportfile]" % sys.argv[0]
140                 sys.exit(-1)
141
142         dstFile = sys.argv[1]
143         srcDir  = os.path.realpath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))
144         runCppCheck(srcDir, dstFile)