1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright (c) 2017 The Khronos Group Inc.
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
26 from argparse import ArgumentParser
27 from common import getChangedFiles, getAllProjectFiles, isTextFile
37 "framework/delibs/debase/deDefs.h",
38 "framework/platform/android/tcuAndroidPlatform.cpp",
39 "framework/platform/android/tcuAndroidWindow.hpp",
40 "framework/platform/android/tcuAndroidWindow.cpp",
41 "framework/platform/lnx/X11/tcuLnxX11Xcb.cpp",
42 "framework/platform/lnx/wayland/tcuLnxWayland.hpp",
43 "framework/platform/lnx/wayland/tcuLnxWayland.cpp",
46 def checkEnds(line, ends):
47 return any(line.endswith(end) for end in ends)
49 def checkFileInvalidTypes (file):
52 if checkEnds(file.replace("\\", "/"), CHECK_LIST) and not checkEnds(file.replace("\\", "/"), EXCLUSION_LIST):
54 for lineNum, line in enumerate(f):
55 # Remove inline comments
59 # Remove text in quoted literals
60 if line.find("\"") > 0:
61 list = line.split('"')
64 line = line.join(list)
65 found = re.search(r'\b[us]*int[0-9]+_t\b', line)
68 print "%s:%i Unacceptable type found" % (file, lineNum+1)
73 def checkInvalidTypes (files):
77 if not checkFileInvalidTypes(file):
82 if __name__ == "__main__":
83 parser = ArgumentParser()
84 parser.add_argument("-e", "--only-errors", action="store_true", dest="onlyErrors", default=False, help="Print only on error")
85 parser.add_argument("-i", "--only-changed", action="store_true", dest="useGitIndex", default=False, help="Check only modified files. Uses git.")
87 args = parser.parse_args()
90 files = getChangedFiles()
92 files = getAllProjectFiles()
94 error = not checkInvalidTypes(files)
97 print "One or more checks failed"
99 if not args.onlyErrors:
100 print "All checks passed"