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

Side by Side Diff: tools/dom/scripts/idlsync.py

Issue 18855009: Update idlsync.py to work with chrome generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/chromegenerator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 The current version corresponds to: 43 The current version corresponds to:
44 URL: %(url)s 44 URL: %(url)s
45 Current revision: %(revision)s 45 Current revision: %(revision)s
46 """ 46 """
47 47
48 # Chrome info. 48 # Chrome info.
49 CHROME_URL_PATTERN = r'"chromium_url": "(\S+)",' 49 CHROME_URL_PATTERN = r'"chromium_url": "(\S+)",'
50 CHROME_REV_PATTERN = r'"chromium_revision": "(\d+)",' 50 CHROME_REV_PATTERN = r'"chromium_revision": "(\d+)",'
51 CHROME_IDL_SUBPATH = 'trunk/src/chrome/common/extensions/api' 51 CHROME_IDL_SUBPATH = 'trunk/src/chrome/common/extensions/api'
52 CHROME_TOOLS_SUBPATH = 'trunk/src/tools' 52 CHROME_COMMENT_EATER_SUBPATH = 'trunk/src/tools/json_comment_eater'
53 CHROME_COMPILER_SUBPATH = 'trunk/src/tools/json_schema_compiler' 53 CHROME_COMPILER_SUBPATH = 'trunk/src/tools/json_schema_compiler'
54 CHROME_IDL_PARSER_SUBPATH = 'trunk/src/ppapi/generators' 54 CHROME_IDL_PARSER_SUBPATH = 'trunk/src/ppapi/generators'
55 CHROME_PLY_SUBPATH = 'trunk/src/third_party/ply' 55 CHROME_PLY_SUBPATH = 'trunk/src/third_party/ply'
56 LOCAL_CHROME_IDL_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 'idl') 56 LOCAL_CHROME_IDL_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 'idl')
57 LOCAL_CHROME_TOOLS_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 57 LOCAL_CHROME_COMMENT_EATER_PATH = os.path.join(
58 'tools') 58 DART_PATH, 'third_party', 'chrome', 'tools', 'json_comment_eater')
59 LOCAL_CHROME_COMPILER_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 59 LOCAL_CHROME_COMPILER_PATH = os.path.join(DART_PATH, 'third_party', 'chrome',
60 'tools', 'json_schema_compiler') 60 'tools', 'json_schema_compiler')
61 LOCAL_CHROME_IDL_PARSER_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 61 LOCAL_CHROME_IDL_PARSER_PATH = os.path.join(DART_PATH, 'third_party', 'chrome',
62 'ppapi', 'generators') 62 'ppapi', 'generators')
63 LOCAL_CHROME_PLY_PATH = os.path.join(DART_PATH, 'third_party', 'chrome', 63 LOCAL_CHROME_PLY_PATH = os.path.join(DART_PATH, 'third_party', 'chrome',
64 'third_party', 'ply') 64 'third_party', 'ply')
65 LOCAL_CHROME_README = """\ 65 LOCAL_CHROME_README = """\
66 This directory contains a copy of Chromium IDL and generation scripts 66 This directory contains a copy of Chromium IDL and generation scripts
67 used to generate Dart APIs for Chrome Apps. 67 used to generate Dart APIs for Chrome Apps.
68 68
(...skipping 27 matching lines...) Expand all
96 # Chrome IDL. 96 # Chrome IDL.
97 ('chrome', CHROME_IDL_SUBPATH, LOCAL_CHROME_IDL_PATH, LOCAL_CHROME_README, 97 ('chrome', CHROME_IDL_SUBPATH, LOCAL_CHROME_IDL_PATH, LOCAL_CHROME_README,
98 DEPTH_INFINITY), 98 DEPTH_INFINITY),
99 # Chrome PPAPI generators. Contains idl_parser.py which is used by the 99 # Chrome PPAPI generators. Contains idl_parser.py which is used by the
100 # Chrome IDL compiler. 100 # Chrome IDL compiler.
101 ('chrome', CHROME_IDL_PARSER_SUBPATH, LOCAL_CHROME_IDL_PARSER_PATH, 101 ('chrome', CHROME_IDL_PARSER_SUBPATH, LOCAL_CHROME_IDL_PARSER_PATH,
102 LOCAL_CHROME_README, DEPTH_FILES), 102 LOCAL_CHROME_README, DEPTH_FILES),
103 # ply files. 103 # ply files.
104 ('chrome', CHROME_PLY_SUBPATH, LOCAL_CHROME_PLY_PATH, LOCAL_CHROME_README, 104 ('chrome', CHROME_PLY_SUBPATH, LOCAL_CHROME_PLY_PATH, LOCAL_CHROME_README,
105 DEPTH_INFINITY), 105 DEPTH_INFINITY),
106 # Top level Chrome tools folder. Contains json_comment_eater.py which is 106 # Path for json_comment_eater, which is needed by the Chrome IDL compiler.
107 # needed by the Chrome IDL compiler. 107 ('chrome', CHROME_COMMENT_EATER_SUBPATH, LOCAL_CHROME_COMMENT_EATER_PATH,
108 ('chrome', CHROME_TOOLS_SUBPATH, LOCAL_CHROME_TOOLS_PATH,
109 LOCAL_CHROME_README, DEPTH_FILES), 108 LOCAL_CHROME_README, DEPTH_FILES),
110 # Chrome IDL compiler files. 109 # Chrome IDL compiler files.
111 ('chrome', CHROME_COMPILER_SUBPATH, LOCAL_CHROME_COMPILER_PATH, 110 ('chrome', CHROME_COMPILER_SUBPATH, LOCAL_CHROME_COMPILER_PATH,
112 LOCAL_CHROME_README, DEPTH_INFINITY), 111 LOCAL_CHROME_README, DEPTH_INFINITY),
113 ] 112 ]
114 113
115 114
116 def RunCommand(cmd): 115 def RunCommand(cmd, valid_exits=[0]):
117 """Executes a shell command and return its stdout.""" 116 """Executes a shell command and return its stdout."""
118 print ' '.join(cmd) 117 print ' '.join(cmd)
119 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 118 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
120 output = pipe.communicate() 119 output = pipe.communicate()
121 if pipe.returncode == 0: 120 if pipe.returncode in valid_exits:
122 return output[0] 121 return output[0]
123 else: 122 else:
124 print output[1] 123 print output[1]
125 print 'FAILED. RET_CODE=%d' % pipe.returncode 124 print 'FAILED. RET_CODE=%d' % pipe.returncode
126 sys.exit(pipe.returncode) 125 sys.exit(pipe.returncode)
127 126
128 127
129 def GetDeps(): 128 def GetDeps():
130 """Returns the DEPS file contents with pinned revision info.""" 129 """Returns the DEPS file contents with pinned revision info."""
131 return RunCommand(['svn', 'cat', DEPS]) 130 return RunCommand(['svn', 'cat', DEPS])
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 'revision': revision } 176 'revision': revision }
178 177
179 readme_path = os.path.join(local_path, 'README') 178 readme_path = os.path.join(local_path, 'README')
180 out = open(readme_path, 'w') 179 out = open(readme_path, 'w')
181 out.write(readme) 180 out.write(readme)
182 out.close() 181 out.close()
183 182
184 ZIP_ARCHIVE = 'version-control-dirs.zip' 183 ZIP_ARCHIVE = 'version-control-dirs.zip'
185 184
186 def SaveVersionControlDir(local_path): 185 def SaveVersionControlDir(local_path):
187 RunCommand([ 186 if os.path.exists(local_path):
188 'sh', '-c', 187 RunCommand([
189 'find %s -name .svn -or -name .git | zip -r %s -@' % ( 188 'sh', '-c',
190 os.path.relpath(local_path), ZIP_ARCHIVE) 189 'find %s -name .svn -or -name .git | zip -r %s -@' % (
191 ]) 190 os.path.relpath(local_path), ZIP_ARCHIVE)
191 ], [0, 12]) # It is ok if zip has nothing to do (exit code 12).
192 192
193 193 def RestoreVersionControlDir(local_path):
194 def RestoreVersionControlDir(): 194 archive_path = os.path.join(local_path, ZIP_ARCHIVE)
195 RunCommand(['unzip', ZIP_ARCHIVE, '-d', '.']) 195 if os.path.exists(archive_path):
196 RunCommand(['rm', ZIP_ARCHIVE]) 196 RunCommand(['unzip', ZIP_ARCHIVE, '-d', '.'])
197 RunCommand(['rm', ZIP_ARCHIVE])
197 198
198 def ParseOptions(): 199 def ParseOptions():
199 parser = optparse.OptionParser() 200 parser = optparse.OptionParser()
200 parser.add_option('--webkit-revision', '-w', dest='webkit_revision', 201 parser.add_option('--webkit-revision', '-w', dest='webkit_revision',
201 help='WebKit IDL revision to install', default=None) 202 help='WebKit IDL revision to install', default=None)
202 parser.add_option('--chrome-revision', '-c', dest='chrome_revision', 203 parser.add_option('--chrome-revision', '-c', dest='chrome_revision',
203 help='Chrome IDL revision to install', default=None) 204 help='Chrome IDL revision to install', default=None)
204 parser.add_option('--update', '-u', dest='update', 205 parser.add_option('--update', '-u', dest='update',
205 help='IDL to update (webkit | chrome | all)', 206 help='IDL to update (webkit | chrome | all)',
206 default='webkit') 207 default='webkit')
(...skipping 12 matching lines...) Expand all
219 for (component, remote_path, local_path, readme, depth) in UPDATE_LIST: 220 for (component, remote_path, local_path, readme, depth) in UPDATE_LIST:
220 if component in update.keys(): 221 if component in update.keys():
221 revision = update[component] 222 revision = update[component]
222 url, latest = GetSvnRevision(deps, component) 223 url, latest = GetSvnRevision(deps, component)
223 if revision is None: 224 if revision is None:
224 revision = latest 225 revision = latest
225 SaveVersionControlDir(local_path); 226 SaveVersionControlDir(local_path);
226 RefreshFiles(url, revision, remote_path, local_path, depth) 227 RefreshFiles(url, revision, remote_path, local_path, depth)
227 PruneExtraFiles(local_path) 228 PruneExtraFiles(local_path)
228 GenerateReadme(local_path, readme, url, revision) 229 GenerateReadme(local_path, readme, url, revision)
229 RestoreVersionControlDir(); 230 RestoreVersionControlDir(local_path);
230 231
231 if __name__ == '__main__': 232 if __name__ == '__main__':
232 main() 233 main()
OLDNEW
« no previous file with comments | « tools/dom/scripts/chromegenerator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698