| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import os.path | 8 import os.path |
| 9 import re | 9 import re |
| 10 import shutil | 10 import shutil |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 r'(\S+)\.idl', | 24 r'(\S+)\.idl', |
| 25 r'(\S+)\.json', | 25 r'(\S+)\.json', |
| 26 r'(\S+)\.py', | 26 r'(\S+)\.py', |
| 27 ] | 27 ] |
| 28 | 28 |
| 29 # WebKit / WebCore info. | 29 # WebKit / WebCore info. |
| 30 WEBKIT_URL_PATTERN = r'"dartium_webkit_trunk": "(\S+)",' | 30 WEBKIT_URL_PATTERN = r'"dartium_webkit_trunk": "(\S+)",' |
| 31 WEBKIT_REV_PATTERN = r'"dartium_webkit_revision": "(\d+)",' | 31 WEBKIT_REV_PATTERN = r'"dartium_webkit_revision": "(\d+)",' |
| 32 WEBCORE_SUBPATH = 'Source/WebCore' | 32 WEBCORE_SUBPATH = 'Source/WebCore' |
| 33 LOCAL_WEBKIT_IDL_PATH = os.path.join(DART_PATH, 'third_party', 'WebCore') | 33 LOCAL_WEBKIT_IDL_PATH = os.path.join(DART_PATH, 'third_party', 'WebCore') |
| 34 LOCAL_WEBKIT_README = os.path.join(LOCAL_WEBKIT_IDL_PATH, 'README') | |
| 35 LOCAL_WEBKIT_README = """\ | 34 LOCAL_WEBKIT_README = """\ |
| 36 This directory contains a copy of WebKit/WebCore IDL files. | 35 This directory contains a copy of WebKit/WebCore IDL files. |
| 37 See the attached LICENSE-* files in this directory. | 36 See the attached LICENSE-* files in this directory. |
| 38 | 37 |
| 39 Please do not modify the files here. They are periodically copied | 38 Please do not modify the files here. They are periodically copied |
| 40 using the script: $DART_ROOT/sdk/lib/html/scripts/%(script)s | 39 using the script: $DART_ROOT/sdk/lib/html/scripts/%(script)s |
| 41 | 40 |
| 42 The current version corresponds to: | 41 The current version corresponds to: |
| 43 URL: %(url)s | 42 URL: %(url)s |
| 44 Current revision: %(revision)s | 43 Current revision: %(revision)s |
| 45 """ | 44 """ |
| 46 | 45 |
| 47 # Chrome info. | 46 # Chrome info. |
| 48 CHROME_URL_PATTERN = r'"chromium_url": "(\S+)",' | 47 CHROME_URL_PATTERN = r'"chromium_url": "(\S+)",' |
| 49 CHROME_REV_PATTERN = r'"chromium_revision": "(\d+)",' | 48 CHROME_REV_PATTERN = r'"chromium_revision": "(\d+)",' |
| 50 CHROME_IDL_SUBPATH = 'trunk/src/chrome/common/extensions/api' | 49 CHROME_IDL_SUBPATH = 'trunk/src/chrome/common/extensions/api' |
| 51 CHROME_TOOLS_SUBPATH = 'trunk/src/tools/json_schema_compiler' | 50 CHROME_TOOLS_SUBPATH = 'trunk/src/tools' |
| 51 CHROME_COMPILER_SUBPATH = 'trunk/src/tools/json_schema_compiler' |
| 52 CHROME_IDL_PARSER_SUBPATH = 'trunk/src/ppapi/generators' |
| 53 CHROME_PLY_SUBPATH = 'trunk/src/third_party/ply' |
| 52 LOCAL_CHROME_IDL_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 'idl') | 54 LOCAL_CHROME_IDL_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 'idl') |
| 53 LOCAL_CHROME_TOOLS_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', | 55 LOCAL_CHROME_TOOLS_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', |
| 54 'tools') | 56 'tools') |
| 57 LOCAL_CHROME_COMPILER_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', |
| 58 'tools', 'json_schema_compiler') |
| 59 LOCAL_CHROME_IDL_PARSER_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', |
| 60 'ppapi', 'generators') |
| 61 LOCAL_CHROME_PLY_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', |
| 62 'third_party', 'ply') |
| 55 LOCAL_CHROME_README = """\ | 63 LOCAL_CHROME_README = """\ |
| 56 This directory contains a copy of Chromium IDL and generation scripts | 64 This directory contains a copy of Chromium IDL and generation scripts |
| 57 used to generate Dart APIs for Chrome Apps. | 65 used to generate Dart APIs for Chrome Apps. |
| 58 | 66 |
| 59 The original files are from: | 67 The original files are from: |
| 60 URL: %(url)s | 68 URL: %(url)s |
| 61 Current revision: %(revision)s | 69 Current revision: %(revision)s |
| 62 | 70 |
| 63 Please see the corresponding LICENSE file at | 71 Please see the corresponding LICENSE file at |
| 64 %(url)s/trunk/src/LICENSE. | 72 %(url)s/trunk/src/LICENSE. |
| 65 """ | 73 """ |
| 74 DEPTH_FILES = 'files' |
| 75 DEPTH_INFINITY = 'infinity' |
| 66 | 76 |
| 67 # Regular expressions corresponding to URL/revision patters in the | 77 # Regular expressions corresponding to URL/revision patters in the |
| 68 # DEPS file. | 78 # DEPS file. |
| 69 DEPS_PATTERNS = { | 79 DEPS_PATTERNS = { |
| 70 'webkit': (WEBKIT_URL_PATTERN, WEBKIT_REV_PATTERN), | 80 'webkit': (WEBKIT_URL_PATTERN, WEBKIT_REV_PATTERN), |
| 71 'chrome': (CHROME_URL_PATTERN, CHROME_REV_PATTERN), | 81 'chrome': (CHROME_URL_PATTERN, CHROME_REV_PATTERN), |
| 72 } | 82 } |
| 73 | 83 |
| 74 # List of components to update. | 84 # List of components to update. |
| 75 UPDATE_LIST = [ | 85 UPDATE_LIST = [ |
| 76 # (component, remote subpath, local path, local readme file) | 86 # (component, remote subpath, local path, local readme file, depth) |
| 77 | 87 |
| 78 # WebKit IDL. | 88 # WebKit IDL. |
| 79 ('webkit', WEBCORE_SUBPATH, LOCAL_WEBKIT_IDL_PATH, LOCAL_WEBKIT_README), | 89 ('webkit', WEBCORE_SUBPATH, LOCAL_WEBKIT_IDL_PATH, LOCAL_WEBKIT_README, |
| 90 DEPTH_INFINITY), |
| 80 # Chrome IDL. | 91 # Chrome IDL. |
| 81 ('chrome', CHROME_IDL_SUBPATH, LOCAL_CHROME_IDL_PATH, LOCAL_CHROME_README), | 92 ('chrome', CHROME_IDL_SUBPATH, LOCAL_CHROME_IDL_PATH, LOCAL_CHROME_README, |
| 93 DEPTH_INFINITY), |
| 94 # Chrome PPAPI generators. Contains idl_parser.py which is used by the |
| 95 # Chrome IDL compiler. |
| 96 ('chrome', CHROME_IDL_PARSER_SUBPATH, LOCAL_CHROME_IDL_PARSER_PATH, |
| 97 LOCAL_CHROME_README, DEPTH_FILES), |
| 98 # ply files. |
| 99 ('chrome', CHROME_PLY_SUBPATH, LOCAL_CHROME_PLY_PATH, LOCAL_CHROME_README, |
| 100 DEPTH_INFINITY), |
| 101 # Top level Chrome tools folder. Contains json_comment_eater.py which is |
| 102 # needed by the Chrome IDL compiler. |
| 103 ('chrome', CHROME_TOOLS_SUBPATH, LOCAL_CHROME_TOOLS_PATH, |
| 104 LOCAL_CHROME_README, DEPTH_FILES), |
| 82 # Chrome IDL compiler files. | 105 # Chrome IDL compiler files. |
| 83 ('chrome', CHROME_TOOLS_SUBPATH, LOCAL_CHROME_TOOLS_PATH, | 106 ('chrome', CHROME_COMPILER_SUBPATH, LOCAL_CHROME_COMPILER_PATH, |
| 84 LOCAL_CHROME_README), | 107 LOCAL_CHROME_README, DEPTH_INFINITY), |
| 85 ] | 108 ] |
| 86 | 109 |
| 87 | 110 |
| 88 def RunCommand(cmd): | 111 def RunCommand(cmd): |
| 89 """Executes a shell command and return its stdout.""" | 112 """Executes a shell command and return its stdout.""" |
| 90 print ' '.join(cmd) | 113 print ' '.join(cmd) |
| 91 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 114 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 92 output = pipe.communicate() | 115 output = pipe.communicate() |
| 93 if pipe.returncode == 0: | 116 if pipe.returncode == 0: |
| 94 return output[0] | 117 return output[0] |
| 95 else: | 118 else: |
| 96 print output[1] | 119 print output[1] |
| 97 print 'FAILED. RET_CODE=%d' % pipe.returncode | 120 print 'FAILED. RET_CODE=%d' % pipe.returncode |
| 98 sys.exit(pipe.returncode) | 121 sys.exit(pipe.returncode) |
| 99 | 122 |
| 100 | 123 |
| 101 def GetDeps(): | 124 def GetDeps(): |
| 102 """Returns the DEPS file contents with pinned revision info.""" | 125 """Returns the DEPS file contents with pinned revision info.""" |
| 103 return RunCommand(['svn', 'cat', DEPS]) | 126 return RunCommand(['svn', 'cat', DEPS]) |
| 104 | 127 |
| 105 | 128 |
| 106 def GetSvnRevision(deps, component): | 129 def GetSvnRevision(deps, component): |
| 107 """Returns a tuple with the (dartium webkit repo, latest revision).""" | 130 """Returns a tuple with the (dartium webkit repo, latest revision).""" |
| 108 url_pattern, rev_pattern = DEPS_PATTERNS[component] | 131 url_pattern, rev_pattern = DEPS_PATTERNS[component] |
| 109 url = re.search(url_pattern, deps).group(1) | 132 url = re.search(url_pattern, deps).group(1) |
| 110 revision = re.search(rev_pattern, deps).group(1) | 133 revision = re.search(rev_pattern, deps).group(1) |
| 111 return (url, revision) | 134 return (url, revision) |
| 112 | 135 |
| 113 | 136 |
| 114 def RefreshIDL(url, revision, remote_path, local_path): | 137 def RefreshFiles(url, revision, remote_path, local_path, depth): |
| 115 """Refreshes refreshes files in the local_path to specific url / | 138 """Refreshes refreshes files in the local_path to specific url / |
| 116 revision / remote_path.""" | 139 revision / remote_path, exporting to depth""" |
| 117 cwd = os.getcwd() | 140 cwd = os.getcwd() |
| 118 try: | 141 try: |
| 119 if os.path.exists(local_path): | 142 if os.path.exists(local_path): |
| 120 shutil.rmtree(local_path) | 143 shutil.rmtree(local_path) |
| 121 head, tail = os.path.split(local_path) | 144 head, tail = os.path.split(local_path) |
| 122 if not os.path.exists(head): | 145 if not os.path.exists(head): |
| 123 os.makedirs(head) | 146 os.makedirs(head) |
| 124 os.chdir(head) | 147 os.chdir(head) |
| 125 RunCommand(['svn', 'export', '-r', revision, url + '/' + remote_path, tail]) | 148 RunCommand(['svn', 'export', '--depth', depth, '-r', revision, |
| 149 url + '/' + remote_path, tail]) |
| 126 finally: | 150 finally: |
| 127 os.chdir(cwd) | 151 os.chdir(cwd) |
| 128 | 152 |
| 129 | 153 |
| 130 def PruneExtraFiles(local_path): | 154 def PruneExtraFiles(local_path): |
| 131 """Removes all files that do not match the whitelist.""" | 155 """Removes all files that do not match the whitelist.""" |
| 132 pattern = re.compile(reduce(lambda x,y: '%s|%s' % (x,y), | 156 pattern = re.compile(reduce(lambda x,y: '%s|%s' % (x,y), |
| 133 map(lambda z: '(%s)' % z, WHITELIST))) | 157 map(lambda z: '(%s)' % z, WHITELIST))) |
| 134 for (root, dirs, files) in os.walk(local_path, topdown=False): | 158 for (root, dirs, files) in os.walk(local_path, topdown=False): |
| 135 for f in files: | 159 for f in files: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if args.update == 'all' or args.update == 'chrome': | 191 if args.update == 'all' or args.update == 'chrome': |
| 168 update['chrome'] = args.chrome_revision | 192 update['chrome'] = args.chrome_revision |
| 169 if args.update == 'all' or args.update == 'webkit': | 193 if args.update == 'all' or args.update == 'webkit': |
| 170 update['webkit'] = args.webkit_revision | 194 update['webkit'] = args.webkit_revision |
| 171 return update | 195 return update |
| 172 | 196 |
| 173 | 197 |
| 174 def main(): | 198 def main(): |
| 175 deps = GetDeps() | 199 deps = GetDeps() |
| 176 update = ParseOptions() | 200 update = ParseOptions() |
| 177 for (component, remote_path, local_path, readme) in UPDATE_LIST: | 201 for (component, remote_path, local_path, readme, depth) in UPDATE_LIST: |
| 178 if component in update.keys(): | 202 if component in update.keys(): |
| 179 revision = update[component] | 203 revision = update[component] |
| 180 url, latest = GetSvnRevision(deps, component) | 204 url, latest = GetSvnRevision(deps, component) |
| 181 if revision is None: | 205 if revision is None: |
| 182 revision = latest | 206 revision = latest |
| 183 RefreshIDL(url, revision, remote_path, local_path) | 207 RefreshFiles(url, revision, remote_path, local_path, depth) |
| 184 PruneExtraFiles(local_path) | 208 PruneExtraFiles(local_path) |
| 185 GenerateReadme(local_path, readme, url, revision) | 209 GenerateReadme(local_path, readme, url, revision) |
| 186 | 210 |
| 187 | 211 |
| 188 if __name__ == '__main__': | 212 if __name__ == '__main__': |
| 189 main() | 213 main() |
| OLD | NEW |