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