| OLD | NEW |
| 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 # |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 # ......builtin/ |
| 26 # ........builtin_runtime.dart | 26 # ........builtin_runtime.dart |
| 27 # ......io/ | 27 # ......io/ |
| 28 # ........io_runtime.dart | 28 # ........io_runtime.dart |
| 29 # ........runtime/ | 29 # ........runtime/ |
| 30 # ......compiler/ | 30 # ......compiler/ |
| 31 # ......core/ | 31 # ......core/ |
| 32 # ........core_{frog, runtime}.dart | 32 # ........core_runtime.dart |
| 33 # ........{frog, runtime}/ | 33 # ........runtime/ |
| 34 # ......coreimpl/ | 34 # ......coreimpl/ |
| 35 # ........coreimpl_{frog, runtime}.dart | 35 # ........coreimpl_runtime.dart |
| 36 # ........{frog, runtime}/ | 36 # ........runtime/ |
| 37 # ......dart2js/ | 37 # ......dart2js/ |
| 38 # ......dartdoc/ | 38 # ......dartdoc/ |
| 39 # ......isolate/ | 39 # ......isolate/ |
| 40 # ........isolate_{frog, runtime}.dart | 40 # ........isolate_{frog, runtime}.dart |
| 41 # ........{frog, runtime}/ | 41 # ........{frog, runtime}/ |
| 42 # ......dom/ | 42 # ......dom/ |
| 43 # ........dom.dart | 43 # ........dom.dart |
| 44 # ......html/ | 44 # ......html/ |
| 45 # ........html_frog.dart | 45 # ........html_frog.dart |
| 46 # ........html_dartium.dart | 46 # ........html_dartium.dart |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 | 91 |
| 92 def Copy(src, dest): | 92 def Copy(src, dest): |
| 93 copyfile(src, dest) | 93 copyfile(src, dest) |
| 94 copymode(src, dest) | 94 copymode(src, dest) |
| 95 | 95 |
| 96 # TODO(zundel): this excludes the analyzer from the sdk build until builders | 96 # TODO(zundel): this excludes the analyzer from the sdk build until builders |
| 97 # have all prerequisite software installed. Also update dart.gyp. | 97 # have all prerequisite software installed. Also update dart.gyp. |
| 98 def ShouldCopyAnalyzer(): | 98 def ShouldCopyAnalyzer(): |
| 99 return utils.GuessOS() == 'linux' | 99 return utils.GuessOS() == 'linux' |
| 100 | 100 |
| 101 | 101 |
| 102 def CopyShellScript(src_file, dest_dir): | 102 def CopyShellScript(src_file, dest_dir): |
| 103 '''Copies a shell/batch script to the given destination directory. Handles | 103 '''Copies a shell/batch script to the given destination directory. Handles |
| 104 using the appropriate platform-specific file extension.''' | 104 using the appropriate platform-specific file extension.''' |
| 105 file_extension = '' | 105 file_extension = '' |
| 106 if utils.GuessOS() == 'win32': | 106 if utils.GuessOS() == 'win32': |
| 107 file_extension = '.bat' | 107 file_extension = '.bat' |
| 108 | 108 |
| 109 src = src_file + file_extension | 109 src = src_file + file_extension |
| 110 dest = join(dest_dir, basename(src_file) + file_extension) | 110 dest = join(dest_dir, basename(src_file) + file_extension) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 | 149 |
| 150 def Main(argv): | 150 def Main(argv): |
| 151 # Pull in all of the gpyi files which will be munged into the sdk. | 151 # Pull in all of the gpyi files which will be munged into the sdk. |
| 152 builtin_runtime_sources = \ | 152 builtin_runtime_sources = \ |
| 153 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] | 153 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] |
| 154 io_runtime_sources = \ | 154 io_runtime_sources = \ |
| 155 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] | 155 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] |
| 156 corelib_sources = \ | 156 corelib_sources = \ |
| 157 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] | 157 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] |
| 158 corelib_frog_sources = \ | |
| 159 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources'] | |
| 160 corelib_runtime_sources = \ | 158 corelib_runtime_sources = \ |
| 161 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] | 159 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] |
| 162 coreimpl_sources = \ | 160 coreimpl_sources = \ |
| 163 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ | 161 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ |
| 164 ['sources'] | 162 ['sources'] |
| 165 coreimpl_frog_sources = \ | |
| 166 (eval(open("frog/lib/frog_coreimpl_sources.gypi").read()))['sources'] | |
| 167 coreimpl_runtime_sources = \ | 163 coreimpl_runtime_sources = \ |
| 168 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources'] | 164 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources'] |
| 169 | 165 |
| 170 HOME = dirname(dirname(realpath(__file__))) | 166 HOME = dirname(dirname(realpath(__file__))) |
| 171 | 167 |
| 172 SDK_tmp = tempfile.mkdtemp() | 168 SDK_tmp = tempfile.mkdtemp() |
| 173 SDK = argv[1] | 169 SDK = argv[1] |
| 174 | 170 |
| 175 # TODO(dgrove) - deal with architectures that are not ia32. | 171 # TODO(dgrove) - deal with architectures that are not ia32. |
| 176 | 172 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 join(INCLUDE, 'dart_debugger_api.h')) | 219 join(INCLUDE, 'dart_debugger_api.h')) |
| 224 | 220 |
| 225 # | 221 # |
| 226 # Create and populate sdk/lib. | 222 # Create and populate sdk/lib. |
| 227 # | 223 # |
| 228 | 224 |
| 229 LIB = join(SDK_tmp, 'lib') | 225 LIB = join(SDK_tmp, 'lib') |
| 230 os.makedirs(LIB) | 226 os.makedirs(LIB) |
| 231 corelib_dest_dir = join(LIB, 'core') | 227 corelib_dest_dir = join(LIB, 'core') |
| 232 os.makedirs(corelib_dest_dir) | 228 os.makedirs(corelib_dest_dir) |
| 233 os.makedirs(join(corelib_dest_dir, 'frog')) | |
| 234 os.makedirs(join(corelib_dest_dir, 'runtime')) | 229 os.makedirs(join(corelib_dest_dir, 'runtime')) |
| 235 | 230 |
| 236 coreimpl_dest_dir = join(LIB, 'coreimpl') | 231 coreimpl_dest_dir = join(LIB, 'coreimpl') |
| 237 os.makedirs(coreimpl_dest_dir) | 232 os.makedirs(coreimpl_dest_dir) |
| 238 os.makedirs(join(coreimpl_dest_dir, 'frog')) | |
| 239 os.makedirs(join(coreimpl_dest_dir, 'runtime')) | 233 os.makedirs(join(coreimpl_dest_dir, 'runtime')) |
| 240 | 234 |
| 241 | 235 |
| 242 # | 236 # |
| 243 # Create and populate lib/builtin. | 237 # Create and populate lib/builtin. |
| 244 # | 238 # |
| 245 builtin_dest_dir = join(LIB, 'builtin') | 239 builtin_dest_dir = join(LIB, 'builtin') |
| 246 os.makedirs(builtin_dest_dir) | 240 os.makedirs(builtin_dest_dir) |
| 247 assert len(builtin_runtime_sources) == 1 | 241 assert len(builtin_runtime_sources) == 1 |
| 248 assert builtin_runtime_sources[0] == 'builtin.dart' | 242 assert builtin_runtime_sources[0] == 'builtin.dart' |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 copytree(dartdoc_src_dir, dartdoc_dest_dir, | 338 copytree(dartdoc_src_dir, dartdoc_dest_dir, |
| 345 ignore=ignore_patterns('.svn', 'docs')) | 339 ignore=ignore_patterns('.svn', 'docs')) |
| 346 | 340 |
| 347 # Fixup frog dependencies. | 341 # Fixup frog dependencies. |
| 348 ReplaceInFiles([join(LIB, 'dartdoc', 'dartdoc.dart')], [ | 342 ReplaceInFiles([join(LIB, 'dartdoc', 'dartdoc.dart')], [ |
| 349 ("'dart2js'", "joinPaths(scriptDir, '../../bin/dart2js')"), | 343 ("'dart2js'", "joinPaths(scriptDir, '../../bin/dart2js')"), |
| 350 ]) | 344 ]) |
| 351 ReplaceInFiles([join(LIB, 'dartdoc', 'frog', 'frog_options.dart')], [ | 345 ReplaceInFiles([join(LIB, 'dartdoc', 'frog', 'frog_options.dart')], [ |
| 352 ("final config = \'dev\';", "final config = \'sdk\';") | 346 ("final config = \'dev\';", "final config = \'sdk\';") |
| 353 ]) | 347 ]) |
| 348 ReplaceInFiles([join(LIB, 'dartdoc', 'frog', 'lib', 'corelib.dart')], [ |
| 349 ("../../../../corelib/src/", "../../../core/runtime/") |
| 350 ]); |
| 351 ReplaceInFiles([join(LIB, 'dartdoc', 'frog', 'lib', 'corelib_impl.dart')], [ |
| 352 ("../../../../corelib/src/implementation", "../../../coreimpl/runtime/") |
| 353 ]); |
| 354 | 354 |
| 355 # Create and populate lib/isolate | 355 # Create and populate lib/isolate |
| 356 copytree(join(HOME, 'lib', 'isolate'), join(LIB, 'isolate'), | 356 copytree(join(HOME, 'lib', 'isolate'), join(LIB, 'isolate'), |
| 357 ignore=ignore_patterns('.svn')) | 357 ignore=ignore_patterns('.svn')) |
| 358 | 358 |
| 359 isolate_runtime_dir = join(LIB, 'isolate', 'runtime') | 359 isolate_runtime_dir = join(LIB, 'isolate', 'runtime') |
| 360 # path seems to exist when run locally, but not on builder | 360 # path seems to exist when run locally, but not on builder |
| 361 if not exists(isolate_runtime_dir): | 361 if not exists(isolate_runtime_dir): |
| 362 os.makedirs(isolate_runtime_dir) | 362 os.makedirs(isolate_runtime_dir) |
| 363 | 363 |
| 364 isolate_runtime_src = join(HOME, 'runtime', 'lib', 'isolate.dart') | 364 isolate_runtime_src = join(HOME, 'runtime', 'lib', 'isolate.dart') |
| 365 isolate_runtime_dest = join(LIB, 'isolate', 'runtime', 'isolate.dart') | 365 isolate_runtime_dest = join(LIB, 'isolate', 'runtime', 'isolate.dart') |
| 366 copyfile(isolate_runtime_src, isolate_runtime_dest) | 366 copyfile(isolate_runtime_src, isolate_runtime_dest) |
| 367 | 367 |
| 368 # | 368 # |
| 369 # Create and populate lib/core. | 369 # Create and populate lib/core. |
| 370 # | 370 # |
| 371 | 371 |
| 372 # First, copy corelib/* to lib/{frog, runtime} | 372 # First, copy corelib/* to lib/runtime |
| 373 for filename in corelib_sources: | 373 for filename in corelib_sources: |
| 374 for target_dir in ['frog', 'runtime']: | 374 for target_dir in ['runtime']: |
| 375 copyfile(join('corelib', 'src', filename), | 375 copyfile(join('corelib', 'src', filename), |
| 376 join(corelib_dest_dir, target_dir, filename)) | 376 join(corelib_dest_dir, target_dir, filename)) |
| 377 | 377 |
| 378 # Next, copy the frog library source on top of core/frog | |
| 379 # TOOD(dgrove): move json to top-level | |
| 380 for filename in corelib_frog_sources: | |
| 381 copyfile(join('frog', 'lib', filename), | |
| 382 join(corelib_dest_dir, 'frog', filename)) | |
| 383 | |
| 384 # Next, copy the runtime library source on top of core/runtime | 378 # Next, copy the runtime library source on top of core/runtime |
| 385 for filename in corelib_runtime_sources: | 379 for filename in corelib_runtime_sources: |
| 386 if filename.endswith('.dart'): | 380 if filename.endswith('.dart'): |
| 387 copyfile(join('runtime', 'lib', filename), | 381 copyfile(join('runtime', 'lib', filename), |
| 388 join(corelib_dest_dir, 'runtime', filename)) | 382 join(corelib_dest_dir, 'runtime', filename)) |
| 389 | 383 |
| 390 # | 384 # |
| 391 # At this point, it's time to create lib/core/core*dart . | 385 # At this point, it's time to create lib/core/core*dart . |
| 392 # | 386 # |
| 393 # munge frog/lib/corelib.dart into lib/core_frog.dart . | |
| 394 src_file = join('frog', 'lib', 'corelib.dart') | |
| 395 dest_file = open(join(corelib_dest_dir, 'core_frog.dart'), 'w') | |
| 396 contents = open(src_file).read() | |
| 397 contents = re.sub('source\(\"../../corelib/src/', 'source(\"', contents) | |
| 398 contents = re.sub("source\(\"", "source(\"frog/", contents) | |
| 399 dest_file.write(contents) | |
| 400 dest_file.close() | |
| 401 | |
| 402 # construct lib/core_runtime.dart from whole cloth. | 387 # construct lib/core_runtime.dart from whole cloth. |
| 403 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w') | 388 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w') |
| 404 dest_file.write('#library("dart:core");\n') | 389 dest_file.write('#library("dart:core");\n') |
| 405 dest_file.write('#import("dart:coreimpl");\n') | 390 dest_file.write('#import("dart:coreimpl");\n') |
| 406 for filename in corelib_sources: | 391 for filename in corelib_sources: |
| 407 dest_file.write('#source("runtime/' + filename + '");\n') | 392 dest_file.write('#source("runtime/' + filename + '");\n') |
| 408 for filename in corelib_runtime_sources: | 393 for filename in corelib_runtime_sources: |
| 409 if filename.endswith('.dart'): | 394 if filename.endswith('.dart'): |
| 410 dest_file.write('#source("runtime/' + filename + '");\n') | 395 dest_file.write('#source("runtime/' + filename + '");\n') |
| 411 # include the missing print function | 396 # include the missing print function |
| 412 dest_file.write('void print(Object arg) { /* native */ }\n') | 397 dest_file.write('void print(Object arg) { /* native */ }\n') |
| 413 dest_file.close() | 398 dest_file.close() |
| 414 | 399 |
| 415 # | 400 # |
| 416 # Create and populate lib/coreimpl. | 401 # Create and populate lib/coreimpl. |
| 417 # | 402 # |
| 418 | 403 |
| 419 # First, copy corelib/src/implementation to corelib/{frog, runtime}. | 404 # First, copy corelib/src/implementation to corelib/runtime. |
| 420 for filename in coreimpl_sources: | 405 for filename in coreimpl_sources: |
| 421 for target_dir in ['frog', 'runtime']: | 406 for target_dir in ['runtime']: |
| 422 copyfile(join('corelib', 'src', 'implementation', filename), | 407 copyfile(join('corelib', 'src', 'implementation', filename), |
| 423 join(coreimpl_dest_dir, target_dir, filename)) | 408 join(coreimpl_dest_dir, target_dir, filename)) |
| 424 | 409 |
| 425 for filename in coreimpl_frog_sources: | |
| 426 copyfile(join('frog', 'lib', filename), | |
| 427 join(coreimpl_dest_dir, 'frog', filename)) | |
| 428 | |
| 429 for filename in coreimpl_runtime_sources: | 410 for filename in coreimpl_runtime_sources: |
| 430 if filename.endswith('.dart'): | 411 if filename.endswith('.dart'): |
| 431 copyfile(join('runtime', 'lib', filename), | 412 copyfile(join('runtime', 'lib', filename), |
| 432 join(coreimpl_dest_dir, 'runtime', filename)) | 413 join(coreimpl_dest_dir, 'runtime', filename)) |
| 433 | 414 |
| 434 | |
| 435 # Create and fix up lib/coreimpl/coreimpl_frog.dart . | |
| 436 src_file = join('frog', 'lib', 'corelib_impl.dart') | |
| 437 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_frog.dart'), 'w') | |
| 438 contents = open(src_file).read() | |
| 439 contents = re.sub('source\(\"../../corelib/src/implementation/', | |
| 440 'source(\"', contents) | |
| 441 contents = re.sub('source\(\"', 'source(\"frog/', contents) | |
| 442 dest_file.write(contents) | |
| 443 dest_file.close() | |
| 444 | |
| 445 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth. | 415 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth. |
| 446 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w') | 416 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w') |
| 447 dest_file.write('#library("dart:coreimpl");\n') | 417 dest_file.write('#library("dart:coreimpl");\n') |
| 448 for filename in coreimpl_sources: | 418 for filename in coreimpl_sources: |
| 449 dest_file.write('#source("runtime/' + filename + '");\n') | 419 dest_file.write('#source("runtime/' + filename + '");\n') |
| 450 for filename in coreimpl_runtime_sources: | 420 for filename in coreimpl_runtime_sources: |
| 451 if filename.endswith('.dart'): | 421 if filename.endswith('.dart'): |
| 452 dest_file.write('#source("runtime/' + filename + '");\n') | 422 dest_file.write('#source("runtime/' + filename + '");\n') |
| 453 dest_file.close() | 423 dest_file.close() |
| 454 | 424 |
| 455 # Create and copy tools. | 425 # Create and copy tools. |
| 456 UTIL = join(SDK_tmp, 'util') | 426 UTIL = join(SDK_tmp, 'util') |
| 457 os.makedirs(UTIL) | 427 os.makedirs(UTIL) |
| 458 | 428 |
| 459 if ShouldCopyAnalyzer(): | 429 if ShouldCopyAnalyzer(): |
| 460 # Create and copy Analyzer library into 'util' | 430 # Create and copy Analyzer library into 'util' |
| 461 ANALYZER_DEST = join(UTIL, 'analyzer') | 431 ANALYZER_DEST = join(UTIL, 'analyzer') |
| 462 os.makedirs(ANALYZER_DEST) | 432 os.makedirs(ANALYZER_DEST) |
| 463 | 433 |
| 464 analyzer_src_jar = join(ANALYZER_HOME, 'util', 'analyzer', | 434 analyzer_src_jar = join(ANALYZER_HOME, 'util', 'analyzer', |
| 465 'dart_analyzer.jar') | 435 'dart_analyzer.jar') |
| 466 analyzer_dest_jar = join(ANALYZER_DEST, 'dart_analyzer.jar') | 436 analyzer_dest_jar = join(ANALYZER_DEST, 'dart_analyzer.jar') |
| 467 copyfile(analyzer_src_jar, analyzer_dest_jar) | 437 copyfile(analyzer_src_jar, analyzer_dest_jar) |
| 468 | 438 |
| 469 jarsToCopy = [ join("args4j", "2.0.12", "args4j-2.0.12.jar"), | 439 jarsToCopy = [ join("args4j", "2.0.12", "args4j-2.0.12.jar"), |
| 470 join("guava", "r09", "guava-r09.jar"), | 440 join("guava", "r09", "guava-r09.jar"), |
| 471 join("json", "r2_20080312", "json.jar") ] | 441 join("json", "r2_20080312", "json.jar") ] |
| 472 for jarToCopy in jarsToCopy: | 442 for jarToCopy in jarsToCopy: |
| 473 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy)) | 443 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy)) |
| 474 os.makedirs(dest_dir) | 444 os.makedirs(dest_dir) |
| 475 dest_file = join (ANALYZER_DEST, jarToCopy) | 445 dest_file = join (ANALYZER_DEST, jarToCopy) |
| 476 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) | 446 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) |
| 477 copyfile(src_file, dest_file) | 447 copyfile(src_file, dest_file) |
| 478 | 448 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 498 if revision is not None: | 468 if revision is not None: |
| 499 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 469 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 500 f.write(revision + '\n') | 470 f.write(revision + '\n') |
| 501 f.close() | 471 f.close() |
| 502 | 472 |
| 503 move(SDK_tmp, SDK) | 473 move(SDK_tmp, SDK) |
| 504 utils.Touch(os.path.join(SDK, 'create.stamp')) | 474 utils.Touch(os.path.join(SDK, 'create.stamp')) |
| 505 | 475 |
| 506 if __name__ == '__main__': | 476 if __name__ == '__main__': |
| 507 sys.exit(Main(sys.argv)) | 477 sys.exit(Main(sys.argv)) |
| OLD | NEW |