Changeset 8565a42 in mainline for tools/checkers/vcc.py
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/checkers/vcc.py
r3061bc1 r8565a42 53 53 def cygpath(upath): 54 54 "Convert Unix (Cygwin) path to Windows path" 55 55 56 56 return subprocess.Popen(['cygpath', '--windows', '--absolute', upath], stdout = subprocess.PIPE).communicate()[0].strip() 57 57 58 58 def preprocess(srcfname, tmpfname, base, options): 59 59 "Preprocess source using GCC preprocessor and compatibility tweaks" 60 60 61 61 global specification 62 62 63 63 args = ['gcc', '-E'] 64 64 args.extend(options.split()) 65 65 args.extend(['-DCONFIG_VERIFY_VCC=1', srcfname]) 66 66 67 67 # Change working directory 68 68 69 69 cwd = os.getcwd() 70 70 os.chdir(base) 71 71 72 72 preproc = subprocess.Popen(args, stdout = subprocess.PIPE).communicate()[0] 73 73 74 74 tmpf = open(tmpfname, "w") 75 75 tmpf.write(specification) 76 76 77 77 for line in preproc.splitlines(): 78 78 79 79 # Ignore preprocessor directives 80 80 81 81 if (line.startswith('#')): 82 82 continue 83 83 84 84 # Remove __attribute__((.*)) GCC extension 85 85 86 86 line = re.sub(re_attribute, "", line) 87 87 88 88 # Ignore unsupported __builtin_va_list type 89 89 # (a better solution replacing __builrin_va_list with 90 90 # an emulated implementation is needed) 91 91 92 92 line = re.sub(re_va_list, "void *", line) 93 93 94 94 tmpf.write("%s\n" % line) 95 95 96 96 tmpf.close() 97 97 98 98 os.chdir(cwd) 99 99 100 100 return True 101 101 102 102 def vcc(vcc_path, root, job): 103 103 "Run Vcc on a jobfile" 104 104 105 105 # Parse jobfile 106 106 107 107 inname = os.path.join(root, job) 108 108 109 109 if (not os.path.isfile(inname)): 110 110 print("Unable to open %s" % inname) 111 111 print("Did you run \"make precheck\" on the source tree?") 112 112 return False 113 113 114 114 inf = open(inname, "r") 115 115 records = inf.read().splitlines() 116 116 inf.close() 117 117 118 118 for record in records: 119 119 arg = jobfile.parse_arg(record) 120 120 if (not arg): 121 121 return False 122 122 123 123 if (len(arg) < 6): 124 124 print("Not enough jobfile record arguments") 125 125 return False 126 126 127 127 srcfname = arg[0] 128 128 tgtfname = arg[1] … … 131 131 base = arg[4] 132 132 options = arg[5] 133 133 134 134 srcfqname = os.path.join(base, srcfname) 135 135 if (not os.path.isfile(srcfqname)): 136 136 print("Source %s not found" % srcfqname) 137 137 return False 138 138 139 139 tmpfname = "%s.preproc" % srcfname 140 140 tmpfqname = os.path.join(base, tmpfname) 141 141 142 142 vccfname = "%s.i" % srcfname 143 143 vccfqname = os.path.join(base, vccfname); 144 144 145 145 # Only C files are interesting for us 146 146 if (tool != "cc"): 147 147 continue 148 148 149 149 # Preprocess sources 150 150 151 151 if (not preprocess(srcfname, tmpfname, base, options)): 152 152 return False 153 153 154 154 # Run Vcc 155 155 print(" -- %s --" % srcfname) 156 156 retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait() 157 157 158 158 if (retval != 0): 159 159 return False 160 160 161 161 # Cleanup, but only if verification was successful 162 162 # (to be able to examine the preprocessed file) 163 163 164 164 if (os.path.isfile(tmpfqname)): 165 165 os.remove(tmpfqname) 166 166 os.remove(vccfqname) 167 167 168 168 return True 169 169 170 170 def main(): 171 171 global specification 172 172 173 173 if (len(sys.argv) < 2): 174 174 usage(sys.argv[0]) 175 175 return 176 176 177 177 rootdir = os.path.abspath(sys.argv[1]) 178 178 if (len(sys.argv) > 2): … … 180 180 else: 181 181 vcc_path = "/cygdrive/c/Program Files (x86)/Microsoft Research/Vcc/Binaries/vcc" 182 182 183 183 if (not os.path.isfile(vcc_path)): 184 184 print("%s is not a binary." % vcc_path) 185 185 print("Please supply the full Cygwin path to Vcc as the second argument.") 186 186 return 187 187 188 188 config = os.path.join(rootdir, "HelenOS.config") 189 189 190 190 if (not os.path.isfile(config)): 191 191 print("%s not found." % config) 192 192 print("Please specify the path to HelenOS build tree root as the first argument.") 193 193 return 194 194 195 195 specpath = os.path.join(rootdir, "tools/checkers/vcc.h") 196 196 if (not os.path.isfile(specpath)): 197 197 print("%s not found." % config) 198 198 return 199 199 200 200 specfile = file(specpath, "r") 201 201 specification = specfile.read() 202 202 specfile.close() 203 203 204 204 for job in jobs: 205 205 if (not vcc(vcc_path, rootdir, job)): … … 207 207 print("Failed job: %s" % job) 208 208 return 209 209 210 210 print() 211 211 print("All jobs passed")
Note:
See TracChangeset
for help on using the changeset viewer.