From: sgjesse@chromium.org Date: Fri, 11 Sep 2009 12:21:48 +0000 (+0000) Subject: Use local cpplint.py if it exists. X-Git-Tag: upstream/4.7.83~23289 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5864d08af29e10f67cb6ffb77835f5cdae3f87a;p=platform%2Fupstream%2Fv8.git Use local cpplint.py if it exists. If there is a local cpplint.py in the tools directory use this instead of any cpplint in the path. This makes it possible to run presubmit checks on Windows by downloading cpplint.py from http://code.google.com/p/google-styleguide/. Review URL: http://codereview.chromium.org/194039 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2874 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/tools/presubmit.py b/tools/presubmit.py index 3e714de..c4f7853 100755 --- a/tools/presubmit.py +++ b/tools/presubmit.py @@ -30,7 +30,7 @@ import optparse import os -from os.path import abspath, join, dirname, basename +from os.path import abspath, join, dirname, basename, exists import re import sys import subprocess @@ -103,7 +103,7 @@ class SourceFileProcessor(object): all_files = [] for file in self.GetPathsToSearch(): all_files += self.FindFilesIn(join(path, file)) - if not self.ProcessFiles(all_files): + if not self.ProcessFiles(all_files, path): return False return True @@ -145,9 +145,12 @@ class CppLintProcessor(SourceFileProcessor): def GetPathsToSearch(self): return ['src', 'public', 'samples', join('test', 'cctest')] - def ProcessFiles(self, files): + def ProcessFiles(self, files, path): filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES]) command = ['cpplint.py', '--filter', filt] + join(files) + local_cpplint = join(path, "tools", "cpplint.py") + if exists(local_cpplint): + command = ['python', local_cpplint, '--filter', filt] + join(files) process = subprocess.Popen(command) return process.wait() == 0 @@ -194,7 +197,7 @@ class SourceProcessor(SourceFileProcessor): result = False return result - def ProcessFiles(self, files): + def ProcessFiles(self, files, path): success = True for file in files: try: