Skip to content

Instantly share code, notes, and snippets.

@jdm
Created November 8, 2016 20:02
Show Gist options
  • Save jdm/7126fa2adbb032fcec4b2eda0fbcec8d to your computer and use it in GitHub Desktop.
Save jdm/7126fa2adbb032fcec4b2eda0fbcec8d to your computer and use it in GitHub Desktop.
import subprocess
import re
import sys
print 'building...'
try:
output = subprocess.check_output(["ninja", "-C", "out/Default", "chrome"],
stderr=subprocess.STDOUT,
shell=False)
print 'no errors found!'
sys.exit(0)
except subprocess.CalledProcessError as e:
output = e.output
missing = []
for line in output.split('\n'):
match = re.search("no member named '(.*)' in 'blink::UseCounter", line)
if not match:
continue
name = match.group(1)
if not name in missing:
missing.append(name)
if not missing:
print output
sys.exit(1)
print 'inserting ', missing
filename = '/Users/jdm/src/chromium/src/third_party/WebKit/Source/core/frame/UseCounter.h'
with open(filename, 'r+') as f:
contents = f.readlines()
target = contents.index(" // Add new features immediately above this line. Don't change assigned\n")
previousIndex = target - 1
while True:
previous = contents[previousIndex]
match = re.search("(.*) = (\d+)", previous)
if match:
value = int(match.group(2)) + 1
break
previousIndex -= 1
for name in missing:
contents.insert(target, " %s = %d,\n" % (name, value))
value += 1
target += 1
contents = ''.join(contents)
f.seek(0)
f.write(contents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment