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

Side by Side Diff: tools/create_sdk.py

Issue 10908038: Significant cleanup of create_sdk now that libraries have (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « lib/config/import_any.config ('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 # ....include/ 21 # ....include/
22 # ......dart_api.h 22 # ......dart_api.h
23 # ......dart_debugger_api.h 23 # ......dart_debugger_api.h
24 # ....lib/ 24 # ....lib/
25 # ......builtin/ 25 # ......_internal/
26 # ........builtin_runtime.dart 26 # ......compiler/
27 # ......config/
28 # ......core/
29 # ......coreimpl/
30 # ......crypto/
31 # ......html/
27 # ......io/ 32 # ......io/
28 # ........io_runtime.dart
29 # ........runtime/
30 # ......compiler/
31 # ......core/
32 # ........core_runtime.dart
33 # ........runtime/
34 # ......coreimpl/
35 # ........coreimpl_runtime.dart
36 # ........runtime/
37 # ......dart2js/
38 # ......isolate/ 33 # ......isolate/
39 # ........isolate_{dart2js, runtime}.dart
40 # ........dart2js/
41 # ......dom/
42 # ........dom.dart
43 # ......html/
44 # ........html_dart2js.dart
45 # ........html_dartium.dart
46 # ......crypto/
47 # ........crypto.dart
48 # ........(implementation files)
49 # ......json/ 34 # ......json/
50 # ........json_frog.dart 35 # ......math/
51 #.........json.dart
52 # ........{frog}/
53 # ......mirrors/ 36 # ......mirrors/
54 # ........mirrors.dart
55 # ......uri/ 37 # ......uri/
56 # ........uri.dart
57 # ......utf/ 38 # ......utf/
58 # ......web/ 39 # ......web/
59 # ........web.dart
60 # ....pkg/ 40 # ....pkg/
61 # ......args/ 41 # ......args/
62 # ......dartdoc/ 42 # ......dartdoc/
63 # ......intl/ 43 # ......intl/
64 # ......logging/ 44 # ......logging/
45 # ......unittest/
65 # ......(more will come here) 46 # ......(more will come here)
66 # ....util/ 47 # ....util/
67 # ......analyzer/ 48 # ......analyzer/
68 # ........dart_analyzer.jar 49 # ........dart_analyzer.jar
69 # ........(third-party libraries for dart_analyzer) 50 # ........(third-party libraries for dart_analyzer)
70 # ......pub/ 51 # ......pub/
71 # ......(more will come here) 52 # ......(more will come here)
72 53
73 54
74 55
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 file_extension = '' 95 file_extension = ''
115 if utils.GuessOS() == 'win32': 96 if utils.GuessOS() == 'win32':
116 file_extension = '.bat' 97 file_extension = '.bat'
117 98
118 src = src_file + file_extension 99 src = src_file + file_extension
119 dest = join(dest_dir, basename(src_file) + file_extension) 100 dest = join(dest_dir, basename(src_file) + file_extension)
120 Copy(src, dest) 101 Copy(src, dest)
121 102
122 103
123 def CopyDart2Js(build_dir, sdk_root): 104 def CopyDart2Js(build_dir, sdk_root):
124 '''
125 Install dart2js in SDK/lib/dart2js.
126
127 Currently, we copy too much stuff to this location, but the SDK's
128 layout matches the the layout of the part of the repository we're
129 dealing with here which frees us from rewriting files. The long term
130 plan is to align the layout of the repository and the SDK, at which
131 point we should be able to simplify Main below and share the dart
132 files between the various components to minimize SDK download size.
133 '''
134 copytree('lib', os.path.join(sdk_root, 'lib', 'dart2js', 'lib'),
135 ignore=ignore_patterns('.svn'))
136 copytree(os.path.join('runtime', 'lib'),
137 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'lib'),
138 ignore=ignore_patterns('.svn'))
139 copytree(os.path.join('runtime', 'bin'),
140 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'bin'),
141 ignore=ignore_patterns('.svn'))
142 if utils.GuessOS() == 'win32': 105 if utils.GuessOS() == 'win32':
143 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') 106 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat')
144 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) 107 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js)
145 ReplaceInFiles([dart2js], 108 ReplaceInFiles([dart2js],
146 [(r'%SCRIPTPATH%\.\.\\lib', 109 [(r'%SCRIPTPATH%\.\.\\lib',
147 r'%SCRIPTPATH%..\lib\dart2js\lib')]) 110 r'%SCRIPTPATH%..\lib')])
148 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') 111 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat')
149 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) 112 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc)
150 else: 113 else:
151 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') 114 dart2js = os.path.join(sdk_root, 'bin', 'dart2js')
152 Copy(os.path.join(build_dir, 'dart2js'), dart2js) 115 Copy(os.path.join(build_dir, 'dart2js'), dart2js)
153 ReplaceInFiles([dart2js], 116 ReplaceInFiles([dart2js],
154 [(r'\$BIN_DIR/\.\./\.\./lib', 117 [(r'\$BIN_DIR/\.\./\.\./lib',
155 r'$BIN_DIR/../lib/dart2js/lib')]) 118 r'$BIN_DIR/../lib')])
156 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') 119 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc')
157 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) 120 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc)
158 121
159 122
160 def Main(argv): 123 def Main(argv):
161 # Pull in all of the gpyi files which will be munged into the sdk. 124 # Pull in all of the gpyi files which will be munged into the sdk.
162 io_runtime_sources = \ 125 io_runtime_sources = \
163 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] 126 (eval(open("runtime/bin/io_sources.gypi").read()))['sources']
164 127
165 HOME = dirname(dirname(realpath(__file__))) 128 HOME = dirname(dirname(realpath(__file__)))
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 # Construct lib/io/io_runtime.dart from whole cloth. 205 # Construct lib/io/io_runtime.dart from whole cloth.
243 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a') 206 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a')
244 for filename in io_runtime_sources: 207 for filename in io_runtime_sources:
245 assert filename.endswith('.dart') 208 assert filename.endswith('.dart')
246 if filename == 'io.dart': 209 if filename == 'io.dart':
247 continue 210 continue
248 dest_file.write('#source("runtime/' + filename + '");\n') 211 dest_file.write('#source("runtime/' + filename + '");\n')
249 dest_file.close() 212 dest_file.close()
250 213
251 # 214 #
252 # Create and populate lib/compiler.
253 #
254 compiler_src_dir = join(HOME, 'lib', 'compiler')
255 compiler_dest_dir = join(LIB, 'compiler')
256
257 copytree(compiler_src_dir, compiler_dest_dir, ignore=ignore_patterns('.svn'))
258
259 # Remap imports in lib/compiler/* .
260 for (dirpath, subdirs, filenames) in os.walk(compiler_dest_dir):
261 for filename in filenames:
262 if filename.endswith('.dart'):
263 filename = join(dirpath, filename)
264 file_contents = open(filename).read()
265 file = open(filename, 'w')
266 file_contents = re.sub(r"\.\./lib", "..", file_contents)
267 file.write(file_contents)
268 file.close()
269
270 #
271 # Create and populate lib/html.
272 #
273 html_src_dir = join(HOME, 'lib', 'html')
274 html_dest_dir = join(LIB, 'html')
275 os.makedirs(html_dest_dir)
276
277 copyfile(join(html_src_dir, 'dart2js', 'html_dart2js.dart'),
278 join(html_dest_dir, 'html_dart2js.dart'))
279 copyfile(join(html_src_dir, 'dartium', 'html_dartium.dart'),
280 join(html_dest_dir, 'html_dartium.dart'))
281 copyfile(join(html_src_dir, 'dartium', 'nativewrappers.dart'),
282 join(html_dest_dir, 'nativewrappers.dart'))
283
284 #
285 # Create and populate lib/dom.
286 #
287 dom_src_dir = join(HOME, 'lib', 'dom')
288 dom_dest_dir = join(LIB, 'dom')
289 os.makedirs(dom_dest_dir)
290
291 copyfile(join(dom_src_dir, 'dart2js', 'dom_dart2js.dart'),
292 join(dom_dest_dir, 'dom_dart2js.dart'))
293
294 #
295 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. 215 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}.
296 # 216 #
297 217
298 for library in ['_internal', 'core', 'coreimpl', 'crypto', 'isolate', 'json', 218 for library in ['_internal', 'compiler', 'config', 'html', 'core', 'coreimpl',
299 'math', 'mirrors', 'uri', 'utf', 'web']: 219 'crypto', 'isolate', 'json', 'math', 'mirrors', 'uri', 'utf',
300 src_dir = join(HOME, 'lib', library) 220 'web']:
301 dest_dir = join(LIB, library) 221 copytree(join(HOME, 'lib', library), join(LIB, library),
302 os.makedirs(dest_dir) 222 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh'))
303
304 for filename in os.listdir(src_dir):
305 if filename.endswith('.dart'):
306 copyfile(join(src_dir, filename), join(dest_dir, filename))
307 223
308 # Create and copy pkg. 224 # Create and copy pkg.
309 PKG = join(SDK_tmp, 'pkg') 225 PKG = join(SDK_tmp, 'pkg')
310 os.makedirs(PKG) 226 os.makedirs(PKG)
311 227
312 # 228 #
313 # Create and populate pkg/{args, intl, logging, unittest} 229 # Create and populate pkg/{args, intl, logging, unittest}
314 # 230 #
315 231
316 for library in ['args', 'intl', 'logging', 'unittest']: 232 for library in ['args', 'intl', 'logging', 'unittest']:
317 src_dir = join(HOME, 'pkg', library) 233 copytree(join(HOME, 'pkg', library), join(PKG, library),
318 dest_dir = join(PKG, library) 234 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh'))
Bob Nystrom 2012/08/31 17:52:31 This means we'll be including each package's tests
dgrove 2012/08/31 18:25:42 For now, that's intended. We can pull them out bef
319 os.makedirs(dest_dir)
320
321 for filename in os.listdir(src_dir):
322 if filename.endswith('.dart'):
323 copyfile(join(src_dir, filename), join(dest_dir, filename))
324 if exists(join(src_dir, 'lib')):
325 copytree(join(src_dir, 'lib'), join(dest_dir, 'lib'),
326 ignore=ignore_patterns('.svn'))
327 235
328 # Create and populate pkg/dartdoc. 236 # Create and populate pkg/dartdoc.
329 dartdoc_src_dir = join(HOME, 'pkg', 'dartdoc') 237 dartdoc_src_dir = join(HOME, 'pkg', 'dartdoc')
330 dartdoc_dest_dir = join(PKG, 'dartdoc') 238 dartdoc_dest_dir = join(PKG, 'dartdoc')
331 copytree(dartdoc_src_dir, dartdoc_dest_dir, 239 copytree(dartdoc_src_dir, dartdoc_dest_dir,
332 ignore=ignore_patterns('.svn', 'docs')) 240 ignore=ignore_patterns('.svn', 'docs'))
333 241
334 # Fixup dart2js dependencies. 242 # Fixup dart2js dependencies.
335 ReplaceInFiles([ 243 ReplaceInFiles([
336 join(PKG, 'dartdoc', 'dartdoc.dart'), 244 join(PKG, 'dartdoc', 'dartdoc.dart'),
(...skipping 26 matching lines...) Expand all
363 dest_file = join (ANALYZER_DEST, jarToCopy) 271 dest_file = join (ANALYZER_DEST, jarToCopy)
364 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) 272 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy)
365 copyfile(src_file, dest_file) 273 copyfile(src_file, dest_file)
366 274
367 # Create and populate util/pub. 275 # Create and populate util/pub.
368 pub_src_dir = join(HOME, 'utils', 'pub') 276 pub_src_dir = join(HOME, 'utils', 'pub')
369 pub_dst_dir = join(UTIL, 'pub') 277 pub_dst_dir = join(UTIL, 'pub')
370 copytree(pub_src_dir, pub_dst_dir, 278 copytree(pub_src_dir, pub_dst_dir,
371 ignore=ignore_patterns('.svn', 'sdk')) 279 ignore=ignore_patterns('.svn', 'sdk'))
372 280
373 # Copy import maps.
danrubel 2012/08/31 17:27:51 We still need this section in there for a little w
dgrove 2012/08/31 18:25:42 config is actually being copied in line 218. Turns
danrubel 2012/08/31 19:24:52 Good by me!
374 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js' ]
375 os.makedirs(join(LIB, 'config'))
376 for platform in PLATFORMS:
377 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config')
378 import_dst = join(LIB, 'config', 'import_' + platform + '.config')
379 copyfile(import_src, import_dst);
380
381 # Copy dart2js. 281 # Copy dart2js.
382 CopyDart2Js(build_dir, SDK_tmp) 282 CopyDart2Js(build_dir, SDK_tmp)
383 283
384 # Write the 'revision' file 284 # Write the 'revision' file
385 revision = utils.GetSVNRevision() 285 revision = utils.GetSVNRevision()
386 if revision is not None: 286 if revision is not None:
387 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 287 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
388 f.write(revision + '\n') 288 f.write(revision + '\n')
389 f.close() 289 f.close()
390 290
391 move(SDK_tmp, SDK) 291 move(SDK_tmp, SDK)
392 utils.Touch(os.path.join(SDK, 'create.stamp')) 292 utils.Touch(os.path.join(SDK, 'create.stamp'))
393 293
394 if __name__ == '__main__': 294 if __name__ == '__main__':
395 sys.exit(Main(sys.argv)) 295 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « lib/config/import_any.config ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698