Commit c219b8a1 authored by wychen's avatar wychen Committed by Commit bot

Revert of Optimize check_gn_headers.py for speed (patchset #1 id:1 of...

Revert of Optimize check_gn_headers.py for speed (patchset #1 id:1 of https://codereview.chromium.org/2842513003/ )

Reason for revert:
This optimization was buggy and broke the ninja parsing.

Original issue's description:
> Optimize check_gn_headers.py for speed
>
> Process the output of 'ninja' live through the pipe rather than waiting
> for it to finish.
>
> Before:
> 20.74user 16.36system 0:24.57elapsed 151%CPU
>
> After:
> 16.63user 9.24system 0:13.94elapsed 185%CPU
>
> BUG=661774
>
> Review-Url: https://codereview.chromium.org/2842513003
> Cr-Commit-Position: refs/heads/master@{#466900}
> Committed: https://chromium.googlesource.com/chromium/src/+/6b609383cf3669b0670b567249ff868ea4b26e43

TBR=dpranke@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=661774

Review-Url: https://codereview.chromium.org/2844623002
Cr-Commit-Position: refs/heads/master@{#467231}
parent 74946c37
......@@ -19,21 +19,7 @@ import sys
def GetHeadersFromNinja(out_dir):
"""Return all the header files from ninja_deps"""
def NinjaSource():
cmd = ['ninja', '-C', out_dir, '-t', 'deps']
# A negative bufsize means to use the system default, which usually
# means fully buffered.
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=-1)
for line in iter(popen.stdout.readline, ''):
yield line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
ninja_out = NinjaSource()
ninja_out = subprocess.check_output(['ninja', '-C', out_dir, '-t', 'deps'])
return ParseNinjaDepsOutput(ninja_out)
......@@ -44,7 +30,7 @@ def ParseNinjaDepsOutput(ninja_out):
prefix = '..' + os.sep + '..' + os.sep
is_valid = False
for line in ninja_out:
for line in ninja_out.split('\n'):
if line.startswith(' '):
if not is_valid:
continue
......
......@@ -58,7 +58,7 @@ a/b/c
class CheckGnHeadersTest(unittest.TestCase):
def testNinja(self):
headers = check_gn_headers.ParseNinjaDepsOutput(ninja_input.split('\n'))
headers = check_gn_headers.ParseNinjaDepsOutput(ninja_input)
expected = set([
'dir/path/b.h',
'c.hh',
......@@ -71,8 +71,7 @@ class CheckGnHeadersTest(unittest.TestCase):
old_sep = os.sep
os.sep = '\\'
headers = check_gn_headers.ParseNinjaDepsOutput(
ninja_input_win.split('\n'))
headers = check_gn_headers.ParseNinjaDepsOutput(ninja_input_win)
expected = set([
'dir\\path\\b.h',
'c.hh',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment