Commit a16aea95 by Jamie Madill Committed by Commit Bot

Fixes to roll_chromium_deps.py.

Includes the new sheriff email alias, and also fixes to the Clang version detection. The new version checks the CopyBara mirror to find the real clang rev ANGLE ends up with. Bug: angleproject:5926 Change-Id: Ie70319feeb5eefbfba8a6b6d2d57110273d6c3e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2872070 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 167a4b6d
...@@ -105,22 +105,19 @@ ANDROID_DEPS_END = r'=== ANDROID_DEPS Generated Code End ===' ...@@ -105,22 +105,19 @@ ANDROID_DEPS_END = r'=== ANDROID_DEPS Generated Code End ==='
# Location of automically gathered android deps. # Location of automically gathered android deps.
ANDROID_DEPS_PATH = 'src/third_party/android_deps/' ANDROID_DEPS_PATH = 'src/third_party/android_deps/'
# TODO(jmadill): Update this with ANGLE wrangler. http://anglebug.com/4059 NOTIFY_EMAIL = 'angle-wrangler@grotations.appspotmail.com'
NOTIFY_EMAIL = 'jmadill@chromium.org'
CLANG_TOOLS_URL = 'https://chromium.googlesource.com/chromium/src/tools/clang'
CLANG_FILE_TEMPLATE = CLANG_TOOLS_URL + '/+/%s/%s'
def add_depot_tools_to_path(): CLANG_TOOLS_PATH = 'tools/clang'
sys.path.append(os.path.join(CHECKOUT_SRC_DIR, 'build')) CLANG_UPDATE_SCRIPT_URL_PATH = 'scripts/update.py'
import find_depot_tools
find_depot_tools.add_depot_tools_to_path()
CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py'
CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join(CHECKOUT_SRC_DIR, 'tools', 'clang', 'scripts', CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join(CHECKOUT_SRC_DIR, 'tools', 'clang', 'scripts',
'update.py') 'update.py')
DepsEntry = collections.namedtuple('DepsEntry', 'path url revision') DepsEntry = collections.namedtuple('DepsEntry', 'path url revision')
ChangedDep = collections.namedtuple('ChangedDep', 'path url current_rev new_rev') ChangedDep = collections.namedtuple('ChangedDep', 'path url current_rev new_rev')
ClangChange = collections.namedtuple('ClangChange', 'mirror_change clang_change')
CipdDepsEntry = collections.namedtuple('CipdDepsEntry', 'path packages') CipdDepsEntry = collections.namedtuple('CipdDepsEntry', 'path packages')
ChangedCipdPackage = collections.namedtuple('ChangedCipdPackage', ChangedCipdPackage = collections.namedtuple('ChangedCipdPackage',
'path package current_version new_version') 'path package current_version new_version')
...@@ -129,6 +126,12 @@ ChromiumRevisionUpdate = collections.namedtuple('ChromiumRevisionUpdate', ('curr ...@@ -129,6 +126,12 @@ ChromiumRevisionUpdate = collections.namedtuple('ChromiumRevisionUpdate', ('curr
'new_chromium_rev ')) 'new_chromium_rev '))
def AddDepotToolsToPath():
sys.path.append(os.path.join(CHECKOUT_SRC_DIR, 'build'))
import find_depot_tools
find_depot_tools.add_depot_tools_to_path()
class RollError(Exception): class RollError(Exception):
pass pass
...@@ -226,6 +229,7 @@ def _GetBranches(): ...@@ -226,6 +229,7 @@ def _GetBranches():
def _ReadGitilesContent(url): def _ReadGitilesContent(url):
# Download and decode BASE64 content until # Download and decode BASE64 content until
# https://code.google.com/p/gitiles/issues/detail?id=7 is fixed. # https://code.google.com/p/gitiles/issues/detail?id=7 is fixed.
logging.debug('Reading gitiles URL %s' % url)
base64_content = ReadUrlContent(url + '?format=TEXT') base64_content = ReadUrlContent(url + '?format=TEXT')
return base64.b64decode(base64_content[0]) return base64.b64decode(base64_content[0])
...@@ -240,6 +244,11 @@ def ReadRemoteCrCommit(revision): ...@@ -240,6 +244,11 @@ def ReadRemoteCrCommit(revision):
return _ReadGitilesContent(CHROMIUM_COMMIT_TEMPLATE % revision) return _ReadGitilesContent(CHROMIUM_COMMIT_TEMPLATE % revision)
def ReadRemoteClangFile(path_below_src, revision):
"""Reads a remote Clang file of a specific revision. Returns a string."""
return _ReadGitilesContent(CLANG_FILE_TEMPLATE % (revision, path_below_src))
def ReadUrlContent(url): def ReadUrlContent(url):
"""Connect to a remote host and read the contents. Returns a list of lines.""" """Connect to a remote host and read the contents. Returns a list of lines."""
conn = urllib2.urlopen(url) conn = urllib2.urlopen(url)
...@@ -384,7 +393,12 @@ def CalculateChangedDeps(angle_deps, new_cr_deps): ...@@ -384,7 +393,12 @@ def CalculateChangedDeps(angle_deps, new_cr_deps):
return sorted(result) return sorted(result)
def CalculateChangedClang(cur_cr_rev, new_cr_rev, autoroll): def CalculateChangedClang(changed_deps, autoroll):
mirror_change = [change for change in changed_deps if change.path == CLANG_TOOLS_PATH]
if not mirror_change:
return None
mirror_change = mirror_change[0]
def GetClangRev(lines): def GetClangRev(lines):
for line in lines: for line in lines:
...@@ -393,19 +407,17 @@ def CalculateChangedClang(cur_cr_rev, new_cr_rev, autoroll): ...@@ -393,19 +407,17 @@ def CalculateChangedClang(cur_cr_rev, new_cr_rev, autoroll):
return match.group(1) return match.group(1)
raise RollError('Could not parse Clang revision!') raise RollError('Could not parse Clang revision!')
# We don't have locally sync'ed deps on autoroller old_clang_update_py = ReadRemoteClangFile(CLANG_UPDATE_SCRIPT_URL_PATH,
if not autoroll: mirror_change.current_rev).splitlines()
with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'rb') as f: old_clang_rev = GetClangRev(old_clang_update_py)
current_lines = f.readlines() logging.debug('Found old clang rev: %s' % old_clang_rev)
current_rev = GetClangRev(current_lines)
else:
cur_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH,
cur_cr_rev).splitlines()
current_rev = GetClangRev(cur_clang_update_py)
new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, new_cr_rev).splitlines() new_clang_update_py = ReadRemoteClangFile(CLANG_UPDATE_SCRIPT_URL_PATH,
new_rev = GetClangRev(new_clang_update_py) mirror_change.new_rev).splitlines()
return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, new_rev) new_clang_rev = GetClangRev(new_clang_update_py)
logging.debug('Found new clang rev: %s' % new_clang_rev)
clang_change = ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, old_clang_rev, new_clang_rev)
return ClangChange(mirror_change, clang_change)
def GenerateCommitMessage( def GenerateCommitMessage(
...@@ -414,7 +426,7 @@ def GenerateCommitMessage( ...@@ -414,7 +426,7 @@ def GenerateCommitMessage(
new_commit_pos, new_commit_pos,
changed_deps_list, changed_deps_list,
autoroll, autoroll,
clang_change=None, clang_change,
): ):
current_cr_rev = rev_update.current_chromium_rev[0:10] current_cr_rev = rev_update.current_chromium_rev[0:10]
new_cr_rev = rev_update.new_chromium_rev[0:10] new_cr_rev = rev_update.new_chromium_rev[0:10]
...@@ -454,10 +466,14 @@ def GenerateCommitMessage( ...@@ -454,10 +466,14 @@ def GenerateCommitMessage(
else: else:
commit_msg.append('No dependencies changed.') commit_msg.append('No dependencies changed.')
if clang_change and clang_change.current_rev != clang_change.new_rev: c = clang_change
if (c and (c.clang_change.current_rev != c.clang_change.new_rev)):
commit_msg.append('Clang version changed %s:%s' % commit_msg.append('Clang version changed %s:%s' %
(clang_change.current_rev, clang_change.new_rev)) (c.clang_change.current_rev, c.clang_change.new_rev))
change_url = CHROMIUM_FILE_TEMPLATE % (rev_interval, CLANG_UPDATE_SCRIPT_URL_PATH)
rev_clang = rev_interval = '%s..%s' % (c.mirror_change.current_rev,
c.mirror_change.new_rev)
change_url = CLANG_FILE_TEMPLATE % (rev_clang, CLANG_UPDATE_SCRIPT_URL_PATH)
commit_msg.append('Details: %s\n' % change_url) commit_msg.append('Details: %s\n' % change_url)
else: else:
commit_msg.append('No update to Clang.\n') commit_msg.append('No update to Clang.\n')
...@@ -694,7 +710,7 @@ def main(): ...@@ -694,7 +710,7 @@ def main():
# We don't have locally sync'ed deps on autoroller, # We don't have locally sync'ed deps on autoroller,
# so trust it to have depot_tools in path # so trust it to have depot_tools in path
if not opts.autoroll: if not opts.autoroll:
add_depot_tools_to_path() AddDepotToolsToPath()
if not opts.ignore_unclean_workdir and not _IsTreeClean(): if not opts.ignore_unclean_workdir and not _IsTreeClean():
logging.error('Please clean your local checkout first.') logging.error('Please clean your local checkout first.')
...@@ -717,15 +733,9 @@ def main(): ...@@ -717,15 +733,9 @@ def main():
new_cr_content = ReadRemoteCrFile('DEPS', rev_update.new_chromium_rev) new_cr_content = ReadRemoteCrFile('DEPS', rev_update.new_chromium_rev)
new_cr_deps = ParseDepsDict(new_cr_content) new_cr_deps = ParseDepsDict(new_cr_content)
changed_deps = CalculateChangedDeps(angle_deps, new_cr_deps) changed_deps = CalculateChangedDeps(angle_deps, new_cr_deps)
clang_change = CalculateChangedClang(rev_update.current_chromium_rev, clang_change = CalculateChangedClang(changed_deps, opts.autoroll)
rev_update.new_chromium_rev, opts.autoroll) commit_msg = GenerateCommitMessage(rev_update, current_commit_pos, new_commit_pos,
commit_msg = GenerateCommitMessage( changed_deps, opts.autoroll, clang_change)
rev_update,
current_commit_pos,
new_commit_pos,
changed_deps,
opts.autoroll,
clang_change=clang_change)
logging.debug('Commit message:\n%s', commit_msg) logging.debug('Commit message:\n%s', commit_msg)
# We are updating a commit that autoroll has created, using existing branch # We are updating a commit that autoroll has created, using existing branch
......
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