From: yangguo@chromium.org Date: Mon, 15 Apr 2013 12:21:05 +0000 (+0000) Subject: Fix so that you can run presubmit.py in Windows. X-Git-Tag: upstream/4.7.83~14584 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55b239185738fda7ff3816b3484db446f92121c3;p=platform%2Fupstream%2Fv8.git Fix so that you can run presubmit.py in Windows. 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 . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14263 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/tools/presubmit.py b/tools/presubmit.py index efa8724..616505f 100755 --- a/tools/presubmit.py +++ b/tools/presubmit.py @@ -228,6 +228,15 @@ class CppLintProcessor(SourceFileProcessor): 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() @@ -237,10 +246,14 @@ class CppLintProcessor(SourceFileProcessor): 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()