summaryrefslogtreecommitdiff
path: root/scripts/cppcheck.py
blob: bd662139232ecb106d417c4c36d0771c50eae3d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- coding: utf-8 -*-

#-------------------------------------------------------------------------
# drawElements Quality Program utilities
# --------------------------------------
#
# Copyright 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-------------------------------------------------------------------------

import os
import sys
import shlex
import subprocess

SRC_DIRS = [
	"delibs/debase",
	"delibs/deimage",
	"delibs/depool",
	"delibs/dethread",
	"delibs/deutil",
	"delibs/decpp",

	"deqp/execserver",
	"deqp/executor",
	"deqp/modules/candytest",
	"deqp/modules/egl",
	"deqp/modules/gles2",
	"deqp/modules/gles3",
	"deqp/modules/gles31",
	"deqp/modules/gl3",
	"deqp/modules/glshared",
	"deqp/modules/glusecases",
	"deqp/modules/opencl",
	"deqp/modules/internal",
	"deqp/framework/qphelper",
	"deqp/framework/common",
	"deqp/framework/egl",
	"deqp/framework/opengl",
	"deqp/framework/opencl",
	"deqp/framework/platform",
	"deqp/framework/randomshaders",
	"deqp/framework/referencerenderer",
	"deqp/wrappers/dynlib",
	"deqp/wrappers/gles3",

	"gapir",
]

INCLUDE_DIRS = [
	"delibs/libpng",
	"delibs/libzip",
	"delibs/zlib",

	"deqp/wrappers/dynlib/inc",
	"deqp/wrappers/gles3/inc",
	"deqp/modules/gles2/accuracy",
	"deqp/modules/gles2/functional",
	"deqp/modules/gles2/performance",
	"deqp/modules/gles2/stress",
	"deqp/modules/gles2/usecases",
	"deqp/modules/gles3/accuracy",
	"deqp/modules/gles3/functional",
	"deqp/modules/gles3/stress",
	"deqp/modules/gles3/usecases",
	"deqp/modules/gles3/performance",
	"deqp/modules/gles31/functional",
	"deqp/modules/gles31/stress",
	"deqp/modules/gl3/functional",
	"deqp/modules/gl3/performance",
	"deqp/modules/gl3/stress",
	"deqp/framework/opengl/simplereference",
	"deqp/framework/opencl/inc",
	"deqp/framework/opengl/wrapper",
	"deqp/framework/opengl/simplereference",

	"gapir/base",
	"gapir/egl",
	"gapir/gles2",
	"gapir/util",

	"domeni/eigen2",
	"domeni/base",
	"domeni/engine",
	"domeni/m3g",
	"domeni/m3g_adapter",
	"domeni/renderer",
	"domeni/resource",
	"domeni/tools"
] + SRC_DIRS

ARGS = [
	"--enable=all,style",
	"--xml-version=2",
	"--platform=win64",
	"-D__cplusplus",
	"-D_M_X64",
	"-D_WIN32",
	"-D_MSC_VER=1600",
	"-DDE_DEBUG=1",
	"-DDE_COMPILER=1", # Is preprocessor buggy in recent cppcheck?
	"-DDE_OS=1",
	"-DDE_CPU=1",
	"-DDE_PTR_SIZE=4",
	"-DAB_COMPILER=1",
	"-DAB_OS=1",
	"-DDEQP_TARGET_NAME=\"Cppcheck\"",
	"-D_XOPEN_SOURCE=600",
	"--suppress=arrayIndexOutOfBounds:deqp/framework/common/tcuVector.hpp",
	"--suppress=invalidPointerCast:deqp/framework/common/tcuTexture.cpp",
	"--suppress=*:deqp/framework/opencl/cl.hpp",
	"--suppress=invalidPointerCast:deqp/modules/opencl/tclSIRLogger.cpp",
	"--suppress=preprocessorErrorDirective:deqp/framework/platform/android/tcuAndroidMain.cpp",
	"--suppress=invalidPointerCast:deqp/modules/gles3/functional/es3fTransformFeedbackTests.cpp",
	"--suppress=invalidPointerCast:deqp/modules/gles3/functional/es3fUniformBlockCase.cpp",
	"--suppress=unusedStructMember",
	"--suppress=postfixOperator",
	"--suppress=unusedFunction",
	"--suppress=unusedPrivateFunction",
	"--rule-file=deqp/scripts/no_empty_fail.rule"
]

def runCppCheck (srcBaseDir, dstFile):
	fullDstFile	= os.path.realpath(dstFile)
	command		= '"C:\\Program Files (x86)\\Cppcheck\\cppcheck.exe"'

	for arg in ARGS + ["--xml"]:
		command += " %s" % arg

	for path in INCLUDE_DIRS:
		command += " -I %s" % path

	for path in SRC_DIRS:
		command += " %s" % path

	command += ' 2> "%s"' % fullDstFile

	os.chdir(srcBaseDir)
	os.system('"%s"' % command) # Double-quotes needed for some reason

if __name__ == "__main__":
	if len(sys.argv) != 2:
		print("%s: [reportfile]" % sys.argv[0])
		sys.exit(-1)

	dstFile	= sys.argv[1]
	srcDir	= os.path.realpath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))
	runCppCheck(srcDir, dstFile)