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 # ....include/ | 21 # ....include/ |
| 22 # ......dart_api.h | 22 # ......dart_api.h |
| 23 # ......dart_debugger_api.h | 23 # ......dart_debugger_api.h |
| 24 # ....lib/ | 24 # ....lib/ |
| 25 # ......_internal/ | 25 # ......_internal/ |
| 26 # ......compiler/ | |
| 27 # ......core/ | 26 # ......core/ |
| 28 # ......coreimpl/ | 27 # ......coreimpl/ |
| 29 # ......crypto/ | 28 # ......crypto/ |
| 30 # ......html/ | 29 # ......html/ |
| 31 # ......io/ | 30 # ......io/ |
| 32 # ......isolate/ | 31 # ......isolate/ |
| 33 # ......json/ | 32 # ......json/ |
| 34 # ......math/ | 33 # ......math/ |
| 35 # ......mirrors/ | 34 # ......mirrors/ |
| 36 # ......uri/ | 35 # ......uri/ |
| 37 # ......utf/ | 36 # ......utf/ |
| 38 # ......web/ | 37 # ......web/ |
| 39 # ....pkg/ | 38 # ....pkg/ |
| 40 # ......args/ | 39 # ......args/ |
| 40 # ......compiler/ | |
| 41 # ......dartdoc/ | 41 # ......dartdoc/ |
| 42 # ......intl/ | 42 # ......intl/ |
| 43 # ......logging/ | 43 # ......logging/ |
| 44 # ......unittest/ | 44 # ......unittest/ |
| 45 # ......(more will come here) | 45 # ......(more will come here) |
| 46 # ....util/ | 46 # ....util/ |
| 47 # ......analyzer/ | 47 # ......analyzer/ |
| 48 # ........dart_analyzer.jar | 48 # ........dart_analyzer.jar |
| 49 # ........(third-party libraries for dart_analyzer) | 49 # ........(third-party libraries for dart_analyzer) |
| 50 # ......pub/ | 50 # ......pub/ |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 if utils.GuessOS() == 'win32': | 95 if utils.GuessOS() == 'win32': |
| 96 file_extension = '.bat' | 96 file_extension = '.bat' |
| 97 | 97 |
| 98 src = src_file + file_extension | 98 src = src_file + file_extension |
| 99 dest = join(dest_dir, basename(src_file) + file_extension) | 99 dest = join(dest_dir, basename(src_file) + file_extension) |
| 100 Copy(src, dest) | 100 Copy(src, dest) |
| 101 | 101 |
| 102 | 102 |
| 103 def CopyDart2Js(build_dir, sdk_root, revision): | 103 def CopyDart2Js(build_dir, sdk_root, revision): |
| 104 if revision: | 104 if revision: |
| 105 ReplaceInFiles([os.path.join(sdk_root, 'lib', 'compiler', | 105 ReplaceInFiles([os.path.join(sdk_root, 'pkg', 'compiler', |
| 106 'implementation', 'compiler.dart')], | 106 'implementation', 'compiler.dart')], |
| 107 [(r"BUILD_ID = 'build number could not be determined'", | 107 [(r"BUILD_ID = 'build number could not be determined'", |
| 108 r"BUILD_ID = '%s'" % revision)]) | 108 r"BUILD_ID = '%s'" % revision)]) |
| 109 if utils.GuessOS() == 'win32': | 109 if utils.GuessOS() == 'win32': |
| 110 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') | 110 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') |
| 111 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) | 111 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) |
| 112 ReplaceInFiles([dart2js], | 112 ReplaceInFiles([dart2js], |
| 113 [(r'%SCRIPTPATH%\.\.\\lib', | 113 [(r'%SCRIPTPATH%\.\.\\lib', |
| 114 r'%SCRIPTPATH%..\lib')]) | 114 r'%SCRIPTPATH%..\pkg')]) |
| 115 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') | 115 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') |
| 116 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) | 116 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) |
| 117 else: | 117 else: |
| 118 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') | 118 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') |
| 119 Copy(os.path.join(build_dir, 'dart2js'), dart2js) | 119 Copy(os.path.join(build_dir, 'dart2js'), dart2js) |
| 120 ReplaceInFiles([dart2js], | 120 ReplaceInFiles([dart2js], |
| 121 [(r'\$BIN_DIR/\.\./\.\./lib', | 121 [(r'\$BIN_DIR/\.\./\.\./lib', |
| 122 r'$BIN_DIR/../lib')]) | 122 r'$BIN_DIR/../pkg')]) |
| 123 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') | 123 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') |
| 124 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) | 124 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) |
| 125 | 125 |
| 126 | 126 |
| 127 def Main(argv): | 127 def Main(argv): |
| 128 # Pull in all of the gpyi files which will be munged into the sdk. | 128 # Pull in all of the gpyi files which will be munged into the sdk. |
| 129 io_runtime_sources = \ | 129 io_runtime_sources = \ |
| 130 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] | 130 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] |
| 131 | 131 |
| 132 HOME = dirname(dirname(realpath(__file__))) | 132 HOME = dirname(dirname(realpath(__file__))) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 assert filename.endswith('.dart') | 212 assert filename.endswith('.dart') |
| 213 if filename == 'io.dart': | 213 if filename == 'io.dart': |
| 214 continue | 214 continue |
| 215 dest_file.write('#source("runtime/' + filename + '");\n') | 215 dest_file.write('#source("runtime/' + filename + '");\n') |
| 216 dest_file.close() | 216 dest_file.close() |
| 217 | 217 |
| 218 # | 218 # |
| 219 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. | 219 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
| 220 # | 220 # |
| 221 | 221 |
| 222 for library in ['_internal', 'compiler', 'html', 'core', 'coreimpl', | 222 for library in ['_internal', 'html', 'core', 'coreimpl', |
| 223 'crypto', 'isolate', 'json', 'math', 'mirrors', 'uri', 'utf', | 223 'crypto', 'isolate', 'json', 'math', 'mirrors', 'uri', 'utf', |
| 224 'web']: | 224 'web']: |
| 225 copytree(join(HOME, 'lib', library), join(LIB, library), | 225 copytree(join(HOME, 'lib', library), join(LIB, library), |
| 226 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | 226 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) |
| 227 | 227 |
| 228 # TODO(dgrove): fix this really ugly hack | |
| 229 ReplaceInFiles( | |
| 230 [join(LIB, 'compiler', 'implementation', 'lib', 'io.dart')], | |
| 231 [('../../runtime/bin', '../io/runtime')]) | |
| 232 | 228 |
| 233 # Create and copy pkg. | 229 # Create and copy pkg. |
| 234 PKG = join(SDK_tmp, 'pkg') | 230 PKG = join(SDK_tmp, 'pkg') |
| 235 os.makedirs(PKG) | 231 os.makedirs(PKG) |
| 236 | 232 |
| 237 # | 233 # |
| 238 # Create and populate pkg/{args, intl, logging, unittest} | 234 # Create and populate pkg/{args, intl, logging, unittest} |
| 239 # | 235 # |
| 240 | 236 |
| 241 for library in ['args', 'dartdoc', 'intl', 'logging', 'unittest']: | 237 for library in ['args', 'dartdoc', 'intl', 'logging', 'unittest']: |
| 242 copytree(join(HOME, 'pkg', library), join(PKG, library), | 238 copytree(join(HOME, 'pkg', library), join(PKG, library), |
| 243 ignore=ignore_patterns('*.svn', 'doc', 'docs', | 239 ignore=ignore_patterns('*.svn', 'doc', 'docs', |
| 244 '*.py', '*.gypi', '*.sh')) | 240 '*.py', '*.gypi', '*.sh')) |
| 245 | 241 |
| 242 # TODO(dgrove): fix this really ugly hack. | |
| 243 copytree(join(HOME, 'lib', 'compiler'), join(PKG, 'compiler'), | |
| 244 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | |
| 245 | |
| 246 ReplaceInFiles( | |
| 247 [join(LIB, '_internal', 'libraries.dart')], | |
| 248 [('"compiler/', '"../pkg/compiler/')]) | |
|
danrubel
2012/09/06 21:49:42
If its not in the "lib" directory then it should n
| |
| 249 | |
| 250 ReplaceInFiles( | |
| 251 [join(PKG, 'compiler', 'implementation', 'lib', 'io.dart')], | |
| 252 [('../../runtime/bin', '../../lib/io/runtime')]) | |
| 253 | |
| 246 # Fixup dartdoc | 254 # Fixup dartdoc |
| 247 ReplaceInFiles([ | 255 ReplaceInFiles([ |
| 248 join(PKG, 'dartdoc', 'dartdoc.dart'), | 256 join(PKG, 'dartdoc', 'dartdoc.dart'), |
| 249 ], [ | 257 ], [ |
| 250 ("final bool IN_SDK = false;", | 258 ("final bool IN_SDK = false;", |
| 251 "final bool IN_SDK = true;"), | 259 "final bool IN_SDK = true;"), |
| 252 ]) | 260 ]) |
| 253 | 261 |
| 254 | 262 |
| 255 # Create and copy tools. | 263 # Create and copy tools. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 if revision is not None: | 297 if revision is not None: |
| 290 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 298 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 291 f.write(revision + '\n') | 299 f.write(revision + '\n') |
| 292 f.close() | 300 f.close() |
| 293 | 301 |
| 294 move(SDK_tmp, SDK) | 302 move(SDK_tmp, SDK) |
| 295 utils.Touch(os.path.join(SDK, 'create.stamp')) | 303 utils.Touch(os.path.join(SDK, 'create.stamp')) |
| 296 | 304 |
| 297 if __name__ == '__main__': | 305 if __name__ == '__main__': |
| 298 sys.exit(Main(sys.argv)) | 306 sys.exit(Main(sys.argv)) |
| OLD | NEW |