| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2011 the V8 project authors. All rights reserved. | 3 # Copyright 2011 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 24 matching lines...) Expand all Loading... |
| 35 md5er = md5.new | 35 md5er = md5.new |
| 36 | 36 |
| 37 | 37 |
| 38 import optparse | 38 import optparse |
| 39 import os | 39 import os |
| 40 from os.path import abspath, join, dirname, basename, exists | 40 from os.path import abspath, join, dirname, basename, exists |
| 41 import pickle | 41 import pickle |
| 42 import re | 42 import re |
| 43 import sys | 43 import sys |
| 44 import subprocess | 44 import subprocess |
| 45 from subprocess import PIPE |
| 45 | 46 |
| 46 # Disabled LINT rules and reason. | 47 # Disabled LINT rules and reason. |
| 47 # build/include_what_you_use: Started giving false positives for variables | 48 # build/include_what_you_use: Started giving false positives for variables |
| 48 # named "string" and "map" assuming that you needed to include STL headers. | 49 # named "string" and "map" assuming that you needed to include STL headers. |
| 49 | 50 |
| 50 ENABLED_LINT_RULES = """ | 51 ENABLED_LINT_RULES = """ |
| 51 build/class | 52 build/class |
| 52 build/deprecated | 53 build/deprecated |
| 53 build/endif_comment | 54 build/endif_comment |
| 54 build/forward_decl | 55 build/forward_decl |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 r'Copyright [\d-]*20[0-1][0-9] the V8 project authors. All rights reserved.'
) | 230 r'Copyright [\d-]*20[0-1][0-9] the V8 project authors. All rights reserved.'
) |
| 230 | 231 |
| 231 class SourceProcessor(SourceFileProcessor): | 232 class SourceProcessor(SourceFileProcessor): |
| 232 """ | 233 """ |
| 233 Check that all files include a copyright notice and no trailing whitespaces. | 234 Check that all files include a copyright notice and no trailing whitespaces. |
| 234 """ | 235 """ |
| 235 | 236 |
| 236 RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', 'SConscript', | 237 RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', 'SConscript', |
| 237 'SConstruct', '.status', '.gyp', '.gypi'] | 238 'SConstruct', '.status', '.gyp', '.gypi'] |
| 238 | 239 |
| 240 # Overwriting the one in the parent class. |
| 241 def FindFilesIn(self, path): |
| 242 if os.path.exists(path+'/.git'): |
| 243 output = subprocess.Popen('git ls-files --full-name', |
| 244 stdout=PIPE, cwd=path, shell=True) |
| 245 result = [] |
| 246 for file in output.stdout.read().split(): |
| 247 for dir_part in os.path.dirname(file).split(os.sep): |
| 248 if self.IgnoreDir(dir_part): |
| 249 break |
| 250 else: |
| 251 if self.IsRelevant(file) and not self.IgnoreFile(file): |
| 252 result.append(join(path, file)) |
| 253 if output.wait() == 0: |
| 254 return result |
| 255 return super(SourceProcessor, self).FindFilesIn(path) |
| 256 |
| 239 def IsRelevant(self, name): | 257 def IsRelevant(self, name): |
| 240 for ext in SourceProcessor.RELEVANT_EXTENSIONS: | 258 for ext in SourceProcessor.RELEVANT_EXTENSIONS: |
| 241 if name.endswith(ext): | 259 if name.endswith(ext): |
| 242 return True | 260 return True |
| 243 return False | 261 return False |
| 244 | 262 |
| 245 def GetPathsToSearch(self): | 263 def GetPathsToSearch(self): |
| 246 return ['.'] | 264 return ['.'] |
| 247 | 265 |
| 248 def IgnoreDir(self, name): | 266 def IgnoreDir(self, name): |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 success = CppLintProcessor().Run(workspace) and success | 337 success = CppLintProcessor().Run(workspace) and success |
| 320 success = SourceProcessor().Run(workspace) and success | 338 success = SourceProcessor().Run(workspace) and success |
| 321 if success: | 339 if success: |
| 322 return 0 | 340 return 0 |
| 323 else: | 341 else: |
| 324 return 1 | 342 return 1 |
| 325 | 343 |
| 326 | 344 |
| 327 if __name__ == '__main__': | 345 if __name__ == '__main__': |
| 328 sys.exit(Main()) | 346 sys.exit(Main()) |
| OLD | NEW |