Skip to content

Commit

Permalink
Fix so that you can run presubmit.py in Windows.
Browse files Browse the repository at this point in the history
presubmit.py tried to execute cpplint.py directly, but in Windows it's the shell that connects that to the python binary so the execution (subprocess.Popen) needs to be told how to find python. An alternative would be to call subprocess.Popen with shell=True but this is less dangerous.

Review URL: https://chromiumcodereview.appspot.com/13849008

Patch from Daniel Bratell <bratell@opera.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14263 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information
yangguo@chromium.org committed Apr 15, 2013
1 parent 2345bdb commit 55b2391
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tools/presubmit.py
Expand Up @@ -228,6 +228,15 @@ def IgnoreFile(self, name):
def GetPathsToSearch(self):
return ['src', 'preparser', 'include', 'samples', join('test', 'cctest')]

def GetCpplintScript(self, prio_path):
for path in [prio_path] + os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
cpplint = os.path.join(path, "cpplint.py")
if os.path.isfile(cpplint):
return cpplint

return None

def ProcessFiles(self, files, path):
good_files_cache = FileContentsCache('.cpplint-cache')
good_files_cache.Load()
Expand All @@ -237,10 +246,14 @@ def ProcessFiles(self, files, path):
return True

filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES])
command = ['cpplint.py', '--filter', filt]
local_cpplint = join(path, "tools", "cpplint.py")
if exists(local_cpplint):
command = ['python', local_cpplint, '--filter', filt]
command = [sys.executable, 'cpplint.py', '--filter', filt]
cpplint = self.GetCpplintScript(join(path, "tools"))
if cpplint is None:
print('Could not find cpplint.py. Make sure '
'depot_tools is installed and in the path.')
sys.exit(1)

command = [sys.executable, cpplint, '--filter', filt]

commands = join([command + [file] for file in files])
count = multiprocessing.cpu_count()
Expand Down

0 comments on commit 55b2391

Please sign in to comment.