Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
|
dgrove
2012/09/05 00:05:56
Generally, compare this file to itself @ r11740
| |
| 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 # ......builtin/ | 25 # ......_internal/ |
| 26 # ........builtin_runtime.dart | 26 # ......compiler/ |
| 27 # ......config/ | |
| 28 # ......core/ | |
| 29 # ......coreimpl/ | |
| 30 # ......crypto/ | |
| 31 # ......html/ | |
| 27 # ......io/ | 32 # ......io/ |
| 28 # ........io_runtime.dart | |
| 29 # ........runtime/ | |
| 30 # ......compiler/ | |
| 31 # ......core/ | |
| 32 # ........core_runtime.dart | |
| 33 # ........runtime/ | |
| 34 # ......coreimpl/ | |
| 35 # ........coreimpl_runtime.dart | |
| 36 # ........runtime/ | |
| 37 # ......dart2js/ | |
| 38 # ......isolate/ | 33 # ......isolate/ |
| 39 # ........isolate_{dart2js, runtime}.dart | |
| 40 # ........dart2js/ | |
| 41 # ......dom/ | |
| 42 # ........dom.dart | |
| 43 # ......html/ | |
| 44 # ........html_dart2js.dart | |
| 45 # ........html_dartium.dart | |
| 46 # ......crypto/ | |
| 47 # ........crypto.dart | |
| 48 # ........(implementation files) | |
| 49 # ......json/ | 34 # ......json/ |
| 50 # ........json_frog.dart | 35 # ......math/ |
| 51 #.........json.dart | |
| 52 # ........{frog}/ | |
| 53 # ......mirrors/ | 36 # ......mirrors/ |
| 54 # ........mirrors.dart | |
| 55 # ......uri/ | 37 # ......uri/ |
| 56 # ........uri.dart | |
| 57 # ......utf/ | 38 # ......utf/ |
| 58 # ......web/ | 39 # ......web/ |
| 59 # ........web.dart | |
| 60 # ....pkg/ | 40 # ....pkg/ |
| 61 # ......args/ | 41 # ......args/ |
| 62 # ......dartdoc/ | 42 # ......dartdoc/ |
| 63 # ......intl/ | 43 # ......intl/ |
| 64 # ......logging/ | 44 # ......logging/ |
| 45 # ......unittest/ | |
| 65 # ......(more will come here) | 46 # ......(more will come here) |
| 66 # ....util/ | 47 # ....util/ |
| 67 # ......analyzer/ | 48 # ......analyzer/ |
| 68 # ........dart_analyzer.jar | 49 # ........dart_analyzer.jar |
| 69 # ........(third-party libraries for dart_analyzer) | 50 # ........(third-party libraries for dart_analyzer) |
| 70 # ......pub/ | 51 # ......pub/ |
| 71 # ......(more will come here) | 52 # ......(more will come here) |
| 72 | 53 |
| 73 | 54 |
| 74 | 55 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 file_extension = '' | 95 file_extension = '' |
| 115 if utils.GuessOS() == 'win32': | 96 if utils.GuessOS() == 'win32': |
| 116 file_extension = '.bat' | 97 file_extension = '.bat' |
| 117 | 98 |
| 118 src = src_file + file_extension | 99 src = src_file + file_extension |
| 119 dest = join(dest_dir, basename(src_file) + file_extension) | 100 dest = join(dest_dir, basename(src_file) + file_extension) |
| 120 Copy(src, dest) | 101 Copy(src, dest) |
| 121 | 102 |
| 122 | 103 |
| 123 def CopyDart2Js(build_dir, sdk_root, revision): | 104 def CopyDart2Js(build_dir, sdk_root, revision): |
| 124 ''' | |
| 125 Install dart2js in SDK/lib/dart2js. | |
| 126 | |
| 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 | |
| 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 | |
| 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. | |
| 133 ''' | |
| 134 dart2js_lib = os.path.join(sdk_root, 'lib', 'dart2js', 'lib') | |
| 135 copytree('lib', dart2js_lib, ignore=ignore_patterns('.svn')) | |
| 136 copytree(os.path.join('runtime', 'lib'), | |
| 137 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'lib'), | |
| 138 ignore=ignore_patterns('.svn')) | |
| 139 copytree(os.path.join('runtime', 'bin'), | |
| 140 os.path.join(sdk_root, 'lib', 'dart2js', 'runtime', 'bin'), | |
| 141 ignore=ignore_patterns('.svn')) | |
| 142 if revision: | 105 if revision: |
| 143 ReplaceInFiles([os.path.join(dart2js_lib, | 106 ReplaceInFiles([os.path.join(sdk_root, 'lib', 'compiler', |
| 144 'compiler/implementation/compiler.dart')], | 107 'implementation', 'compiler.dart')], |
| 145 [(r"BUILD_ID = 'build number could not be determined'", | 108 [(r"BUILD_ID = 'build number could not be determined'", |
| 146 r"BUILD_ID = '%s'" % revision)]) | 109 r"BUILD_ID = '%s'" % revision)]) |
| 147 if utils.GuessOS() == 'win32': | 110 if utils.GuessOS() == 'win32': |
| 148 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') | 111 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') |
| 149 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) | 112 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) |
| 150 ReplaceInFiles([dart2js], | 113 ReplaceInFiles([dart2js], |
| 151 [(r'%SCRIPTPATH%\.\.\\lib', | 114 [(r'%SCRIPTPATH%\.\.\\lib', |
| 152 r'%SCRIPTPATH%..\lib\dart2js\lib')]) | 115 r'%SCRIPTPATH%..\lib')]) |
| 153 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') | 116 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') |
| 154 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) | 117 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) |
| 155 else: | 118 else: |
| 156 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') | 119 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') |
| 157 Copy(os.path.join(build_dir, 'dart2js'), dart2js) | 120 Copy(os.path.join(build_dir, 'dart2js'), dart2js) |
| 158 ReplaceInFiles([dart2js], | 121 ReplaceInFiles([dart2js], |
| 159 [(r'\$BIN_DIR/\.\./\.\./lib', | 122 [(r'\$BIN_DIR/\.\./\.\./lib', |
| 160 r'$BIN_DIR/../lib/dart2js/lib')]) | 123 r'$BIN_DIR/../lib')]) |
| 161 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') | 124 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') |
| 162 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) | 125 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) |
| 163 | 126 |
| 164 | 127 |
| 165 def Main(argv): | 128 def Main(argv): |
| 166 # Pull in all of the gpyi files which will be munged into the sdk. | 129 # Pull in all of the gpyi files which will be munged into the sdk. |
| 167 io_runtime_sources = \ | 130 io_runtime_sources = \ |
| 168 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] | 131 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] |
| 169 | 132 |
| 170 HOME = dirname(dirname(realpath(__file__))) | 133 HOME = dirname(dirname(realpath(__file__))) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 # Construct lib/io/io_runtime.dart from whole cloth. | 210 # Construct lib/io/io_runtime.dart from whole cloth. |
| 248 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a') | 211 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a') |
| 249 for filename in io_runtime_sources: | 212 for filename in io_runtime_sources: |
| 250 assert filename.endswith('.dart') | 213 assert filename.endswith('.dart') |
| 251 if filename == 'io.dart': | 214 if filename == 'io.dart': |
| 252 continue | 215 continue |
| 253 dest_file.write('#source("runtime/' + filename + '");\n') | 216 dest_file.write('#source("runtime/' + filename + '");\n') |
| 254 dest_file.close() | 217 dest_file.close() |
| 255 | 218 |
| 256 # | 219 # |
| 257 # Create and populate lib/compiler. | |
| 258 # | |
| 259 compiler_src_dir = join(HOME, 'lib', 'compiler') | |
| 260 compiler_dest_dir = join(LIB, 'compiler') | |
| 261 | |
| 262 copytree(compiler_src_dir, compiler_dest_dir, ignore=ignore_patterns('.svn')) | |
| 263 | |
| 264 # Remap imports in lib/compiler/* . | |
| 265 for (dirpath, subdirs, filenames) in os.walk(compiler_dest_dir): | |
| 266 for filename in filenames: | |
| 267 if filename.endswith('.dart'): | |
| 268 filename = join(dirpath, filename) | |
| 269 file_contents = open(filename).read() | |
| 270 file = open(filename, 'w') | |
| 271 file_contents = re.sub(r"\.\./lib", "..", file_contents) | |
| 272 file.write(file_contents) | |
| 273 file.close() | |
| 274 | |
| 275 # | |
| 276 # Create and populate lib/html. | |
| 277 # | |
| 278 html_src_dir = join(HOME, 'lib', 'html') | |
| 279 html_dest_dir = join(LIB, 'html') | |
| 280 os.makedirs(html_dest_dir) | |
| 281 | |
| 282 copyfile(join(html_src_dir, 'dart2js', 'html_dart2js.dart'), | |
| 283 join(html_dest_dir, 'html_dart2js.dart')) | |
| 284 copyfile(join(html_src_dir, 'dartium', 'html_dartium.dart'), | |
| 285 join(html_dest_dir, 'html_dartium.dart')) | |
| 286 copyfile(join(html_src_dir, 'dartium', 'nativewrappers.dart'), | |
| 287 join(html_dest_dir, 'nativewrappers.dart')) | |
| 288 | |
| 289 # | |
| 290 # Create and populate lib/dom. | |
| 291 # | |
| 292 dom_src_dir = join(HOME, 'lib', 'dom') | |
| 293 dom_dest_dir = join(LIB, 'dom') | |
| 294 os.makedirs(dom_dest_dir) | |
| 295 | |
| 296 copyfile(join(dom_src_dir, 'dart2js', 'dom_dart2js.dart'), | |
| 297 join(dom_dest_dir, 'dom_dart2js.dart')) | |
|
dgrove
2012/09/05 00:05:56
the dom piece of this needs to stay in for now. On
keertip
2012/09/05 15:35:18
Done.
| |
| 298 | |
| 299 # | |
| 300 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. | 220 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
| 301 # | 221 # |
| 302 | 222 |
| 303 for library in ['_internal', 'core', 'coreimpl', 'crypto', 'isolate', 'json', | 223 for library in ['_internal', 'compiler', 'config', 'html', 'core', 'coreimpl', |
| 304 'math', 'mirrors', 'uri', 'utf', 'web']: | 224 'crypto', 'isolate', 'json', 'math', 'mirrors', 'uri', 'utf', |
| 305 src_dir = join(HOME, 'lib', library) | 225 'web']: |
| 306 dest_dir = join(LIB, library) | 226 copytree(join(HOME, 'lib', library), join(LIB, library), |
| 307 os.makedirs(dest_dir) | 227 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) |
|
dgrove
2012/09/05 00:05:56
You will also need this:
# TODO(dgrove): fix thi
keertip
2012/09/05 15:35:18
Done.
| |
| 308 | |
| 309 for filename in os.listdir(src_dir): | |
| 310 if filename.endswith('.dart'): | |
| 311 copyfile(join(src_dir, filename), join(dest_dir, filename)) | |
| 312 | 228 |
| 313 # Create and copy pkg. | 229 # Create and copy pkg. |
| 314 PKG = join(SDK_tmp, 'pkg') | 230 PKG = join(SDK_tmp, 'pkg') |
| 315 os.makedirs(PKG) | 231 os.makedirs(PKG) |
| 316 | 232 |
| 317 # | 233 # |
| 318 # Create and populate pkg/{args, intl, logging, unittest} | 234 # Create and populate pkg/{args, intl, logging, unittest} |
| 319 # | 235 # |
| 320 | 236 |
| 321 for library in ['args', 'intl', 'logging', 'unittest']: | 237 for library in ['args', 'dartdoc', 'intl', 'logging', 'unittest']: |
| 322 src_dir = join(HOME, 'pkg', library) | 238 copytree(join(HOME, 'pkg', library), join(PKG, library), |
| 323 dest_dir = join(PKG, library) | 239 ignore=ignore_patterns('*.svn', 'doc', 'docs', |
| 324 os.makedirs(dest_dir) | 240 '*.py', '*.gypi', '*.sh')) |
| 325 | 241 |
| 326 for filename in os.listdir(src_dir): | 242 # Fixup dartdoc |
| 327 if filename.endswith('.dart'): | |
| 328 copyfile(join(src_dir, filename), join(dest_dir, filename)) | |
| 329 if exists(join(src_dir, 'lib')): | |
| 330 copytree(join(src_dir, 'lib'), join(dest_dir, 'lib'), | |
| 331 ignore=ignore_patterns('.svn')) | |
| 332 | |
| 333 # Create and populate pkg/dartdoc. | |
| 334 dartdoc_src_dir = join(HOME, 'pkg', 'dartdoc') | |
| 335 dartdoc_dest_dir = join(PKG, 'dartdoc') | |
| 336 copytree(dartdoc_src_dir, dartdoc_dest_dir, | |
| 337 ignore=ignore_patterns('.svn', 'docs')) | |
| 338 | |
| 339 # Fixup dart2js dependencies. | |
| 340 ReplaceInFiles([ | 243 ReplaceInFiles([ |
| 341 join(PKG, 'dartdoc', 'dartdoc.dart'), | 244 join(PKG, 'dartdoc', 'dartdoc.dart'), |
| 342 ], [ | 245 ], [ |
| 343 ("final bool IN_SDK = false;", | 246 ("final bool IN_SDK = false;", |
| 344 "final bool IN_SDK = true;"), | 247 "final bool IN_SDK = true;"), |
| 345 ]) | 248 ]) |
| 346 | 249 |
| 347 | 250 |
| 348 # Create and copy tools. | 251 # Create and copy tools. |
| 349 UTIL = join(SDK_tmp, 'util') | 252 UTIL = join(SDK_tmp, 'util') |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 363 join("guava", "r09", "guava-r09.jar"), | 266 join("guava", "r09", "guava-r09.jar"), |
| 364 join("json", "r2_20080312", "json.jar") ] | 267 join("json", "r2_20080312", "json.jar") ] |
| 365 for jarToCopy in jarsToCopy: | 268 for jarToCopy in jarsToCopy: |
| 366 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy)) | 269 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy)) |
| 367 os.makedirs(dest_dir) | 270 os.makedirs(dest_dir) |
| 368 dest_file = join (ANALYZER_DEST, jarToCopy) | 271 dest_file = join (ANALYZER_DEST, jarToCopy) |
| 369 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) | 272 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) |
| 370 copyfile(src_file, dest_file) | 273 copyfile(src_file, dest_file) |
| 371 | 274 |
| 372 # Create and populate util/pub. | 275 # Create and populate util/pub. |
| 373 pub_src_dir = join(HOME, 'utils', 'pub') | 276 copytree(join(HOME, 'utils', 'pub'), join(UTIL, 'pub'), |
| 374 pub_dst_dir = join(UTIL, 'pub') | |
| 375 copytree(pub_src_dir, pub_dst_dir, | |
| 376 ignore=ignore_patterns('.svn', 'sdk')) | 277 ignore=ignore_patterns('.svn', 'sdk')) |
| 377 | 278 |
| 378 # Copy import maps. | |
| 379 PLATFORMS = ['any', 'vm', 'dartium', 'dart2js' ] | |
| 380 os.makedirs(join(LIB, 'config')) | |
| 381 for platform in PLATFORMS: | |
| 382 import_src = join(HOME, 'lib', 'config', 'import_' + platform + '.config') | |
| 383 import_dst = join(LIB, 'config', 'import_' + platform + '.config') | |
| 384 copyfile(import_src, import_dst); | |
| 385 | |
| 386 revision = utils.GetSVNRevision() | 279 revision = utils.GetSVNRevision() |
| 387 | 280 |
| 388 # Copy dart2js. | 281 # Copy dart2js. |
| 389 CopyDart2Js(build_dir, SDK_tmp, revision) | 282 CopyDart2Js(build_dir, SDK_tmp, revision) |
| 390 | 283 |
| 391 # Write the 'revision' file | 284 # Write the 'revision' file |
| 392 if revision is not None: | 285 if revision is not None: |
| 393 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 286 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
| 394 f.write(revision + '\n') | 287 f.write(revision + '\n') |
| 395 f.close() | 288 f.close() |
| 396 | 289 |
| 397 move(SDK_tmp, SDK) | 290 move(SDK_tmp, SDK) |
| 398 utils.Touch(os.path.join(SDK, 'create.stamp')) | 291 utils.Touch(os.path.join(SDK, 'create.stamp')) |
| 399 | 292 |
| 400 if __name__ == '__main__': | 293 if __name__ == '__main__': |
| 401 sys.exit(Main(sys.argv)) | 294 sys.exit(Main(sys.argv)) |
| OLD | NEW |