Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: tools-webrtc/autoroller/roll_deps.py

Issue 1414343008: DEPS: Sync Git subtree mirrors instead of symlinking into chromium/src (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased (PS 16 and 17 has full trybot coverage) Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 # 3 #
4 # Use of this source code is governed by a BSD-style license 4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source 5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found 6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may 7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree. 8 # be found in the AUTHORS file in the root of the source tree.
9 9
10 """Script to automatically roll dependencies in the WebRTC DEPS file.""" 10 """Script to automatically roll dependencies in the WebRTC DEPS file."""
11 11
12 import argparse 12 import argparse
13 import base64 13 import base64
14 import collections 14 import collections
15 import logging 15 import logging
16 import os 16 import os
17 import re 17 import re
18 import subprocess 18 import subprocess
19 import sys 19 import sys
20 import urllib 20 import urllib
21 21
22 22
23 # Skip these dependencies (list without solution name prefix). 23 # Skip these dependencies (list without solution name prefix).
24 DONT_AUTOROLL_THESE = [ 24 DONT_AUTOROLL_THESE = [
25 'src/third_party/gflags/src', 25 'src/third_party/gflags/src',
26 'src/third_party/winsdk_samples/src', 26 'src/third_party/winsdk_samples',
27 ] 27 ]
28 28
29 WEBRTC_URL = 'https://chromium.googlesource.com/external/webrtc' 29 WEBRTC_URL = 'https://chromium.googlesource.com/external/webrtc'
30 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src' 30 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src'
31 CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s' 31 CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s'
32 CHROMIUM_LOG_TEMPLATE = CHROMIUM_SRC_URL + '/+log/%s' 32 CHROMIUM_LOG_TEMPLATE = CHROMIUM_SRC_URL + '/+log/%s'
33 CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s' 33 CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s'
34 34
35 COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$') 35 COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$')
36 CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION = \'(\d+)\'$') 36 CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION = \'(\d+)\'$')
37 ROLL_BRANCH_NAME = 'roll_chromium_revision' 37 ROLL_BRANCH_NAME = 'roll_chromium_revision'
38 38
39 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 39 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
40 CHECKOUT_SRC_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir, 40 CHECKOUT_SRC_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir,
41 os.pardir)) 41 os.pardir))
42 CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(CHECKOUT_SRC_DIR, os.pardir)) 42 CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(CHECKOUT_SRC_DIR, os.pardir))
43 CHROMIUM_CHECKOUT_SRC_DIR = os.path.join(CHECKOUT_SRC_DIR, 'chromium', 'src')
44 43
45 sys.path.append(CHECKOUT_SRC_DIR) 44 sys.path.append(CHECKOUT_SRC_DIR)
46 import setup_links 45 import setup_links
47 46
48 sys.path.append(os.path.join(CHECKOUT_SRC_DIR, 'build')) 47 sys.path.append(os.path.join(CHECKOUT_SRC_DIR, 'build'))
49 import find_depot_tools 48 import find_depot_tools
50 find_depot_tools.add_depot_tools_to_path() 49 find_depot_tools.add_depot_tools_to_path()
51 from gclient import GClientKeywords 50 from gclient import GClientKeywords
52 51
53 CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py' 52 CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py'
54 CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join('tools', 'clang', 'scripts', 53 CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join(CHECKOUT_SRC_DIR, 'tools',
55 'update.py') 54 'clang', 'scripts', 'update.py')
56 55
57 DepsEntry = collections.namedtuple('DepsEntry', 'path url revision') 56 DepsEntry = collections.namedtuple('DepsEntry', 'path url revision')
58 ChangedDep = collections.namedtuple('ChangedDep', 57 ChangedDep = collections.namedtuple('ChangedDep',
59 'path url current_rev new_rev') 58 'path url current_rev new_rev')
60 59
61 class RollError(Exception): 60 class RollError(Exception):
62 pass 61 pass
63 62
64 63
65 def ParseDepsDict(deps_content): 64 def ParseDepsDict(deps_content):
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 289
291 290
292 def CalculateChangedClang(new_cr_rev): 291 def CalculateChangedClang(new_cr_rev):
293 def GetClangRev(lines): 292 def GetClangRev(lines):
294 for line in lines: 293 for line in lines:
295 match = CLANG_REVISION_RE.match(line) 294 match = CLANG_REVISION_RE.match(line)
296 if match: 295 if match:
297 return match.group(1) 296 return match.group(1)
298 raise RollError('Could not parse Clang revision!') 297 raise RollError('Could not parse Clang revision!')
299 298
300 chromium_src_path = os.path.join(CHROMIUM_CHECKOUT_SRC_DIR, 299 with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'rb') as f:
301 CLANG_UPDATE_SCRIPT_LOCAL_PATH)
302 with open(chromium_src_path, 'rb') as f:
303 current_lines = f.readlines() 300 current_lines = f.readlines()
304 current_rev = GetClangRev(current_lines) 301 current_rev = GetClangRev(current_lines)
305 302
306 new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, 303 new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH,
307 new_cr_rev).splitlines() 304 new_cr_rev).splitlines()
308 new_rev = GetClangRev(new_clang_update_py) 305 new_rev = GetClangRev(new_clang_update_py)
309 return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, new_rev) 306 return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, new_rev)
310 307
311 308
312 def GenerateCommitMessage(current_cr_rev, new_cr_rev, current_commit_pos, 309 def GenerateCommitMessage(current_cr_rev, new_cr_rev, current_commit_pos,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 356
360 # Update the chromium_revision variable. 357 # Update the chromium_revision variable.
361 with open(deps_filename, 'rb') as deps_file: 358 with open(deps_filename, 'rb') as deps_file:
362 deps_content = deps_file.read() 359 deps_content = deps_file.read()
363 deps_content = deps_content.replace(old_cr_revision, new_cr_revision) 360 deps_content = deps_content.replace(old_cr_revision, new_cr_revision)
364 with open(deps_filename, 'wb') as deps_file: 361 with open(deps_filename, 'wb') as deps_file:
365 deps_file.write(deps_content) 362 deps_file.write(deps_content)
366 363
367 # Update each individual DEPS entry. 364 # Update each individual DEPS entry.
368 for dep in changed_deps: 365 for dep in changed_deps:
366 local_dep_dir = os.path.join(CHECKOUT_ROOT_DIR, dep.path)
367 if not os.path.isdir(local_dep_dir):
368 raise RollError(
369 'Cannot find local directory %s. Either run\n'
370 'gclient sync --deps=all\n'
371 'or make sure the .gclient file for your solution contains all '
372 'platforms in the target_os list, i.e.\n'
373 'target_os = ["android", "unix", "mac", "ios", "win"];\n'
374 'Then run "gclient sync" again.' % local_dep_dir)
369 _, stderr = _RunCommand( 375 _, stderr = _RunCommand(
370 ['roll-dep-svn', '--no-verify-revision', dep.path, dep.new_rev], 376 ['roll-dep-svn', '--no-verify-revision', dep.path, dep.new_rev],
371 working_dir=CHECKOUT_SRC_DIR, ignore_exit_code=True) 377 working_dir=CHECKOUT_SRC_DIR, ignore_exit_code=True)
372 if stderr: 378 if stderr:
373 logging.warning('roll-dep-svn: %s', stderr) 379 logging.warning('roll-dep-svn: %s', stderr)
374 380
375 381
376 def _IsTreeClean(): 382 def _IsTreeClean():
377 stdout, _ = _RunCommand(['git', 'status', '--porcelain']) 383 stdout, _ = _RunCommand(['git', 'status', '--porcelain'])
378 if len(stdout) == 0: 384 if len(stdout) == 0:
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 _CreateRollBranch(opts.dry_run) 507 _CreateRollBranch(opts.dry_run)
502 UpdateDepsFile(deps_filename, current_cr_rev, new_cr_rev, changed_deps) 508 UpdateDepsFile(deps_filename, current_cr_rev, new_cr_rev, changed_deps)
503 _LocalCommit(commit_msg, opts.dry_run) 509 _LocalCommit(commit_msg, opts.dry_run)
504 _UploadCL(opts.dry_run, opts.rietveld_email) 510 _UploadCL(opts.dry_run, opts.rietveld_email)
505 _SendToCQ(opts.dry_run, opts.skip_cq) 511 _SendToCQ(opts.dry_run, opts.skip_cq)
506 return 0 512 return 0
507 513
508 514
509 if __name__ == '__main__': 515 if __name__ == '__main__':
510 sys.exit(main()) 516 sys.exit(main())
OLDNEW
« DEPS ('K') | « sync_chromium.py ('k') | tools-webrtc/autoroller/unittests/testdata/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698