| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 Currently, we copy too much stuff to this location, but the SDK's | 127 Currently, we copy too much stuff to this location, but the SDK's |
| 128 layout matches the the layout of the part of the repository we're | 128 layout matches the the layout of the part of the repository we're |
| 129 dealing with here which frees us from rewriting files. The long term | 129 dealing with here which frees us from rewriting files. The long term |
| 130 plan is to align the layout of the repository and the SDK, at which | 130 plan is to align the layout of the repository and the SDK, at which |
| 131 point we should be able to simplify Main below and share the dart | 131 point we should be able to simplify Main below and share the dart |
| 132 files between the various components to minimize SDK download size. | 132 files between the various components to minimize SDK download size. |
| 133 ''' | 133 ''' |
| 134 copytree('lib', os.path.join(sdk_root, 'lib', 'dart2js', 'lib'), | 134 copytree('lib', os.path.join(sdk_root, 'lib', 'dart2js', 'lib'), |
| 135 ignore=ignore_patterns('.svn')) | 135 ignore=ignore_patterns('.svn')) |
| 136 copytree(os.path.join('corelib', 'src'), | |
| 137 os.path.join(sdk_root, 'lib', 'dart2js', 'corelib', 'src'), | |
| 138 ignore=ignore_patterns('.svn')) | |
| 139 copytree(os.path.join('runtime', 'lib'), | 136 copytree(os.path.join('runtime', 'lib'), |
| 140 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'lib'), | 137 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'lib'), |
| 141 ignore=ignore_patterns('.svn')) | 138 ignore=ignore_patterns('.svn')) |
| 142 copytree(os.path.join('runtime', 'bin'), | 139 copytree(os.path.join('runtime', 'bin'), |
| 143 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'bin'), | 140 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'bin'), |
| 144 ignore=ignore_patterns('.svn')) | 141 ignore=ignore_patterns('.svn')) |
| 145 if utils.GuessOS() == 'win32': | 142 if utils.GuessOS() == 'win32': |
| 146 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') | 143 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') |
| 147 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) | 144 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) |
| 148 ReplaceInFiles([dart2js], | 145 ReplaceInFiles([dart2js], |
| 149 [(r'%SCRIPTPATH%\.\.\\lib', | 146 [(r'%SCRIPTPATH%\.\.\\lib', |
| 150 r'%SCRIPTPATH%..\lib\dart2js\lib')]) | 147 r'%SCRIPTPATH%..\lib\dart2js\lib')]) |
| 151 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') | 148 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') |
| 152 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) | 149 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) |
| 153 else: | 150 else: |
| 154 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') | 151 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') |
| 155 Copy(os.path.join(build_dir, 'dart2js'), dart2js) | 152 Copy(os.path.join(build_dir, 'dart2js'), dart2js) |
| 156 ReplaceInFiles([dart2js], | 153 ReplaceInFiles([dart2js], |
| 157 [(r'\$BIN_DIR/\.\./\.\./lib', | 154 [(r'\$BIN_DIR/\.\./\.\./lib', |
| 158 r'$BIN_DIR/../lib/dart2js/lib')]) | 155 r'$BIN_DIR/../lib/dart2js/lib')]) |
| 159 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') | 156 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') |
| 160 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) | 157 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) |
| 161 | 158 |
| 162 | 159 |
| 163 def Main(argv): | 160 def Main(argv): |
| 164 # Pull in all of the gpyi files which will be munged into the sdk. | 161 # Pull in all of the gpyi files which will be munged into the sdk. |
| 165 builtin_runtime_sources = \ | |
| 166 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] | |
| 167 io_runtime_sources = \ | 162 io_runtime_sources = \ |
| 168 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] | 163 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] |
| 169 corelib_sources = \ | |
| 170 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] | |
| 171 corelib_runtime_sources = \ | |
| 172 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] | |
| 173 coreimpl_sources = \ | |
| 174 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ | |
| 175 ['sources'] | |
| 176 coreimpl_runtime_sources = \ | |
| 177 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources'] | |
| 178 | 164 |
| 179 HOME = dirname(dirname(realpath(__file__))) | 165 HOME = dirname(dirname(realpath(__file__))) |
| 180 | 166 |
| 181 SDK_tmp = tempfile.mkdtemp() | 167 SDK_tmp = tempfile.mkdtemp() |
| 182 SDK = argv[1] | 168 SDK = argv[1] |
| 183 | 169 |
| 184 # TODO(dgrove) - deal with architectures that are not ia32. | 170 # TODO(dgrove) - deal with architectures that are not ia32. |
| 185 | 171 |
| 186 if exists(SDK): | 172 if exists(SDK): |
| 187 rmtree(SDK) | 173 rmtree(SDK) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 join(INCLUDE, 'dart_api.h')) | 216 join(INCLUDE, 'dart_api.h')) |
| 231 copyfile(join(HOME, 'runtime', 'include', 'dart_debugger_api.h'), | 217 copyfile(join(HOME, 'runtime', 'include', 'dart_debugger_api.h'), |
| 232 join(INCLUDE, 'dart_debugger_api.h')) | 218 join(INCLUDE, 'dart_debugger_api.h')) |
| 233 | 219 |
| 234 # | 220 # |
| 235 # Create and populate sdk/lib. | 221 # Create and populate sdk/lib. |
| 236 # | 222 # |
| 237 | 223 |
| 238 LIB = join(SDK_tmp, 'lib') | 224 LIB = join(SDK_tmp, 'lib') |
| 239 os.makedirs(LIB) | 225 os.makedirs(LIB) |
| 240 corelib_dest_dir = join(LIB, 'core') | |
| 241 os.makedirs(corelib_dest_dir) | |
| 242 os.makedirs(join(corelib_dest_dir, 'runtime')) | |
| 243 | |
| 244 coreimpl_dest_dir = join(LIB, 'coreimpl') | |
| 245 os.makedirs(coreimpl_dest_dir) | |
| 246 os.makedirs(join(coreimpl_dest_dir, 'runtime')) | |
| 247 | |
| 248 | |
| 249 # | |
| 250 # Create and populate lib/builtin. | |
| 251 # | |
| 252 builtin_dest_dir = join(LIB, 'builtin') | |
| 253 os.makedirs(builtin_dest_dir) | |
| 254 assert len(builtin_runtime_sources) == 1 | |
| 255 assert builtin_runtime_sources[0] == 'builtin.dart' | |
| 256 copyfile(join(HOME, 'runtime', 'bin', 'builtin.dart'), | |
| 257 join(builtin_dest_dir, 'builtin_runtime.dart')) | |
| 258 # | |
| 259 # rename the print function in dart:builtin | |
| 260 # so that it does not conflict with the print function in dart:core | |
| 261 # | |
| 262 ReplaceInFiles([ | |
| 263 join(builtin_dest_dir, 'builtin_runtime.dart') | |
| 264 ], [ | |
| 265 ('void print\(', 'void builtinPrint(') | |
| 266 ]) | |
| 267 | 226 |
| 268 # | 227 # |
| 269 # Create and populate lib/io. | 228 # Create and populate lib/io. |
| 270 # | 229 # |
| 271 io_dest_dir = join(LIB, 'io') | 230 io_dest_dir = join(LIB, 'io') |
| 272 os.makedirs(io_dest_dir) | 231 os.makedirs(io_dest_dir) |
| 273 os.makedirs(join(io_dest_dir, 'runtime')) | 232 os.makedirs(join(io_dest_dir, 'runtime')) |
| 274 for filename in io_runtime_sources: | 233 for filename in io_runtime_sources: |
| 275 assert filename.endswith('.dart') | 234 assert filename.endswith('.dart') |
| 276 if filename == 'io.dart': | 235 if filename == 'io.dart': |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 # Create and populate lib/dom. | 285 # Create and populate lib/dom. |
| 327 # | 286 # |
| 328 dom_src_dir = join(HOME, 'lib', 'dom') | 287 dom_src_dir = join(HOME, 'lib', 'dom') |
| 329 dom_dest_dir = join(LIB, 'dom') | 288 dom_dest_dir = join(LIB, 'dom') |
| 330 os.makedirs(dom_dest_dir) | 289 os.makedirs(dom_dest_dir) |
| 331 | 290 |
| 332 copyfile(join(dom_src_dir, 'dart2js', 'dom_dart2js.dart'), | 291 copyfile(join(dom_src_dir, 'dart2js', 'dom_dart2js.dart'), |
| 333 join(dom_dest_dir, 'dom_dart2js.dart')) | 292 join(dom_dest_dir, 'dom_dart2js.dart')) |
| 334 | 293 |
| 335 # | 294 # |
| 336 # Create and populate lib/{crypto, json, uri, utf, ...}. | 295 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
| 337 # | 296 # |
| 338 | 297 |
| 339 for library in ['_internal', 'crypto', 'json', 'math', 'mirrors', 'uri', | 298 for library in ['_internal', 'core', 'coreimpl', 'crypto', 'isolate', 'json', |
| 340 'utf', 'web']: | 299 'math', 'mirrors', 'uri', 'utf', 'web']: |
| 341 src_dir = join(HOME, 'lib', library) | 300 src_dir = join(HOME, 'lib', library) |
| 342 dest_dir = join(LIB, library) | 301 dest_dir = join(LIB, library) |
| 343 os.makedirs(dest_dir) | 302 os.makedirs(dest_dir) |
| 344 | 303 |
| 345 for filename in os.listdir(src_dir): | 304 for filename in os.listdir(src_dir): |
| 346 if filename.endswith('.dart'): | 305 if filename.endswith('.dart'): |
| 347 copyfile(join(src_dir, filename), join(dest_dir, filename)) | 306 copyfile(join(src_dir, filename), join(dest_dir, filename)) |
| 348 | 307 |
| 349 # Create and populate lib/isolate | |
| 350 copytree(join(HOME, 'lib', 'isolate'), join(LIB, 'isolate'), | |
| 351 ignore=ignore_patterns('.svn')) | |
| 352 | |
| 353 # | |
| 354 # Create and populate lib/core. | |
| 355 # | |
| 356 | |
| 357 # First, copy corelib/* to lib/runtime | |
| 358 for filename in corelib_sources: | |
| 359 for target_dir in ['runtime']: | |
| 360 copyfile(join('corelib', 'src', filename), | |
| 361 join(corelib_dest_dir, target_dir, filename)) | |
| 362 | |
| 363 # Next, copy the runtime library source on top of core/runtime | |
| 364 for filename in corelib_runtime_sources: | |
| 365 if filename.endswith('.dart'): | |
| 366 copyfile(join('runtime', 'lib', filename), | |
| 367 join(corelib_dest_dir, 'runtime', filename)) | |
| 368 | |
| 369 # | |
| 370 # At this point, it's time to create lib/core/core*dart . | |
| 371 # | |
| 372 # construct lib/core_runtime.dart from whole cloth. | |
| 373 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w') | |
| 374 dest_file.write('#library("dart:core");\n') | |
| 375 dest_file.write('#import("dart:coreimpl");\n') | |
| 376 dest_file.write('#import("dart:math");\n') | |
| 377 for filename in corelib_sources: | |
| 378 dest_file.write('#source("runtime/' + filename + '");\n') | |
| 379 for filename in corelib_runtime_sources: | |
| 380 if filename.endswith('.dart'): | |
| 381 dest_file.write('#source("runtime/' + filename + '");\n') | |
| 382 # include the missing print function | |
| 383 dest_file.write('void print(Object arg) { /* native */ }\n') | |
| 384 dest_file.close() | |
| 385 | |
| 386 # | |
| 387 # Create and populate lib/coreimpl. | |
| 388 # | |
| 389 | |
| 390 # First, copy corelib/src/implementation to corelib/runtime. | |
| 391 for filename in coreimpl_sources: | |
| 392 for target_dir in ['runtime']: | |
| 393 copyfile(join('corelib', 'src', 'implementation', filename), | |
| 394 join(coreimpl_dest_dir, target_dir, filename)) | |
| 395 | |
| 396 for filename in coreimpl_runtime_sources: | |
| 397 if filename.endswith('.dart') and not filename.endswith('_patch.dart'): | |
| 398 copyfile(join('runtime', 'lib', filename), | |
| 399 join(coreimpl_dest_dir, 'runtime', filename)) | |
| 400 | |
| 401 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth. | |
| 402 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w') | |
| 403 dest_file.write('#library("dart:coreimpl");\n') | |
| 404 dest_file.write('#import("dart:math");\n') | |
| 405 for filename in coreimpl_sources: | |
| 406 dest_file.write('#source("runtime/' + filename + '");\n') | |
| 407 for filename in coreimpl_runtime_sources: | |
| 408 if filename.endswith('.dart') and not filename.endswith('_patch.dart'): | |
| 409 dest_file.write('#source("runtime/' + filename + '");\n') | |
| 410 dest_file.close() | |
| 411 | |
| 412 | |
| 413 # Create and copy pkg. | 308 # Create and copy pkg. |
| 414 PKG = join(SDK_tmp, 'pkg') | 309 PKG = join(SDK_tmp, 'pkg') |
| 415 os.makedirs(PKG) | 310 os.makedirs(PKG) |
| 416 | 311 |
| 417 # | 312 # |
| 418 # Create and populate pkg/{args, intl, logging, unittest} | 313 # Create and populate pkg/{args, intl, logging, unittest} |
| 419 # | 314 # |
| 420 | 315 |
| 421 for library in ['args', 'intl', 'logging', 'unittest']: | 316 for library in ['args', 'intl', 'logging', 'unittest']: |
| 422 src_dir = join(HOME, 'pkg', library) | 317 src_dir = join(HOME, 'pkg', library) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 if revision is not None: | 386 if revision is not None: |
| 492 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 387 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 493 f.write(revision + '\n') | 388 f.write(revision + '\n') |
| 494 f.close() | 389 f.close() |
| 495 | 390 |
| 496 move(SDK_tmp, SDK) | 391 move(SDK_tmp, SDK) |
| 497 utils.Touch(os.path.join(SDK, 'create.stamp')) | 392 utils.Touch(os.path.join(SDK, 'create.stamp')) |
| 498 | 393 |
| 499 if __name__ == '__main__': | 394 if __name__ == '__main__': |
| 500 sys.exit(Main(sys.argv)) | 395 sys.exit(Main(sys.argv)) |
| OLD | NEW |