| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 # | |
| 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 | |
| 7 # A script to fetch and build dartium branches into an empty directory. | |
| 8 # | |
| 9 # Main dev directories - src, src/third_party/WebKit, src/dart - are checked out | |
| 10 # via git. A custom_deps entry is added to the .gclient file. | |
| 11 # | |
| 12 # Note: this checkout is not suitable for git merges across branches | |
| 13 # (e.g., upstream merges). It's a shallow checkout without history. | |
| 14 # | |
| 15 # Usage: | |
| 16 # .../fetch_dartium.py --branch=[trunk|bleeding_edge|dartium_integration|1.4|...
] | |
| 17 # --path=path [--build] | |
| 18 # | |
| 19 # Default branch is bleeding_edge. The path must be created by this script. | |
| 20 | |
| 21 import optparse | |
| 22 import os | |
| 23 import os.path | |
| 24 import re | |
| 25 import shutil | |
| 26 import subprocess | |
| 27 import sys | |
| 28 | |
| 29 def Run(cmd, path = '.', isPiped = False): | |
| 30 print 'Running in ' + path + ': ' + ' '.join(cmd) | |
| 31 cwd = os.getcwd() | |
| 32 os.chdir(path) | |
| 33 if isPiped: | |
| 34 p = subprocess.Popen(cmd, stdout = subprocess.PIPE) | |
| 35 else: | |
| 36 p = subprocess.Popen(cmd) | |
| 37 os.chdir(cwd) | |
| 38 return p | |
| 39 | |
| 40 def RunSync(cmd): | |
| 41 print "\n[%s]\n$ %s" % (os.getcwd(), " ".join(cmd)) | |
| 42 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| 43 output = pipe.communicate() | |
| 44 if pipe.returncode == 0: | |
| 45 return output[0] | |
| 46 else: | |
| 47 print output[1] | |
| 48 print "FAILED. RET_CODE=%d" % pipe.returncode | |
| 49 sys.exit(pipe.returncode) | |
| 50 | |
| 51 | |
| 52 def main(): | |
| 53 option_parser = optparse.OptionParser() | |
| 54 option_parser.add_option('', '--branch', help="Checkout a branch of Dartium, e
.g., [bleeding_edge|dartium_integration|trunk|1.4]", | |
| 55 action="store", dest="branch", default="bleeding_edge
") | |
| 56 option_parser.add_option('', '--build', help="Compile", | |
| 57 action="store_true", dest="build") | |
| 58 option_parser.add_option('', '--path', help="Path to checkout to", | |
| 59 action="store", dest="path", default=None) | |
| 60 options, args = option_parser.parse_args() | |
| 61 | |
| 62 path = options.path | |
| 63 if not path: | |
| 64 print 'Please set a path' | |
| 65 exit(1) | |
| 66 path = os.path.expanduser(path) | |
| 67 if os.path.isfile(path) or os.path.isdir(path): | |
| 68 print 'Path %s already exists' % path | |
| 69 os.mkdir(path) | |
| 70 os.chdir(path) | |
| 71 | |
| 72 if options.branch != 'trunk': | |
| 73 branch = 'branches/' + options.branch | |
| 74 else: | |
| 75 branch = 'trunk' | |
| 76 deps_path = 'https://dart.googlecode.com/svn/%s/deps/dartium.deps' % branch | |
| 77 | |
| 78 Run(['gclient', 'config', deps_path]).wait() | |
| 79 | |
| 80 # Mark chrome, blink, and dart as custom. We'll check them out separately | |
| 81 # via git. | |
| 82 f = open('.gclient', 'r') | |
| 83 lines = f.readlines() | |
| 84 f.close() | |
| 85 f = open('.gclient', 'w') | |
| 86 for line in lines: | |
| 87 f.write(line) | |
| 88 if 'custom_deps' in line: | |
| 89 f.write( | |
| 90 ' "src": None,\n' | |
| 91 ' "src/third_party/WebKit": None,\n' | |
| 92 ' "src/dart": None,\n' | |
| 93 ) | |
| 94 f.close() | |
| 95 | |
| 96 # Find branches from the DEPS file. | |
| 97 DEPS = RunSync(['svn', 'cat', deps_path + '/DEPS']) | |
| 98 chrome_base = 'svn://svn.chromium.org/' | |
| 99 chrome_branch = re.search('dartium_chromium_branch":\s*"(.+)"', DEPS).group(1) | |
| 100 blink_branch = re.search('dartium_webkit_branch":\s*"(.+)"', DEPS).group(1) | |
| 101 dart_base = 'https://dart.googlecode.com/svn/' | |
| 102 dart_branch = re.search('dart_branch":\s*"(.+)"', DEPS).group(1) | |
| 103 | |
| 104 chrome_url = chrome_base + chrome_branch | |
| 105 blink_url = chrome_base + blink_branch | |
| 106 dart_url = dart_base + dart_branch + '/dart' | |
| 107 | |
| 108 # Fetch dart, chrome, and blink via git-svn and everything else via | |
| 109 # gclient sync. | |
| 110 blink_fetch = Run(['git', 'svn', 'clone', '-rHEAD', blink_url, 'blink']) | |
| 111 dart_fetch = Run(['git', 'svn', 'clone', '-rHEAD', dart_url, 'dart']) | |
| 112 Run(['git', 'svn', 'clone', '-rHEAD', chrome_url, 'src']).wait() | |
| 113 sync = Run(['gclient', 'sync', '--nohooks']) | |
| 114 ps = [blink_fetch, dart_fetch, sync] | |
| 115 | |
| 116 # Spin until everything is done. | |
| 117 while True: | |
| 118 ps_status = [p.poll() for p in ps] | |
| 119 if all([x is not None for x in ps_status]): | |
| 120 break | |
| 121 | |
| 122 # Move blink and dart to the right locations. | |
| 123 webkit_relative_path = os.path.join('src', 'third_party', 'WebKit') | |
| 124 if os.path.isdir(webkit_relative_path): | |
| 125 shutil.rmtree(webkit_relative_path) | |
| 126 Run(['mv', 'blink', webkit_relative_path]).wait() | |
| 127 dart_relative_path = os.path.join('src', 'dart') | |
| 128 if os.path.isdir(dart_relative_path): | |
| 129 shutil.rmtree(dart_relative_path) | |
| 130 Run(['mv', 'dart', dart_relative_path]).wait() | |
| 131 os.chdir('src') | |
| 132 | |
| 133 # Sync again and runhooks. | |
| 134 Run(['gclient', 'sync']).wait() | |
| 135 Run(['gclient', 'runhooks']).wait() | |
| 136 | |
| 137 # Build if requested. | |
| 138 if options.build: | |
| 139 Run([os.path.join('.', 'dart', 'tools', 'dartium', 'build.py'), '--mode=Rele
ase']) | |
| 140 | |
| 141 if '__main__' == __name__: | |
| 142 main() | |
| OLD | NEW |