Changes in tools/checkers/vcc.py [ed63298:f4057f5] in mainline
- File:
-
- 1 edited
-
tools/checkers/vcc.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/checkers/vcc.py
red63298 rf4057f5 36 36 import subprocess 37 37 import jobfile 38 import re 38 39 39 40 jobs = [ 40 "kernel/kernel.job", 41 "uspace/srv/clip/clip.job" 41 "kernel/kernel.job" 42 42 ] 43 44 re_attribute = re.compile("__attribute__\s*\(\(.*\)\)") 45 re_va_list = re.compile("__builtin_va_list") 46 47 specification = "" 43 48 44 49 def usage(prname): 45 50 "Print usage syntax" 46 print prname + " <ROOT>"51 print(prname + " <ROOT> [VCC_PATH]") 47 52 48 53 def cygpath(upath): … … 54 59 "Preprocess source using GCC preprocessor and compatibility tweaks" 55 60 61 global specification 62 56 63 args = ['gcc', '-E'] 57 64 args.extend(options.split()) 58 args. append(srcfname)65 args.extend(['-DCONFIG_VERIFY_VCC=1', srcfname]) 59 66 60 67 # Change working directory … … 65 72 preproc = subprocess.Popen(args, stdout = subprocess.PIPE).communicate()[0] 66 73 67 tmpf = file(tmpfname, "w") 74 tmpf = open(tmpfname, "w") 75 tmpf.write(specification) 68 76 69 77 for line in preproc.splitlines(): 78 70 79 # Ignore preprocessor directives 80 71 81 if (line.startswith('#')): 72 continue 82 continue 83 84 # Remove __attribute__((.*)) GCC extension 85 86 line = re.sub(re_attribute, "", line) 87 88 # Ignore unsupported __builtin_va_list type 89 # (a better solution replacing __builrin_va_list with 90 # an emulated implementation is needed) 91 92 line = re.sub(re_va_list, "void *", line) 73 93 74 94 tmpf.write("%s\n" % line) … … 80 100 return True 81 101 82 def vcc( root, job):102 def vcc(vcc_path, root, job): 83 103 "Run Vcc on a jobfile" 84 104 … … 88 108 89 109 if (not os.path.isfile(inname)): 90 print "Unable to open %s" % inname91 print "Did you run \"make precheck\" on the source tree?"110 print("Unable to open %s" % inname) 111 print("Did you run \"make precheck\" on the source tree?") 92 112 return False 93 113 94 inf = file(inname, "r")114 inf = open(inname, "r") 95 115 records = inf.read().splitlines() 96 116 inf.close() … … 102 122 103 123 if (len(arg) < 6): 104 print "Not enought jobfile record arguments"124 print("Not enough jobfile record arguments") 105 125 return False 106 126 107 127 srcfname = arg[0] 108 128 tgtfname = arg[1] 129 tool = arg[2] 130 category = arg[3] 109 131 base = arg[4] 110 132 options = arg[5] … … 112 134 srcfqname = os.path.join(base, srcfname) 113 135 if (not os.path.isfile(srcfqname)): 114 print "Source %s not found" % srcfqname136 print("Source %s not found" % srcfqname) 115 137 return False 116 138 … … 118 140 tmpfqname = os.path.join(base, tmpfname) 119 141 142 vccfname = "%s.i" % srcfname 143 vccfqname = os.path.join(base, vccfname); 144 120 145 # Only C files are interesting for us 121 if ( arg[2]!= "cc"):146 if (tool != "cc"): 122 147 continue 123 148 … … 128 153 129 154 # Run Vcc 130 131 retval = subprocess.Popen(['vcc', cygpath(tmpfqname)]).wait() 132 133 # Cleanup 155 print(" -- %s --" % srcfname) 156 retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait() 157 158 if (retval != 0): 159 return False 160 161 # Cleanup, but only if verification was successful 162 # (to be able to examine the preprocessed file) 134 163 135 164 if (os.path.isfile(tmpfqname)): 136 165 os.remove(tmpfqname) 137 138 if (retval != 0): 139 return False 166 os.remove(vccfqname) 140 167 141 168 return True 142 169 143 170 def main(): 171 global specification 172 144 173 if (len(sys.argv) < 2): 145 174 usage(sys.argv[0]) … … 147 176 148 177 rootdir = os.path.abspath(sys.argv[1]) 178 if (len(sys.argv) > 2): 179 vcc_path = sys.argv[2] 180 else: 181 vcc_path = "/cygdrive/c/Program Files (x86)/Microsoft Research/Vcc/Binaries/vcc" 182 183 if (not os.path.isfile(vcc_path)): 184 print("%s is not a binary." % vcc_path) 185 print("Please supply the full Cygwin path to Vcc as the second argument.") 186 return 187 149 188 config = os.path.join(rootdir, "HelenOS.config") 150 189 151 190 if (not os.path.isfile(config)): 152 print "%s not found." % config 153 print "Please specify the path to HelenOS build tree root as the first argument." 154 return 191 print("%s not found." % config) 192 print("Please specify the path to HelenOS build tree root as the first argument.") 193 return 194 195 specpath = os.path.join(rootdir, "tools/checkers/vcc.h") 196 if (not os.path.isfile(specpath)): 197 print("%s not found." % config) 198 return 199 200 specfile = file(specpath, "r") 201 specification = specfile.read() 202 specfile.close() 155 203 156 204 for job in jobs: 157 if (not vcc( rootdir, job)):205 if (not vcc(vcc_path, rootdir, job)): 158 206 print 159 print "Failed job: %s" % job207 print("Failed job: %s" % job) 160 208 return 161 209 162 210 print 163 print "All jobs passed"211 print("All jobs passed") 164 212 165 213 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.
