| OLD | NEW |
| 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) 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 # ......pub | 20 # ......pub |
| 20 # ....include/ | 21 # ....include/ |
| 21 # ......dart_api.h | 22 # ......dart_api.h |
| 22 # ......dart_debugger_api.h | 23 # ......dart_debugger_api.h |
| 23 # ....lib/ | 24 # ....lib/ |
| 24 # ......builtin/ | 25 # ......builtin/ |
| 25 # ........builtin_runtime.dart | 26 # ........builtin_runtime.dart |
| 26 # ......io/ | 27 # ......io/ |
| 27 # ........io_runtime.dart | 28 # ........io_runtime.dart |
| 28 # ........runtime/ | 29 # ........runtime/ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 # ........(implementation files) | 49 # ........(implementation files) |
| 49 # ......json/ | 50 # ......json/ |
| 50 # ........json_frog.dart | 51 # ........json_frog.dart |
| 51 #.........json.dart | 52 #.........json.dart |
| 52 # ........{frog}/ | 53 # ........{frog}/ |
| 53 # ......uri/ | 54 # ......uri/ |
| 54 # ........uri.dart | 55 # ........uri.dart |
| 55 # ......utf/ | 56 # ......utf/ |
| 56 # ......(more will come here) | 57 # ......(more will come here) |
| 57 # ....util/ | 58 # ....util/ |
| 59 # ......analyzer/ |
| 60 # ........dart_analyzer.jar |
| 61 # ........(third-party libraries for dart_analyzer) |
| 58 # ......pub/ | 62 # ......pub/ |
| 59 # ......(more will come here) | 63 # ......(more will come here) |
| 60 | 64 |
| 61 | 65 |
| 62 | 66 |
| 63 import os | 67 import os |
| 64 import re | 68 import re |
| 65 import sys | 69 import sys |
| 66 import tempfile | 70 import tempfile |
| 67 import utils | 71 import utils |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 | 86 |
| 83 dest = open(path, 'w') | 87 dest = open(path, 'w') |
| 84 dest.write(contents) | 88 dest.write(contents) |
| 85 dest.close() | 89 dest.close() |
| 86 | 90 |
| 87 | 91 |
| 88 def Copy(src, dest): | 92 def Copy(src, dest): |
| 89 copyfile(src, dest) | 93 copyfile(src, dest) |
| 90 copymode(src, dest) | 94 copymode(src, dest) |
| 91 | 95 |
| 96 # TODO(zundel): this excludes the analyzer from the sdk build until builders |
| 97 # have all prerequisite software installed. Also update |
| 98 # dart.gyp and dart-compiler.gyp |
| 99 def ShouldCopyAnalyzer(): |
| 100 # return utils.GuessOS() == 'linux' |
| 101 return False |
| 102 |
| 92 | 103 |
| 93 def CopyShellScript(src_file, dest_dir): | 104 def CopyShellScript(src_file, dest_dir): |
| 94 '''Copies a shell/batch script to the given destination directory. Handles | 105 '''Copies a shell/batch script to the given destination directory. Handles |
| 95 using the appropriate platform-specific file extension.''' | 106 using the appropriate platform-specific file extension.''' |
| 96 file_extension = '' | 107 file_extension = '' |
| 97 if utils.GuessOS() == 'win32': | 108 if utils.GuessOS() == 'win32': |
| 98 file_extension = '.bat' | 109 file_extension = '.bat' |
| 99 | 110 |
| 100 src = src_file + file_extension | 111 src = src_file + file_extension |
| 101 dest = join(dest_dir, basename(src_file) + file_extension) | 112 dest = join(dest_dir, basename(src_file) + file_extension) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 # Create and populate sdk/bin. | 182 # Create and populate sdk/bin. |
| 172 BIN = join(SDK_tmp, 'bin') | 183 BIN = join(SDK_tmp, 'bin') |
| 173 os.makedirs(BIN) | 184 os.makedirs(BIN) |
| 174 | 185 |
| 175 # Copy the Dart VM binary and the Windows Dart VM link library | 186 # Copy the Dart VM binary and the Windows Dart VM link library |
| 176 # into sdk/bin. | 187 # into sdk/bin. |
| 177 # | 188 # |
| 178 # TODO(dgrove) - deal with architectures that are not ia32. | 189 # TODO(dgrove) - deal with architectures that are not ia32. |
| 179 build_dir = os.path.dirname(argv[1]) | 190 build_dir = os.path.dirname(argv[1]) |
| 180 dart_file_extension = '' | 191 dart_file_extension = '' |
| 192 analyzer_file_extension = '' |
| 181 if utils.GuessOS() == 'win32': | 193 if utils.GuessOS() == 'win32': |
| 182 dart_file_extension = '.exe' | 194 dart_file_extension = '.exe' |
| 195 analyzer_file_extension = '.bat' # TODO(zundel): test on Windows |
| 183 dart_import_lib_src = join(HOME, build_dir, 'dart.lib') | 196 dart_import_lib_src = join(HOME, build_dir, 'dart.lib') |
| 184 dart_import_lib_dest = join(BIN, 'dart.lib') | 197 dart_import_lib_dest = join(BIN, 'dart.lib') |
| 185 copyfile(dart_import_lib_src, dart_import_lib_dest) | 198 copyfile(dart_import_lib_src, dart_import_lib_dest) |
| 186 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension) | 199 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension) |
| 187 dart_dest_binary = join(BIN, 'dart' + dart_file_extension) | 200 dart_dest_binary = join(BIN, 'dart' + dart_file_extension) |
| 188 copyfile(dart_src_binary, dart_dest_binary) | 201 copyfile(dart_src_binary, dart_dest_binary) |
| 189 copymode(dart_src_binary, dart_dest_binary) | 202 copymode(dart_src_binary, dart_dest_binary) |
| 190 | 203 |
| 204 if ShouldCopyAnalyzer(): |
| 205 # Copy analyzer into sdk/bin |
| 206 ANALYZER_HOME = join(HOME, build_dir, 'analyzer') |
| 207 dart_analyzer_src_binary = join(ANALYZER_HOME, 'bin', 'dart_analyzer') |
| 208 dart_analyzer_dest_binary = join(BIN, |
| 209 'dart_analyzer' + analyzer_file_extension) |
| 210 copyfile(dart_analyzer_src_binary, dart_analyzer_dest_binary) |
| 211 copymode(dart_analyzer_src_binary, dart_analyzer_dest_binary) |
| 212 |
| 191 # Create pub shell script. | 213 # Create pub shell script. |
| 192 pub_src_script = join(HOME, 'utils', 'pub', 'sdk', 'pub') | 214 pub_src_script = join(HOME, 'utils', 'pub', 'sdk', 'pub') |
| 193 CopyShellScript(pub_src_script, BIN) | 215 CopyShellScript(pub_src_script, BIN) |
| 194 | 216 |
| 195 # | 217 # |
| 196 # Create and populate sdk/include. | 218 # Create and populate sdk/include. |
| 197 # | 219 # |
| 198 INCLUDE = join(SDK_tmp, 'include') | 220 INCLUDE = join(SDK_tmp, 'include') |
| 199 os.makedirs(INCLUDE) | 221 os.makedirs(INCLUDE) |
| 200 copyfile(join(HOME, 'runtime', 'include', 'dart_api.h'), | 222 copyfile(join(HOME, 'runtime', 'include', 'dart_api.h'), |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 dest_file.write('#source("runtime/' + filename + '");\n') | 481 dest_file.write('#source("runtime/' + filename + '");\n') |
| 460 for filename in coreimpl_runtime_sources: | 482 for filename in coreimpl_runtime_sources: |
| 461 if filename.endswith('.dart'): | 483 if filename.endswith('.dart'): |
| 462 dest_file.write('#source("runtime/' + filename + '");\n') | 484 dest_file.write('#source("runtime/' + filename + '");\n') |
| 463 dest_file.close() | 485 dest_file.close() |
| 464 | 486 |
| 465 # Create and copy tools. | 487 # Create and copy tools. |
| 466 UTIL = join(SDK_tmp, 'util') | 488 UTIL = join(SDK_tmp, 'util') |
| 467 os.makedirs(UTIL) | 489 os.makedirs(UTIL) |
| 468 | 490 |
| 491 if ShouldCopyAnalyzer(): |
| 492 # Create and copy Analyzer library into 'util' |
| 493 ANALYZER_DEST = join(UTIL, 'analyzer') |
| 494 os.makedirs(ANALYZER_DEST) |
| 495 |
| 496 analyzer_src_jar = join(ANALYZER_HOME, 'util', 'analyzer', |
| 497 'dart_analyzer.jar') |
| 498 analyzer_dest_jar = join(ANALYZER_DEST, 'dart_analyzer.jar') |
| 499 copyfile(analyzer_src_jar, analyzer_dest_jar) |
| 500 |
| 501 jarsToCopy = [ join("args4j", "2.0.12", "args4j-2.0.12.jar"), |
| 502 join("guava", "r09", "guava-r09.jar"), |
| 503 join("json", "r2_20080312", "json.jar") ] |
| 504 for jarToCopy in jarsToCopy: |
| 505 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy)) |
| 506 os.makedirs(dest_dir) |
| 507 dest_file = join (ANALYZER_DEST, jarToCopy) |
| 508 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) |
| 509 copyfile(src_file, dest_file) |
| 510 |
| 469 # Create and populate util/pub. | 511 # Create and populate util/pub. |
| 470 pub_src_dir = join(HOME, 'utils', 'pub') | 512 pub_src_dir = join(HOME, 'utils', 'pub') |
| 471 pub_dst_dir = join(UTIL, 'pub') | 513 pub_dst_dir = join(UTIL, 'pub') |
| 472 copytree(pub_src_dir, pub_dst_dir, | 514 copytree(pub_src_dir, pub_dst_dir, |
| 473 ignore=ignore_patterns('.svn', 'sdk')) | 515 ignore=ignore_patterns('.svn', 'sdk')) |
| 474 | 516 |
| 475 # Copy import maps. | 517 # Copy import maps. |
| 476 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js' ] | 518 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js' ] |
| 477 os.makedirs(join(LIB, 'config')) | 519 os.makedirs(join(LIB, 'config')) |
| 478 for platform in PLATFORMS: | 520 for platform in PLATFORMS: |
| 479 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config') | 521 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config') |
| 480 import_dst = join(LIB, 'config', 'import_' + platform + '.config') | 522 import_dst = join(LIB, 'config', 'import_' + platform + '.config') |
| 481 copyfile(import_src, import_dst); | 523 copyfile(import_src, import_dst); |
| 482 | 524 |
| 483 # Copy dart2js. | 525 # Copy dart2js. |
| 484 CopyDart2Js(build_dir, SDK_tmp) | 526 CopyDart2Js(build_dir, SDK_tmp) |
| 485 | 527 |
| 486 # Write the 'revision' file | 528 # Write the 'revision' file |
| 487 revision = utils.GetSVNRevision() | 529 revision = utils.GetSVNRevision() |
| 488 if revision is not None: | 530 if revision is not None: |
| 489 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 531 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 490 f.write(revision + '\n') | 532 f.write(revision + '\n') |
| 491 f.close() | 533 f.close() |
| 492 | 534 |
| 493 move(SDK_tmp, SDK) | 535 move(SDK_tmp, SDK) |
| 494 utils.Touch(os.path.join(SDK, 'create.stamp')) | 536 utils.Touch(os.path.join(SDK, 'create.stamp')) |
| 495 | 537 |
| 496 if __name__ == '__main__': | 538 if __name__ == '__main__': |
| 497 sys.exit(Main(sys.argv)) | 539 sys.exit(Main(sys.argv)) |
| OLD | NEW |