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

Side by Side Diff: tools/create_sdk.py

Issue 10454112: Remove frog from the SDK and stop running it from the editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Never map to .js_. Created 8 years, 6 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/dartdoc/dartdoc.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) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, 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 # ......frogc.dart 18 # ......dart2js
19 # ......pub 19 # ......pub
20 # ....include/ 20 # ....include/
21 # ......dart_api.h 21 # ......dart_api.h
22 # ......dart_debugger_api.h 22 # ......dart_debugger_api.h
23 # ....lib/ 23 # ....lib/
24 # ......builtin/ 24 # ......builtin/
25 # ........builtin_runtime.dart 25 # ........builtin_runtime.dart
26 # ......io/ 26 # ......io/
27 # ........io_runtime.dart 27 # ........io_runtime.dart
28 # ........runtime/ 28 # ........runtime/
29 # ......compiler/
29 # ......core/ 30 # ......core/
30 # ........core_{frog, runtime}.dart 31 # ........core_{frog, runtime}.dart
31 # ........{frog, runtime}/ 32 # ........{frog, runtime}/
32 # ......coreimpl/ 33 # ......coreimpl/
33 # ........coreimpl_{frog, runtime}.dart 34 # ........coreimpl_{frog, runtime}.dart
34 # ........{frog, runtime}/ 35 # ........{frog, runtime}/
36 # ......dart2js/
35 # ......dartdoc/ 37 # ......dartdoc/
36 # ......isolate/ 38 # ......isolate/
37 # ........isolate_{frog, runtime}.dart 39 # ........isolate_{frog, runtime}.dart
38 # ........{frog, runtime}/ 40 # ........{frog, runtime}/
39 # ......dom/ 41 # ......dom/
40 # ........dom.dart 42 # ........dom.dart
41 # ......frog/
42 # ......html/ 43 # ......html/
43 # ........html_frog.dart 44 # ........html_frog.dart
44 # ........html_dartium.dart 45 # ........html_dartium.dart
45 # ......crypto/ 46 # ......crypto/
46 # ........crypto.dart 47 # ........crypto.dart
47 # ........(implementation files) 48 # ........(implementation files)
48 # ......json/ 49 # ......json/
49 # ........json_frog.dart 50 # ........json_frog.dart
50 #.........json.dart 51 #.........json.dart
51 # ........{frog}/ 52 # ........{frog}/
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 165
165 # TODO(dgrove) - deal with architectures that are not ia32. 166 # TODO(dgrove) - deal with architectures that are not ia32.
166 167
167 if exists(SDK): 168 if exists(SDK):
168 rmtree(SDK) 169 rmtree(SDK)
169 170
170 # Create and populate sdk/bin. 171 # Create and populate sdk/bin.
171 BIN = join(SDK_tmp, 'bin') 172 BIN = join(SDK_tmp, 'bin')
172 os.makedirs(BIN) 173 os.makedirs(BIN)
173 174
174 # Copy the Dart VM binary, frogc and Windows dart VM link library 175 # Copy the Dart VM binary and the Windows Dart VM link library
175 # into sdk/bin. 176 # into sdk/bin.
176 # 177 #
177 # TODO(dgrove) - deal with architectures that are not ia32. 178 # TODO(dgrove) - deal with architectures that are not ia32.
178 build_dir = os.path.dirname(argv[1]) 179 build_dir = os.path.dirname(argv[1])
179 dart_file_extension = '' 180 dart_file_extension = ''
180 if utils.GuessOS() == 'win32': 181 if utils.GuessOS() == 'win32':
181 dart_file_extension = '.exe' 182 dart_file_extension = '.exe'
182 dart_import_lib_src = join(HOME, build_dir, 'dart.lib') 183 dart_import_lib_src = join(HOME, build_dir, 'dart.lib')
183 dart_import_lib_dest = join(BIN, 'dart.lib') 184 dart_import_lib_dest = join(BIN, 'dart.lib')
184 copyfile(dart_import_lib_src, dart_import_lib_dest) 185 copyfile(dart_import_lib_src, dart_import_lib_dest)
185 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension) 186 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension)
186 dart_dest_binary = join(BIN, 'dart' + dart_file_extension) 187 dart_dest_binary = join(BIN, 'dart' + dart_file_extension)
187 copyfile(dart_src_binary, dart_dest_binary) 188 copyfile(dart_src_binary, dart_dest_binary)
188 copymode(dart_src_binary, dart_dest_binary) 189 copymode(dart_src_binary, dart_dest_binary)
189 190
190 frogc_src_binary = join(HOME, 'frog', 'scripts', 'bootstrap', 'frogc')
191 CopyShellScript(frogc_src_binary, BIN)
192
193 # Create sdk/bin/frogc.dart, and hack as needed.
194 frog_src_dir = join(HOME, 'frog')
195
196 # Convert frogc.dart's imports from import('*') -> import('frog/*').
197 frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read()
198 frogc_dest = open(join(BIN, 'frogc.dart'), 'w')
199 frogc_dest.write(
200 re.sub(r"#import\('([^.])", r"#import('../lib/frog/\1", frogc_contents))
201 frogc_dest.close()
202
203 # Create pub shell script. 191 # Create pub shell script.
204 pub_src_script = join(HOME, 'utils', 'pub', 'sdk', 'pub') 192 pub_src_script = join(HOME, 'utils', 'pub', 'sdk', 'pub')
205 CopyShellScript(pub_src_script, BIN) 193 CopyShellScript(pub_src_script, BIN)
206 194
207 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart.
208
209 # 195 #
210 # Create and populate sdk/include. 196 # Create and populate sdk/include.
211 # 197 #
212 INCLUDE = join(SDK_tmp, 'include') 198 INCLUDE = join(SDK_tmp, 'include')
213 os.makedirs(INCLUDE) 199 os.makedirs(INCLUDE)
214 copyfile(join(HOME, 'runtime', 'include', 'dart_api.h'), 200 copyfile(join(HOME, 'runtime', 'include', 'dart_api.h'),
215 join(INCLUDE, 'dart_api.h')) 201 join(INCLUDE, 'dart_api.h'))
216 copyfile(join(HOME, 'runtime', 'include', 'dart_debugger_api.h'), 202 copyfile(join(HOME, 'runtime', 'include', 'dart_debugger_api.h'),
217 join(INCLUDE, 'dart_debugger_api.h')) 203 join(INCLUDE, 'dart_debugger_api.h'))
218 204
219 # 205 #
220 # Create and populate sdk/lib. 206 # Create and populate sdk/lib.
221 # 207 #
222 208
223 LIB = join(SDK_tmp, 'lib') 209 LIB = join(SDK_tmp, 'lib')
224 os.makedirs(LIB) 210 os.makedirs(LIB)
225 corelib_dest_dir = join(LIB, 'core') 211 corelib_dest_dir = join(LIB, 'core')
226 os.makedirs(corelib_dest_dir) 212 os.makedirs(corelib_dest_dir)
227 os.makedirs(join(corelib_dest_dir, 'frog')) 213 os.makedirs(join(corelib_dest_dir, 'frog'))
228 os.makedirs(join(corelib_dest_dir, 'runtime')) 214 os.makedirs(join(corelib_dest_dir, 'runtime'))
229 215
230 coreimpl_dest_dir = join(LIB, 'coreimpl') 216 coreimpl_dest_dir = join(LIB, 'coreimpl')
231 os.makedirs(coreimpl_dest_dir) 217 os.makedirs(coreimpl_dest_dir)
232 os.makedirs(join(coreimpl_dest_dir, 'frog')) 218 os.makedirs(join(coreimpl_dest_dir, 'frog'))
233 os.makedirs(join(coreimpl_dest_dir, 'frog', 'node'))
234 os.makedirs(join(coreimpl_dest_dir, 'runtime')) 219 os.makedirs(join(coreimpl_dest_dir, 'runtime'))
235 220
236 221
237 # 222 #
238 # Create and populate lib/builtin. 223 # Create and populate lib/builtin.
239 # 224 #
240 builtin_dest_dir = join(LIB, 'builtin') 225 builtin_dest_dir = join(LIB, 'builtin')
241 os.makedirs(builtin_dest_dir) 226 os.makedirs(builtin_dest_dir)
242 assert len(builtin_runtime_sources) == 1 227 assert len(builtin_runtime_sources) == 1
243 assert builtin_runtime_sources[0] == 'builtin.dart' 228 assert builtin_runtime_sources[0] == 'builtin.dart'
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 copytree(compiler_src_dir, compiler_dest_dir, ignore=ignore_patterns('.svn')) 271 copytree(compiler_src_dir, compiler_dest_dir, ignore=ignore_patterns('.svn'))
287 272
288 # Remap imports in lib/compiler/* . 273 # Remap imports in lib/compiler/* .
289 for (dirpath, subdirs, filenames) in os.walk(compiler_dest_dir): 274 for (dirpath, subdirs, filenames) in os.walk(compiler_dest_dir):
290 for filename in filenames: 275 for filename in filenames:
291 if filename.endswith('.dart'): 276 if filename.endswith('.dart'):
292 filename = join(dirpath, filename) 277 filename = join(dirpath, filename)
293 file_contents = open(filename).read() 278 file_contents = open(filename).read()
294 file = open(filename, 'w') 279 file = open(filename, 'w')
295 file_contents = re.sub(r"\.\./lib", "..", file_contents) 280 file_contents = re.sub(r"\.\./lib", "..", file_contents)
296 file_contents = re.sub(r"\.\./frog/", "frog/", file_contents)
297 file.write(file_contents) 281 file.write(file_contents)
298 file.close() 282 file.close()
299 283
300 # 284 #
301 # Create and populate lib/frog.
302 #
303 # TODO(dgrove): Frog is not a dart library and should not live in lib.
304 #
305 frog_dest_dir = join(LIB, 'frog')
306 os.makedirs(frog_dest_dir)
307
308 for filename in os.listdir(frog_src_dir):
309 if filename == 'frog_options.dart':
310 # change config from 'dev' to 'sdk' in frog_options.dart
311 frog_options_contents = open(join(frog_src_dir, filename)).read()
312 frog_options_dest = open(join(frog_dest_dir, filename), 'w')
313 frog_options_dest.write(re.sub("final config = \'dev\';",
314 "final config = \'sdk\';",
315 frog_options_contents))
316 frog_options_dest.close()
317 elif filename.endswith('.dart'):
318 copyfile(join(frog_src_dir, filename), join(frog_dest_dir, filename))
319
320
321 copytree(join(frog_src_dir, 'server'), join(frog_dest_dir, 'server'),
322 ignore=ignore_patterns('.svn'))
323
324 # Remap imports in frog/... .
325 for (dirpath, subdirs, filenames) in os.walk(frog_dest_dir):
326 for filename in filenames:
327 if filename.endswith('.dart'):
328 file_contents = open(join(dirpath, filename)).read()
329 file = open(join(dirpath, filename), 'w')
330 file.write(re.sub(r"\.\./lib/", "../", file_contents))
331 file.close()
332
333 #
334 # Create and populate lib/html. 285 # Create and populate lib/html.
335 # 286 #
336 html_src_dir = join(HOME, 'lib', 'html') 287 html_src_dir = join(HOME, 'lib', 'html')
337 html_dest_dir = join(LIB, 'html') 288 html_dest_dir = join(LIB, 'html')
338 os.makedirs(html_dest_dir) 289 os.makedirs(html_dest_dir)
339 290
340 copyfile(join(html_src_dir, 'frog', 'html_frog.dart'), 291 copyfile(join(html_src_dir, 'frog', 'html_frog.dart'),
341 join(html_dest_dir, 'html_frog.dart')) 292 join(html_dest_dir, 'html_frog.dart'))
342 copyfile(join(html_src_dir, 'dartium', 'html_dartium.dart'), 293 copyfile(join(html_src_dir, 'dartium', 'html_dartium.dart'),
343 join(html_dest_dir, 'html_dartium.dart')) 294 join(html_dest_dir, 'html_dartium.dart'))
(...skipping 21 matching lines...) Expand all
365 316
366 for filename in os.listdir(src_dir): 317 for filename in os.listdir(src_dir):
367 if filename.endswith('.dart'): 318 if filename.endswith('.dart'):
368 copyfile(join(src_dir, filename), join(dest_dir, filename)) 319 copyfile(join(src_dir, filename), join(dest_dir, filename))
369 320
370 # Create and populate lib/dartdoc 321 # Create and populate lib/dartdoc
371 dartdoc_src_dir = join(HOME, 'lib', 'dartdoc') 322 dartdoc_src_dir = join(HOME, 'lib', 'dartdoc')
372 dartdoc_dest_dir = join(LIB, 'dartdoc') 323 dartdoc_dest_dir = join(LIB, 'dartdoc')
373 copytree(dartdoc_src_dir, dartdoc_dest_dir, 324 copytree(dartdoc_src_dir, dartdoc_dest_dir,
374 ignore=ignore_patterns('.svn', 'docs')) 325 ignore=ignore_patterns('.svn', 'docs'))
375 ReplaceInFiles([ 326
327 # Copy frog into lib/dartdoc and fixup dependencies.
328 # TODO(johnniwinther): This should not be necessary long term.
329 frog_src_dir = join(HOME, 'frog')
330 frog_dest_dir = join(dartdoc_dest_dir, 'frog')
331 os.makedirs(frog_dest_dir)
332 for filename in os.listdir(frog_src_dir):
333 if filename == 'frog_options.dart':
334 # Change config from 'dev' to 'sdk' in frog_options.dart.
335 frog_options_contents = open(join(frog_src_dir, filename)).read()
336 frog_options_dest = open(join(frog_dest_dir, filename), 'w')
337 frog_options_dest.write(re.sub("final config = \'dev\';",
338 "final config = \'sdk\';",
339 frog_options_contents))
340 frog_options_dest.close()
341 elif filename.endswith('.dart'):
342 dest = join(frog_dest_dir, filename)
343 copyfile(join(frog_src_dir, filename), dest)
344 ReplaceInFiles([dest], [("../lib/", "../../")])
345 ReplaceInFiles([
376 join(LIB, 'dartdoc', 'dartdoc.dart') 346 join(LIB, 'dartdoc', 'dartdoc.dart')
377 ], [ 347 ], [
378 ("#import\('../../frog", "#import('../frog"), 348 ("#import\('../../frog",
349 "#import('frog"),
379 ("joinPaths\(scriptDir, '../../frog/'\)", 350 ("joinPaths\(scriptDir, '../../frog/'\)",
380 "joinPaths(scriptDir, '../frog/')"), 351 "joinPaths(scriptDir, 'frog/')"),
381 ("joinPaths\(frogPath, 'lib'\)", "joinPaths(frogPath, '..')"), 352 ("joinPaths\(frogPath, 'lib'\)",
353 "joinPaths(scriptDir, '../')"),
382 ("joinPaths\(frogPath, 'minfrog'\)", 354 ("joinPaths\(frogPath, 'minfrog'\)",
383 "joinPaths(scriptDir, '../../bin/frogc')") 355 "joinPaths(scriptDir, '../../bin/dart2js')"),
384 ]) 356 ])
385 ReplaceInFiles([ 357 ReplaceInFiles([
386 join(LIB, 'dartdoc', 'classify.dart'), 358 join(LIB, 'dartdoc', 'classify.dart'),
387 join(LIB, 'dartdoc', 'client-live-nav.dart'), 359 join(LIB, 'dartdoc', 'client-live-nav.dart'),
388 join(LIB, 'dartdoc', 'client-static.dart') 360 join(LIB, 'dartdoc', 'client-static.dart')
389 ], [ 361 ], [
390 ("#import\('../../frog", "#import('../frog") 362 ("#import\('../../frog", "#import('frog")
391 ]) 363 ])
392 364
393 # Create and populate lib/isolate 365 # Create and populate lib/isolate
394 copytree(join(HOME, 'lib', 'isolate'), join(LIB, 'isolate'), 366 copytree(join(HOME, 'lib', 'isolate'), join(LIB, 'isolate'),
395 ignore=ignore_patterns('.svn')) 367 ignore=ignore_patterns('.svn'))
396 368
397 isolate_runtime_dir = join(LIB, 'isolate', 'runtime') 369 isolate_runtime_dir = join(LIB, 'isolate', 'runtime')
398 # path seems to exist when run locally, but not on builder 370 # path seems to exist when run locally, but not on builder
399 if not exists(isolate_runtime_dir): 371 if not exists(isolate_runtime_dir):
400 os.makedirs(isolate_runtime_dir) 372 os.makedirs(isolate_runtime_dir)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w') 456 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w')
485 dest_file.write('#library("dart:coreimpl");\n') 457 dest_file.write('#library("dart:coreimpl");\n')
486 for filename in coreimpl_sources: 458 for filename in coreimpl_sources:
487 dest_file.write('#source("runtime/' + filename + '");\n') 459 dest_file.write('#source("runtime/' + filename + '");\n')
488 for filename in coreimpl_runtime_sources: 460 for filename in coreimpl_runtime_sources:
489 if filename.endswith('.dart'): 461 if filename.endswith('.dart'):
490 dest_file.write('#source("runtime/' + filename + '");\n') 462 dest_file.write('#source("runtime/' + filename + '");\n')
491 dest_file.close() 463 dest_file.close()
492 464
493 # Create and copy tools. 465 # Create and copy tools.
494
495 UTIL = join(SDK_tmp, 'util') 466 UTIL = join(SDK_tmp, 'util')
496 os.makedirs(UTIL) 467 os.makedirs(UTIL)
497 468
498 # Create and populate util/pub 469 # Create and populate util/pub.
499 pub_src_dir = join(HOME, 'utils', 'pub') 470 pub_src_dir = join(HOME, 'utils', 'pub')
500 pub_dst_dir = join(UTIL, 'pub') 471 pub_dst_dir = join(UTIL, 'pub')
501 copytree(pub_src_dir, pub_dst_dir, 472 copytree(pub_src_dir, pub_dst_dir,
502 ignore=ignore_patterns('.svn', 'sdk')) 473 ignore=ignore_patterns('.svn', 'sdk'))
503 474
504 # Copy import maps 475 # Copy import maps.
505 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js', 'frog' ] 476 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js' ]
506 os.makedirs(join(LIB, 'config')) 477 os.makedirs(join(LIB, 'config'))
507 for platform in PLATFORMS: 478 for platform in PLATFORMS:
508 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config') 479 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config')
509 import_dst = join(LIB, 'config', 'import_' + platform + '.config') 480 import_dst = join(LIB, 'config', 'import_' + platform + '.config')
510 copyfile(import_src, import_dst); 481 copyfile(import_src, import_dst);
511 482
483 # Copy dart2js.
512 CopyDart2Js(build_dir, SDK_tmp) 484 CopyDart2Js(build_dir, SDK_tmp)
513 485
514 # Write the 'revision' file 486 # Write the 'revision' file
515 revision = utils.GetSVNRevision() 487 revision = utils.GetSVNRevision()
516 if revision is not None: 488 if revision is not None:
517 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 489 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
518 f.write(revision + '\n') 490 f.write(revision + '\n')
519 f.close() 491 f.close()
520 492
521 move(SDK_tmp, SDK) 493 move(SDK_tmp, SDK)
522 utils.Touch(os.path.join(SDK, 'create.stamp')) 494 utils.Touch(os.path.join(SDK, 'create.stamp'))
523 495
524 if __name__ == '__main__': 496 if __name__ == '__main__':
525 sys.exit(Main(sys.argv)) 497 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « lib/dartdoc/dartdoc.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698