Chromium Code Reviews

Side by Side Diff: tools/create_sdk.py

Issue 13966011: Put a snapshot of pub in the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/test/test_pub.dart ('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/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 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. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 # A script which will be invoked from gyp to create an SDK. 7 # A script which will be invoked from gyp to create an SDK.
8 # 8 #
9 # Usage: create_sdk.py sdk_directory 9 # Usage: create_sdk.py sdk_directory
10 # 10 #
11 # The SDK will be used either from the command-line or from the editor. 11 # The SDK will be used either from the command-line or from the editor.
12 # Top structure is 12 # Top structure is
13 # 13 #
14 # ..dart-sdk/ 14 # ..dart-sdk/
15 # ....bin/ 15 # ....bin/
16 # ......dart or dart.exe (executable) 16 # ......dart or dart.exe (executable)
17 # ......dart.lib (import library for VM native extensions on Windows) 17 # ......dart.lib (import library for VM native extensions on Windows)
18 # ......dart2js 18 # ......dart2js
19 # ......dart_analyzer 19 # ......dart_analyzer
20 # ......pub 20 # ......pub
21 # ......snapshots/ 21 # ......snapshots/
22 # ........utils_wrapper.dart.snapshot 22 # ........utils_wrapper.dart.snapshot
23 # ........pub.dart.snapshot
23 # ....include/ 24 # ....include/
24 # ......dart_api.h 25 # ......dart_api.h
25 # ......dart_debugger_api.h 26 # ......dart_debugger_api.h
26 # ....lib/ 27 # ....lib/
27 # ......_internal/ 28 # ......_internal/
28 # ......async/ 29 # ......async/
29 # ......collection/ 30 # ......collection/
30 # ......_collection_dev/ 31 # ......_collection_dev/
31 # ......core/ 32 # ......core/
32 # ......crypto/ 33 # ......crypto/
(...skipping 38 matching lines...)
71 from os.path import basename, dirname, join, realpath, exists, isdir 72 from os.path import basename, dirname, join, realpath, exists, isdir
72 73
73 # TODO(dgrove): Only import modules following Google style guide. 74 # TODO(dgrove): Only import modules following Google style guide.
74 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move 75 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
75 76
76 77
77 def GetOptions(): 78 def GetOptions():
78 options = optparse.OptionParser(usage='usage: %prog [options]') 79 options = optparse.OptionParser(usage='usage: %prog [options]')
79 options.add_option("--sdk_output_dir", 80 options.add_option("--sdk_output_dir",
80 help='Where to output the sdk') 81 help='Where to output the sdk')
81 options.add_option("--utils_snapshot_location", 82 options.add_option("--snapshot_location",
82 help='Location of the utils snapshot.') 83 help='Location of the snapshots.')
83 return options.parse_args() 84 return options.parse_args()
84 85
85 86
86 def ReplaceInFiles(paths, subs): 87 def ReplaceInFiles(paths, subs):
87 '''Reads a series of files, applies a series of substitutions to each, and 88 '''Reads a series of files, applies a series of substitutions to each, and
88 saves them back out. subs should by a list of (pattern, replace) tuples.''' 89 saves them back out. subs should by a list of (pattern, replace) tuples.'''
89 for path in paths: 90 for path in paths:
90 contents = open(path).read() 91 contents = open(path).read()
91 for pattern, replace in subs: 92 for pattern, replace in subs:
92 contents = re.sub(pattern, replace, contents) 93 contents = re.sub(pattern, replace, contents)
(...skipping 19 matching lines...)
112 dest = join(dest_dir, basename(src_file) + file_extension) 113 dest = join(dest_dir, basename(src_file) + file_extension)
113 Copy(src, dest) 114 Copy(src, dest)
114 115
115 116
116 def CopyDartScripts(home, sdk_root): 117 def CopyDartScripts(home, sdk_root):
117 for executable in ['dart2js', 'dartanalyzer', 'dartdoc', 'pub']: 118 for executable in ['dart2js', 'dartanalyzer', 'dartdoc', 'pub']:
118 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), 119 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable),
119 os.path.join(sdk_root, 'bin')) 120 os.path.join(sdk_root, 'bin'))
120 121
121 122
122 def CopySnapshots(snapshot, sdk_root): 123 def CopySnapshots(snapshots, sdk_root):
123 copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot))) 124 for snapshot in ['utils_wrapper', 'pub']:
125 snapshot += '.dart.snapshot'
126 copyfile(join(snapshots, snapshot),
127 join(sdk_root, 'bin', 'snapshots', snapshot))
124 128
125 129
126 def Main(argv): 130 def Main(argv):
127 # Pull in all of the gypi files which will be munged into the sdk. 131 # Pull in all of the gypi files which will be munged into the sdk.
128 HOME = dirname(dirname(realpath(__file__))) 132 HOME = dirname(dirname(realpath(__file__)))
129 133
130 (options, args) = GetOptions() 134 (options, args) = GetOptions()
131 135
132 SDK = options.sdk_output_dir 136 SDK = options.sdk_output_dir
133 SDK_tmp = '%s.tmp' % SDK 137 SDK_tmp = '%s.tmp' % SDK
134 138
135 SNAPSHOT = options.utils_snapshot_location 139 SNAPSHOT = options.snapshot_location
136 140
137 # TODO(dgrove) - deal with architectures that are not ia32. 141 # TODO(dgrove) - deal with architectures that are not ia32.
138 142
139 if exists(SDK): 143 if exists(SDK):
140 rmtree(SDK) 144 rmtree(SDK)
141 145
142 if exists(SDK_tmp): 146 if exists(SDK_tmp):
143 rmtree(SDK_tmp) 147 rmtree(SDK_tmp)
144 148
145 os.makedirs(SDK_tmp) 149 os.makedirs(SDK_tmp)
(...skipping 52 matching lines...)
198 202
199 LIB = join(SDK_tmp, 'lib') 203 LIB = join(SDK_tmp, 'lib')
200 os.makedirs(LIB) 204 os.makedirs(LIB)
201 205
202 # 206 #
203 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. 207 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}.
204 # 208 #
205 209
206 os.makedirs(join(LIB, 'html')) 210 os.makedirs(join(LIB, 'html'))
207 211
208 for library in ['_internal', 212 for library in [join('_internal', 'compiler'), join('_internal', 'dartdoc'),
Bob Nystrom 2013/04/24 16:31:36 Nit, but I would put each join() on its own line.
nweiz 2013/04/24 20:00:46 Done.
nweiz 2013/04/24 20:00:46 Done.
213 join('_internal', 'pub', 'resource'),
209 'async', 'collection', '_collection_dev', 'core', 214 'async', 'collection', '_collection_dev', 'core',
210 'crypto', 'io', 'isolate', 215 'crypto', 'io', 'isolate',
211 join('chrome', 'dart2js'), join('chrome', 'dartium'), 216 join('chrome', 'dart2js'), join('chrome', 'dartium'),
212 join('html', 'dart2js'), join('html', 'dartium'), 217 join('html', 'dart2js'), join('html', 'dartium'),
213 join('html', 'html_common'), 218 join('html', 'html_common'),
214 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), 219 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'),
215 'json', 'math', 'mirrors', 'typed_data', 220 'json', 'math', 'mirrors', 'typed_data',
216 join('svg', 'dart2js'), join('svg', 'dartium'), 221 join('svg', 'dart2js'), join('svg', 'dartium'),
217 'uri', 'utf', 222 'uri', 'utf',
218 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), 223 join('web_audio', 'dart2js'), join('web_audio', 'dartium'),
219 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), 224 join('web_gl', 'dart2js'), join('web_gl', 'dartium'),
220 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: 225 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]:
221 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), 226 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library),
222 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) 227 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh',
228 '.gitignore'))
229
230 # Copy lib/_internal/libraries.dart.
231 copyfile(join(HOME, 'sdk', 'lib', '_internal', 'libraries.dart'),
232 join(LIB, '_internal', 'libraries.dart'))
Bob Nystrom 2013/04/24 16:31:36 What's this about? Is this related to the pub chan
nweiz 2013/04/24 20:00:46 The for loop above used to put everything under _i
223 233
224 # Create and copy packages. 234 # Create and copy packages.
225 PACKAGES = join(SDK_tmp, 'packages') 235 PACKAGES = join(SDK_tmp, 'packages')
226 os.makedirs(PACKAGES) 236 os.makedirs(PACKAGES)
227 237
228 # 238 #
229 # Create and populate packages/{args, intl, logging, meta, unittest, ...} 239 # Create and populate packages/{args, intl, logging, meta, unittest, ...}
230 # 240 #
231 241
232 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', 242 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos',
(...skipping 28 matching lines...)
261 # Create and copy dartanalyzer into 'util' 271 # Create and copy dartanalyzer into 'util'
262 DARTANALYZER_SRC = join(HOME, build_dir, 'dartanalyzer') 272 DARTANALYZER_SRC = join(HOME, build_dir, 'dartanalyzer')
263 DARTANALYZER_DEST = join(UTIL, 'dartanalyzer') 273 DARTANALYZER_DEST = join(UTIL, 'dartanalyzer')
264 os.makedirs(DARTANALYZER_DEST) 274 os.makedirs(DARTANALYZER_DEST)
265 275
266 jarFiles = glob.glob(join(DARTANALYZER_SRC, '*.jar')) 276 jarFiles = glob.glob(join(DARTANALYZER_SRC, '*.jar'))
267 277
268 for jarFile in jarFiles: 278 for jarFile in jarFiles:
269 copyfile(jarFile, join(DARTANALYZER_DEST, os.path.basename(jarFile))) 279 copyfile(jarFile, join(DARTANALYZER_DEST, os.path.basename(jarFile)))
270 280
271 PUB_DEST = join(SDK_tmp, 'lib', '_internal', 'pub')
272
273
274 # Copy in 7zip for Windows. 281 # Copy in 7zip for Windows.
275 if HOST_OS == 'win32': 282 if HOST_OS == 'win32':
276 copytree(join(HOME, 'third_party', '7zip'), 283 copytree(join(HOME, 'third_party', '7zip'),
277 join(PUB_DEST, 'resource', '7zip'), 284 join(SDK_tmp, 'lib', '_internal', 'pub', 'resource', '7zip'),
278 ignore=ignore_patterns('.svn')) 285 ignore=ignore_patterns('.svn'))
279 286
280 ReplaceInFiles([ 287 # Copy dart2js/dartdoc.
Bob Nystrom 2013/04/24 16:31:36 Update comment.
nweiz 2013/04/24 20:00:46 Done.
281 join(PUB_DEST, 'lib', 'src', 'io.dart'),
282 ], [
283 ("../../../../third_party/7zip/7za.exe",
284 "resource/7zip/7za.exe"),
285 ])
286
287 # Copy dart2js/dartdoc/pub.
288 CopyDartScripts(HOME, SDK_tmp) 288 CopyDartScripts(HOME, SDK_tmp)
289 CopySnapshots(SNAPSHOT, SDK_tmp) 289 CopySnapshots(SNAPSHOT, SDK_tmp)
290 290
291 # Write the 'version' file 291 # Write the 'version' file
292 version = utils.GetVersion() 292 version = utils.GetVersion()
293 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') 293 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w')
294 versionFile.write(version + '\n') 294 versionFile.write(version + '\n')
295 versionFile.close() 295 versionFile.close()
296 296
297 # Write the 'revision' file 297 # Write the 'revision' file
298 revision = utils.GetSVNRevision() 298 revision = utils.GetSVNRevision()
299 299
300 if revision is not None: 300 if revision is not None:
301 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 301 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
302 f.write(revision + '\n') 302 f.write(revision + '\n')
303 f.close() 303 f.close()
304 304
305 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) 305 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README'))
306 306
307 move(SDK_tmp, SDK) 307 move(SDK_tmp, SDK)
308 308
309 if __name__ == '__main__': 309 if __name__ == '__main__':
310 sys.exit(Main(sys.argv)) 310 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/test_pub.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine