Chromium Code Reviews| 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 # ........dart2js.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 |
| 104 def CreateSnapshots(build_dir, sdk_root, internal_build_dir): | |
| 105 snapshots = [os.path.join(internal_build_dir, 'compiler', | |
| 106 'implementation', 'dart2js.dart')] | |
| 107 for snapshot in snapshots: | |
| 108 snapshot_name = os.path.join(sdk_root, 'bin', 'snapshots', | |
| 109 basename(snapshot) + '.snapshot') | |
| 110 subprocess.call([os.path.join(build_dir, 'dart'), | |
|
kustermann
2013/04/09 15:02:28
Does this work on windows as well (or do we need t
ricow1
2013/04/09 15:26:59
This is using this existing code on with other arg
| |
| 111 '--generate-script-snapshot=%s' % | |
| 112 snapshot_name, | |
|
kustermann
2013/04/09 15:02:28
You could move this a line up.
| |
| 113 snapshot]) | |
| 114 | |
| 115 | |
| 102 def CopyDartScripts(home, build_dir, sdk_root, version): | 116 def CopyDartScripts(home, build_dir, sdk_root, version): |
| 117 # We create a copy internal that we can use to create the snapshot | |
| 118 # with the right version from | |
| 119 internal_build_dir = os.path.join(sdk_root, '_internal') | |
| 120 if exists(internal_build_dir): | |
| 121 rmtree(internal_build_dir); | |
| 122 copytree(os.path.join(home, 'sdk', 'lib', '_internal'), | |
| 123 internal_build_dir) | |
|
ahe
2013/04/09 14:37:21
Did you test that this works? The relative refere
ricow1
2013/04/09 15:26:59
As discussed offline I will change this to a wrapp
| |
| 124 | |
| 103 if version: | 125 if version: |
| 104 ReplaceInFiles([os.path.join(sdk_root, 'lib', '_internal', 'compiler', | 126 ReplaceInFiles([os.path.join(internal_build_dir, 'compiler', |
| 105 'implementation', 'compiler.dart')], | 127 'implementation', 'compiler.dart')], |
| 106 [(r"BUILD_ID = 'build number could not be determined'", | 128 [(r"BUILD_ID = 'build number could not be determined'", |
| 107 r"BUILD_ID = '%s'" % version)]) | 129 r"BUILD_ID = '%s'" % version)]) |
| 108 # TODO(dgrove) - add pub once issue 6619 is fixed | 130 # TODO(dgrove) - add pub once issue 6619 is fixed |
| 109 for executable in ['dart2js', 'dartdoc']: | 131 for executable in ['dart2js', 'dartdoc']: |
| 110 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), | 132 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), |
| 111 os.path.join(sdk_root, 'bin')) | 133 os.path.join(sdk_root, 'bin')) |
| 112 | 134 |
| 113 subprocess.call([os.path.join(build_dir, 'dart'), | 135 CreateSnapshots(build_dir, sdk_root, internal_build_dir) |
| 114 '--generate-script-snapshot=%s' % | 136 rmtree(internal_build_dir) |
| 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 | |
| 120 | 137 |
| 121 | 138 |
| 122 def Main(argv): | 139 def Main(argv): |
| 123 # Pull in all of the gpyi files which will be munged into the sdk. | 140 # Pull in all of the gpyi files which will be munged into the sdk. |
|
kustermann
2013/04/09 15:02:28
gpyi -> gypi
ricow1
2013/04/09 15:26:59
Done.
| |
| 124 HOME = dirname(dirname(realpath(__file__))) | 141 HOME = dirname(dirname(realpath(__file__))) |
| 125 | 142 |
| 126 SDK = argv[1] | 143 SDK = argv[1] |
| 127 SDK_tmp = '%s.tmp' % SDK | 144 SDK_tmp = '%s.tmp' % SDK |
| 128 | 145 |
| 129 # TODO(dgrove) - deal with architectures that are not ia32. | 146 # TODO(dgrove) - deal with architectures that are not ia32. |
| 130 | 147 |
| 131 if exists(SDK): | 148 if exists(SDK): |
| 132 rmtree(SDK) | 149 rmtree(SDK) |
| 133 | 150 |
| 134 if exists(SDK_tmp): | 151 if exists(SDK_tmp): |
| 135 rmtree(SDK_tmp) | 152 rmtree(SDK_tmp) |
| 136 | 153 |
| 137 os.makedirs(SDK_tmp) | 154 os.makedirs(SDK_tmp) |
| 138 | 155 |
| 139 # Create and populate sdk/bin. | 156 # Create and populate sdk/bin. |
| 140 BIN = join(SDK_tmp, 'bin') | 157 BIN = join(SDK_tmp, 'bin') |
| 141 os.makedirs(BIN) | 158 os.makedirs(BIN) |
| 159 SNAPSHOTS = join(BIN, 'snapshots') | |
| 160 os.makedirs(SNAPSHOTS) | |
| 142 | 161 |
| 143 # Copy the Dart VM binary and the Windows Dart VM link library | 162 # Copy the Dart VM binary and the Windows Dart VM link library |
| 144 # into sdk/bin. | 163 # into sdk/bin. |
| 145 # | 164 # |
| 146 # TODO(dgrove) - deal with architectures that are not ia32. | 165 # TODO(dgrove) - deal with architectures that are not ia32. |
| 147 build_dir = os.path.dirname(argv[1]) | 166 build_dir = os.path.dirname(argv[1]) |
| 148 dart_file_extension = '' | 167 dart_file_extension = '' |
| 149 analyzer_file_extension = '' | 168 analyzer_file_extension = '' |
| 150 if HOST_OS == 'win32': | 169 if HOST_OS == 'win32': |
| 151 dart_file_extension = '.exe' | 170 dart_file_extension = '.exe' |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 # | 211 # |
| 193 | 212 |
| 194 LIB = join(SDK_tmp, 'lib') | 213 LIB = join(SDK_tmp, 'lib') |
| 195 os.makedirs(LIB) | 214 os.makedirs(LIB) |
| 196 | 215 |
| 197 # | 216 # |
| 198 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. | 217 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
| 199 # | 218 # |
| 200 | 219 |
| 201 os.makedirs(join(LIB, 'html')) | 220 os.makedirs(join(LIB, 'html')) |
| 202 for library in ['_internal', 'async', 'collection', '_collection_dev', 'core', | 221 |
| 222 # Remove _internal/compiler/implementation/lib when we can add that | |
| 223 # as part of the dart2js snapshot. | |
| 224 for library in ['_internal/compiler/implementation/lib', | |
| 225 'async', 'collection', '_collection_dev', 'core', | |
| 203 'crypto', 'io', 'isolate', | 226 'crypto', 'io', 'isolate', |
| 204 join('chrome', 'dart2js'), join('chrome', 'dartium'), | 227 join('chrome', 'dart2js'), join('chrome', 'dartium'), |
| 205 join('html', 'dart2js'), join('html', 'dartium'), | 228 join('html', 'dart2js'), join('html', 'dartium'), |
| 206 join('html', 'html_common'), | 229 join('html', 'html_common'), |
| 207 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), | 230 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), |
| 208 'json', 'math', 'mirrors', 'typeddata', | 231 'json', 'math', 'mirrors', 'typeddata', |
| 209 join('svg', 'dart2js'), join('svg', 'dartium'), | 232 join('svg', 'dart2js'), join('svg', 'dartium'), |
| 210 'uri', 'utf', | 233 'uri', 'utf', |
| 211 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), | 234 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), |
| 212 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), | 235 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), |
| 213 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: | 236 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: |
| 214 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), | 237 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), |
| 215 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | 238 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) |
| 216 | 239 |
| 240 # Remove this once we can add it as part of the dart2js snapshot. | |
|
ahe
2013/04/09 14:37:21
The Editor will still need it.
| |
| 241 copyfile(join(HOME, 'sdk', 'lib', '_internal', 'libraries.dart'), | |
| 242 join(LIB, '_internal', 'libraries.dart')) | |
| 217 | 243 |
| 218 # Create and copy packages. | 244 # Create and copy packages. |
| 219 PACKAGES = join(SDK_tmp, 'packages') | 245 PACKAGES = join(SDK_tmp, 'packages') |
| 220 os.makedirs(PACKAGES) | 246 os.makedirs(PACKAGES) |
| 221 | 247 |
| 222 # | 248 # |
| 223 # Create and populate packages/{args, intl, logging, meta, unittest, ...} | 249 # Create and populate packages/{args, intl, logging, meta, unittest, ...} |
| 224 # | 250 # |
| 225 | 251 |
| 226 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', | 252 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 312 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 287 f.write(revision + '\n') | 313 f.write(revision + '\n') |
| 288 f.close() | 314 f.close() |
| 289 | 315 |
| 290 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) | 316 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) |
| 291 | 317 |
| 292 move(SDK_tmp, SDK) | 318 move(SDK_tmp, SDK) |
| 293 | 319 |
| 294 if __name__ == '__main__': | 320 if __name__ == '__main__': |
| 295 sys.exit(Main(sys.argv)) | 321 sys.exit(Main(sys.argv)) |
| OLD | NEW |