| 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 # |
| 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/ |
| 22 # ........utils_wrapper.dart.snapshot |
| 21 # ....include/ | 23 # ....include/ |
| 22 # ......dart_api.h | 24 # ......dart_api.h |
| 23 # ......dart_debugger_api.h | 25 # ......dart_debugger_api.h |
| 24 # ....lib/ | 26 # ....lib/ |
| 25 # ......_internal/ | 27 # ......_internal/ |
| 26 # ......async/ | 28 # ......async/ |
| 27 # ......collection/ | 29 # ......collection/ |
| 28 # ......_collection_dev/ | 30 # ......_collection_dev/ |
| 29 # ......core/ | 31 # ......core/ |
| 30 # ......crypto/ | 32 # ......crypto/ |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 using the appropriate platform-specific file extension.''' | 94 using the appropriate platform-specific file extension.''' |
| 93 file_extension = '' | 95 file_extension = '' |
| 94 if HOST_OS == 'win32': | 96 if HOST_OS == 'win32': |
| 95 file_extension = '.bat' | 97 file_extension = '.bat' |
| 96 | 98 |
| 97 src = src_file + file_extension | 99 src = src_file + file_extension |
| 98 dest = join(dest_dir, basename(src_file) + file_extension) | 100 dest = join(dest_dir, basename(src_file) + file_extension) |
| 99 Copy(src, dest) | 101 Copy(src, dest) |
| 100 | 102 |
| 101 | 103 |
| 102 def CopyDartScripts(home, build_dir, sdk_root, version): | 104 def CopyDartScripts(home, sdk_root): |
| 103 if version: | |
| 104 ReplaceInFiles([os.path.join(sdk_root, 'lib', '_internal', 'compiler', | |
| 105 'implementation', 'compiler.dart')], | |
| 106 [(r"BUILD_ID = 'build number could not be determined'", | |
| 107 r"BUILD_ID = '%s'" % version)]) | |
| 108 # TODO(dgrove) - add pub once issue 6619 is fixed | 105 # TODO(dgrove) - add pub once issue 6619 is fixed |
| 109 for executable in ['dart2js', 'dartdoc']: | 106 for executable in ['dart2js', 'dartdoc']: |
| 110 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), | 107 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), |
| 111 os.path.join(sdk_root, 'bin')) | 108 os.path.join(sdk_root, 'bin')) |
| 112 | 109 |
| 113 subprocess.call([os.path.join(build_dir, 'dart'), | |
| 114 '--generate-script-snapshot=%s' % | |
| 115 os.path.join(sdk_root, 'lib', '_internal', 'compiler', | |
| 116 'implementation', 'dart2js.dart.snapshot'), | |
| 117 os.path.join(sdk_root, 'lib', '_internal', 'compiler', | |
| 118 'implementation', 'dart2js.dart')]) | |
| 119 | 110 |
| 111 def CopySnapshots(snapshot, sdk_root): |
| 112 copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot))) |
| 120 | 113 |
| 121 | 114 |
| 122 def Main(argv): | 115 def Main(argv): |
| 123 # Pull in all of the gpyi files which will be munged into the sdk. | 116 # Pull in all of the gypi files which will be munged into the sdk. |
| 124 HOME = dirname(dirname(realpath(__file__))) | 117 HOME = dirname(dirname(realpath(__file__))) |
| 125 | 118 |
| 119 # TODO(ricow): change to use option parser, issue 9820. |
| 126 SDK = argv[1] | 120 SDK = argv[1] |
| 127 SDK_tmp = '%s.tmp' % SDK | 121 SDK_tmp = '%s.tmp' % SDK |
| 128 | 122 |
| 123 SNAPSHOT_LOCATION = argv[2] |
| 124 SNAPSHOT = join(SNAPSHOT_LOCATION, 'utils_wrapper.dart.snapshot') |
| 125 |
| 129 # TODO(dgrove) - deal with architectures that are not ia32. | 126 # TODO(dgrove) - deal with architectures that are not ia32. |
| 130 | 127 |
| 131 if exists(SDK): | 128 if exists(SDK): |
| 132 rmtree(SDK) | 129 rmtree(SDK) |
| 133 | 130 |
| 134 if exists(SDK_tmp): | 131 if exists(SDK_tmp): |
| 135 rmtree(SDK_tmp) | 132 rmtree(SDK_tmp) |
| 136 | 133 |
| 137 os.makedirs(SDK_tmp) | 134 os.makedirs(SDK_tmp) |
| 138 | 135 |
| 139 # Create and populate sdk/bin. | 136 # Create and populate sdk/bin. |
| 140 BIN = join(SDK_tmp, 'bin') | 137 BIN = join(SDK_tmp, 'bin') |
| 141 os.makedirs(BIN) | 138 os.makedirs(BIN) |
| 142 | 139 |
| 140 os.makedirs(join(BIN, 'snapshots')) |
| 141 |
| 143 # Copy the Dart VM binary and the Windows Dart VM link library | 142 # Copy the Dart VM binary and the Windows Dart VM link library |
| 144 # into sdk/bin. | 143 # into sdk/bin. |
| 145 # | 144 # |
| 146 # TODO(dgrove) - deal with architectures that are not ia32. | 145 # TODO(dgrove) - deal with architectures that are not ia32. |
| 147 build_dir = os.path.dirname(argv[1]) | 146 build_dir = os.path.dirname(argv[1]) |
| 148 dart_file_extension = '' | 147 dart_file_extension = '' |
| 149 analyzer_file_extension = '' | 148 analyzer_file_extension = '' |
| 150 if HOST_OS == 'win32': | 149 if HOST_OS == 'win32': |
| 151 dart_file_extension = '.exe' | 150 dart_file_extension = '.exe' |
| 152 analyzer_file_extension = '.bat' | 151 analyzer_file_extension = '.bat' |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 # | 191 # |
| 193 | 192 |
| 194 LIB = join(SDK_tmp, 'lib') | 193 LIB = join(SDK_tmp, 'lib') |
| 195 os.makedirs(LIB) | 194 os.makedirs(LIB) |
| 196 | 195 |
| 197 # | 196 # |
| 198 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. | 197 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
| 199 # | 198 # |
| 200 | 199 |
| 201 os.makedirs(join(LIB, 'html')) | 200 os.makedirs(join(LIB, 'html')) |
| 202 for library in ['_internal', 'async', 'collection', '_collection_dev', 'core', | 201 |
| 202 for library in ['_internal/compiler/implementation/lib', |
| 203 'async', 'collection', '_collection_dev', 'core', |
| 203 'crypto', 'io', 'isolate', | 204 'crypto', 'io', 'isolate', |
| 204 join('chrome', 'dart2js'), join('chrome', 'dartium'), | 205 join('chrome', 'dart2js'), join('chrome', 'dartium'), |
| 205 join('html', 'dart2js'), join('html', 'dartium'), | 206 join('html', 'dart2js'), join('html', 'dartium'), |
| 206 join('html', 'html_common'), | 207 join('html', 'html_common'), |
| 207 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), | 208 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), |
| 208 'json', 'math', 'mirrors', 'typeddata', | 209 'json', 'math', 'mirrors', 'typeddata', |
| 209 join('svg', 'dart2js'), join('svg', 'dartium'), | 210 join('svg', 'dart2js'), join('svg', 'dartium'), |
| 210 'uri', 'utf', | 211 'uri', 'utf', |
| 211 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), | 212 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), |
| 212 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), | 213 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), |
| 213 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: | 214 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: |
| 214 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), | 215 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), |
| 215 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | 216 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) |
| 216 | 217 |
| 218 # This is used by both the editor and dart2js, remove this once we moved |
| 219 # out the compiler functionality from sdk/lib/_internal. See issue 9801. |
| 220 copyfile(join(HOME, 'sdk', 'lib', '_internal', 'libraries.dart'), |
| 221 join(LIB, '_internal', 'libraries.dart')) |
| 217 | 222 |
| 218 # Create and copy packages. | 223 # Create and copy packages. |
| 219 PACKAGES = join(SDK_tmp, 'packages') | 224 PACKAGES = join(SDK_tmp, 'packages') |
| 220 os.makedirs(PACKAGES) | 225 os.makedirs(PACKAGES) |
| 221 | 226 |
| 222 # | 227 # |
| 223 # Create and populate packages/{args, intl, logging, meta, unittest, ...} | 228 # Create and populate packages/{args, intl, logging, meta, unittest, ...} |
| 224 # | 229 # |
| 225 | 230 |
| 226 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', | 231 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 join(join(UTIL, 'pub'), '7zip'), | 267 join(join(UTIL, 'pub'), '7zip'), |
| 263 ignore=ignore_patterns('.svn')) | 268 ignore=ignore_patterns('.svn')) |
| 264 | 269 |
| 265 ReplaceInFiles([ | 270 ReplaceInFiles([ |
| 266 join(UTIL, 'pub', 'io.dart'), | 271 join(UTIL, 'pub', 'io.dart'), |
| 267 ], [ | 272 ], [ |
| 268 ("../../third_party/7zip/7za.exe", | 273 ("../../third_party/7zip/7za.exe", |
| 269 "7zip/7za.exe"), | 274 "7zip/7za.exe"), |
| 270 ]) | 275 ]) |
| 271 | 276 |
| 272 version = utils.GetVersion() | |
| 273 | |
| 274 # Copy dart2js/dartdoc/pub. | 277 # Copy dart2js/dartdoc/pub. |
| 275 CopyDartScripts(HOME, build_dir, SDK_tmp, version) | 278 CopyDartScripts(HOME, SDK_tmp) |
| 279 CopySnapshots(SNAPSHOT, SDK_tmp) |
| 276 | 280 |
| 277 # Write the 'version' file | 281 # Write the 'version' file |
| 282 version = utils.GetVersion() |
| 278 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') | 283 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') |
| 279 versionFile.write(version + '\n') | 284 versionFile.write(version + '\n') |
| 280 versionFile.close() | 285 versionFile.close() |
| 281 | 286 |
| 282 # Write the 'revision' file | 287 # Write the 'revision' file |
| 283 revision = utils.GetSVNRevision() | 288 revision = utils.GetSVNRevision() |
| 284 | 289 |
| 285 if revision is not None: | 290 if revision is not None: |
| 286 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 291 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 287 f.write(revision + '\n') | 292 f.write(revision + '\n') |
| 288 f.close() | 293 f.close() |
| 289 | 294 |
| 290 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) | 295 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) |
| 291 | 296 |
| 292 move(SDK_tmp, SDK) | 297 move(SDK_tmp, SDK) |
| 293 | 298 |
| 294 if __name__ == '__main__': | 299 if __name__ == '__main__': |
| 295 sys.exit(Main(sys.argv)) | 300 sys.exit(Main(sys.argv)) |
| OLD | NEW |