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

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

Issue 9958151: Update script to fetch new WebCore IDL (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add WebCore IDL for r313 (which matches the generated code). Created 8 years, 8 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 | « no previous file | third_party/WebCore/LICENSE-APPLE » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # BSD-style license that can be found in the LICENSE file.
5
6 import optparse
7 import os
8 import os.path
9 import re
10 import shutil
11 import subprocess
12 import sys
13
14 SCRIPT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__)))
sra1 2012/04/04 20:17:58 What are you join-ing here? Seems like a no-op.
vsm 2012/04/04 20:26:33 Done.
15 DART_PATH = os.path.abspath(os.path.join(SCRIPT_PATH, '..', '..', '..'))
16
17 # Path to install latest IDL.
18 IDL_PATH = os.path.join(DART_PATH, 'third_party', 'WebCore')
19
20 # Whitelist of files to keep.
21 WHITELIST = [
22 r'LICENSE(\S+)',
23 r'(\S+)\.idl']
24
25 # README file to generate.
26 README = os.path.join(IDL_PATH, 'README')
27
28 # SVN URL to latest Dartium version of WebKit.
29 DEPS = 'http://dart.googlecode.com/svn/branches/bleeding_edge/deps/dartium.deps/ DEPS'
30 URL_PATTERN = r'"dartium_webkit_trunk": "(\S+)",'
31 REV_PATTERN = r'"dartium_webkit_revision": "(\d+)",'
32 WEBCORE_SUBPATH = 'Source/WebCore'
33
34
35 def RunCommand(cmd):
36 """Executes a shell command and return its stdout."""
37 print ' '.join(cmd)
38 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
39 output = pipe.communicate()
40 if pipe.returncode == 0:
41 return output[0]
42 else:
43 print output[1]
44 print 'FAILED. RET_CODE=%d' % pipe.returncode
45 sys.exit(pipe.returncode)
46
47
48 def GetWebkitSvnRevision():
49 """Returns a tuple with the (dartium webkit repo, latest revision)."""
50 deps = RunCommand(['svn', 'cat', DEPS])
51 url = re.search(URL_PATTERN, deps).group(1)
52 revision = re.search(REV_PATTERN, deps).group(1)
53 return (url, revision)
54
55
56 def RefreshIDL(url, revision):
57 """Refreshes the IDL to specific WebKit url / revision."""
58 cwd = os.getcwd()
59 try:
60 shutil.rmtree(IDL_PATH)
61 os.chdir(os.path.dirname(IDL_PATH))
62 RunCommand(['svn', 'export', '-r', revision, url + '/' + WEBCORE_SUBPATH])
63 finally:
64 os.chdir(cwd)
65
66
67 def PruneExtraFiles():
68 """Removes all files that do not match the whitelist."""
69 pattern = re.compile(reduce(lambda x,y: '%s|%s' % (x,y),
70 map(lambda z: '(%s)' % z, WHITELIST)))
71 for (root, dirs, files) in os.walk(IDL_PATH, topdown=False):
72 for f in files:
73 if not pattern.match(f):
74 os.remove(os.path.join(root, f))
75 for d in dirs:
76 dirpath = os.path.join(root, d)
77 if not os.listdir(dirpath):
78 shutil.rmtree(dirpath)
79
80
81 def ParseOptions():
82 parser = optparse.OptionParser()
83 parser.add_option('--revision', '-r', dest='revision',
84 help='Revision to install', default=None)
85 args, _ = parser.parse_args()
86 return args.revision
87
88
89 def GenerateReadme(url, revision):
90 readme = """This directory contains a copy of WebKit/WebCore IDL files.
91 See the attached LICENSE-* files in this directory.
92
93 Please do not modify the files here. They are periodically copied
94 using the script: $DART_ROOT/lib/dom/scripts/%s
95
96 The current version corresponds to:
97 URL: %s
98 Current revision: %s
99 """ % (os.path.basename(__file__), url, revision)
sra1 2012/04/04 20:17:58 No need to change this but FYI you can use named f
100 out = open(README, 'w')
101 out.write(readme)
102 out.close()
103
104
105 def main():
106 revision = ParseOptions()
107 url, latest = GetWebkitSvnRevision()
108 if not revision:
109 revision = latest
110 RefreshIDL(url, revision)
111 PruneExtraFiles()
112 GenerateReadme(url, revision)
113
114
115 if __name__ == '__main__':
116 main()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebCore/LICENSE-APPLE » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698