Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: tools/presubmit.py

Issue 13849008: Fix so that you can run presubmit.py in Windows. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 IGNORE_LINT = ['flag-definitions.h'] 222 IGNORE_LINT = ['flag-definitions.h']
223 223
224 def IgnoreFile(self, name): 224 def IgnoreFile(self, name):
225 return (super(CppLintProcessor, self).IgnoreFile(name) 225 return (super(CppLintProcessor, self).IgnoreFile(name)
226 or (name in CppLintProcessor.IGNORE_LINT)) 226 or (name in CppLintProcessor.IGNORE_LINT))
227 227
228 def GetPathsToSearch(self): 228 def GetPathsToSearch(self):
229 return ['src', 'preparser', 'include', 'samples', join('test', 'cctest')] 229 return ['src', 'preparser', 'include', 'samples', join('test', 'cctest')]
230 230
231 def GetCpplintScript(self, prio_path):
232 for path in [prio_path] + os.environ["PATH"].split(os.pathsep):
233 path = path.strip('"')
234 cpplint = os.path.join(path, "cpplint.py")
235 if os.path.isfile(cpplint):
236 return cpplint
237
238 return None
239
231 def ProcessFiles(self, files, path): 240 def ProcessFiles(self, files, path):
232 good_files_cache = FileContentsCache('.cpplint-cache') 241 good_files_cache = FileContentsCache('.cpplint-cache')
233 good_files_cache.Load() 242 good_files_cache.Load()
234 files = good_files_cache.FilterUnchangedFiles(files) 243 files = good_files_cache.FilterUnchangedFiles(files)
235 if len(files) == 0: 244 if len(files) == 0:
236 print 'No changes in files detected. Skipping cpplint check.' 245 print 'No changes in files detected. Skipping cpplint check.'
237 return True 246 return True
238 247
239 filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES]) 248 filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES])
240 command = ['cpplint.py', '--filter', filt] 249 command = [sys.executable, 'cpplint.py', '--filter', filt]
241 local_cpplint = join(path, "tools", "cpplint.py") 250 cpplint = self.GetCpplintScript(join(path, "tools"))
242 if exists(local_cpplint): 251 if cpplint is None:
243 command = ['python', local_cpplint, '--filter', filt] 252 print('Could not find cpplint.py. Make sure '
253 'depot_tools is installed and in the path.')
254 sys.exit(1)
255
256 command = [sys.executable, cpplint, '--filter', filt]
244 257
245 commands = join([command + [file] for file in files]) 258 commands = join([command + [file] for file in files])
246 count = multiprocessing.cpu_count() 259 count = multiprocessing.cpu_count()
247 pool = multiprocessing.Pool(count) 260 pool = multiprocessing.Pool(count)
248 try: 261 try:
249 results = pool.map_async(CppLintWorker, commands).get(999999) 262 results = pool.map_async(CppLintWorker, commands).get(999999)
250 except KeyboardInterrupt: 263 except KeyboardInterrupt:
251 print "\nCaught KeyboardInterrupt, terminating workers." 264 print "\nCaught KeyboardInterrupt, terminating workers."
252 sys.exit(1) 265 sys.exit(1)
253 266
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 print "Running copyright header and trailing whitespaces check..." 393 print "Running copyright header and trailing whitespaces check..."
381 success = SourceProcessor().Run(workspace) and success 394 success = SourceProcessor().Run(workspace) and success
382 if success: 395 if success:
383 return 0 396 return 0
384 else: 397 else:
385 return 1 398 return 1
386 399
387 400
388 if __name__ == '__main__': 401 if __name__ == '__main__':
389 sys.exit(Main()) 402 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698