| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2011, 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 # ......frogc.dart | 17 # ......frogc.dart |
| 18 # ......frogsh (coming later) | 18 # ......frogsh (coming later) |
| 19 # ....lib/ | 19 # ....lib/ |
| 20 # ......builtin/ | 20 # ......builtin/ |
| 21 # ........builtin_runtime.dart | 21 # ........builtin_runtime.dart |
| 22 # ......io/ |
| 23 # ........io_runtime.dart |
| 22 # ........runtime/ | 24 # ........runtime/ |
| 23 # ......core/ | 25 # ......core/ |
| 24 # ........core_{frog, runtime}.dart | 26 # ........core_{frog, runtime}.dart |
| 25 # ........{frog, runtime}/ | 27 # ........{frog, runtime}/ |
| 26 # ......coreimpl/ | 28 # ......coreimpl/ |
| 27 # ........coreimpl_{frog, runtime}.dart | 29 # ........coreimpl_{frog, runtime}.dart |
| 28 # ........{frog, runtime}/ | 30 # ........{frog, runtime}/ |
| 29 # ......dom/ | 31 # ......dom/ |
| 30 # ........dom.dart | 32 # ........dom.dart |
| 31 # ......frog/ | 33 # ......frog/ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 48 import tempfile | 50 import tempfile |
| 49 import utils | 51 import utils |
| 50 | 52 |
| 51 from os.path import dirname, join, realpath, exists, isdir | 53 from os.path import dirname, join, realpath, exists, isdir |
| 52 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move | 54 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move |
| 53 | 55 |
| 54 def Main(argv): | 56 def Main(argv): |
| 55 # Pull in all of the gpyi files which will be munged into the sdk. | 57 # Pull in all of the gpyi files which will be munged into the sdk. |
| 56 builtin_runtime_sources = \ | 58 builtin_runtime_sources = \ |
| 57 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] | 59 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] |
| 60 io_runtime_sources = \ |
| 61 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] |
| 58 corelib_sources = \ | 62 corelib_sources = \ |
| 59 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] | 63 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] |
| 60 corelib_frog_sources = \ | 64 corelib_frog_sources = \ |
| 61 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources'] | 65 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources'] |
| 62 corelib_runtime_sources = \ | 66 corelib_runtime_sources = \ |
| 63 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] | 67 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] |
| 64 coreimpl_sources = \ | 68 coreimpl_sources = \ |
| 65 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ | 69 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ |
| 66 ['sources'] | 70 ['sources'] |
| 67 coreimpl_frog_sources = \ | 71 coreimpl_frog_sources = \ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 os.makedirs(join(corelib_dest_dir, 'runtime')) | 130 os.makedirs(join(corelib_dest_dir, 'runtime')) |
| 127 | 131 |
| 128 coreimpl_dest_dir = join(LIB, 'coreimpl') | 132 coreimpl_dest_dir = join(LIB, 'coreimpl') |
| 129 os.makedirs(coreimpl_dest_dir) | 133 os.makedirs(coreimpl_dest_dir) |
| 130 os.makedirs(join(coreimpl_dest_dir, 'frog')) | 134 os.makedirs(join(coreimpl_dest_dir, 'frog')) |
| 131 os.makedirs(join(coreimpl_dest_dir, 'frog', 'node')) | 135 os.makedirs(join(coreimpl_dest_dir, 'frog', 'node')) |
| 132 os.makedirs(join(coreimpl_dest_dir, 'runtime')) | 136 os.makedirs(join(coreimpl_dest_dir, 'runtime')) |
| 133 | 137 |
| 134 | 138 |
| 135 # | 139 # |
| 136 # Create and populate lib/runtime. | 140 # Create and populate lib/builtin. |
| 137 # | 141 # |
| 138 builtin_dest_dir = join(LIB, 'builtin') | 142 builtin_dest_dir = join(LIB, 'builtin') |
| 139 os.makedirs(builtin_dest_dir) | 143 os.makedirs(builtin_dest_dir) |
| 140 os.makedirs(join(builtin_dest_dir, 'runtime')) | 144 assert len(builtin_runtime_sources) == 1 |
| 141 for filename in builtin_runtime_sources: | 145 assert builtin_runtime_sources[0] == 'builtin.dart' |
| 142 if filename.endswith('.dart'): | 146 copyfile(join(HOME, 'runtime', 'bin', 'builtin.dart'), |
| 143 copyfile(join(HOME, 'runtime', 'bin', filename), | 147 join(builtin_dest_dir, 'builtin_runtime.dart')) |
| 144 join(builtin_dest_dir, 'runtime', filename)) | |
| 145 | 148 |
| 146 # Construct lib/builtin/builtin_runtime.dart from whole cloth. | 149 |
| 147 dest_file = open(join(builtin_dest_dir, 'builtin_runtime.dart'), 'w') | 150 # |
| 148 dest_file.write('#library("dart:builtin");\n') | 151 # Create and populate lib/io. |
| 149 for filename in builtin_runtime_sources: | 152 # |
| 150 if filename.endswith('.dart'): | 153 io_dest_dir = join(LIB, 'io') |
| 151 dest_file.write('#source("runtime/' + filename + '");\n') | 154 os.makedirs(io_dest_dir) |
| 155 os.makedirs(join(io_dest_dir, 'runtime')) |
| 156 for filename in io_runtime_sources: |
| 157 assert filename.endswith('.dart') |
| 158 if filename == 'io.dart': |
| 159 copyfile(join(HOME, 'runtime', 'bin', filename), |
| 160 join(io_dest_dir, 'io_runtime.dart')) |
| 161 else: |
| 162 copyfile(join(HOME, 'runtime', 'bin', filename), |
| 163 join(io_dest_dir, 'runtime', filename)) |
| 164 |
| 165 # Construct lib/io/io_runtime.dart from whole cloth. |
| 166 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a') |
| 167 for filename in io_runtime_sources: |
| 168 assert filename.endswith('.dart') |
| 169 if filename == 'io.dart': |
| 170 continue |
| 171 dest_file.write('#source("runtime/' + filename + '");\n') |
| 152 dest_file.close() | 172 dest_file.close() |
| 153 | 173 |
| 174 |
| 154 # | 175 # |
| 155 # Create and populate lib/frog. | 176 # Create and populate lib/frog. |
| 156 # | 177 # |
| 157 frog_dest_dir = join(LIB, 'frog') | 178 frog_dest_dir = join(LIB, 'frog') |
| 158 os.makedirs(frog_dest_dir) | 179 os.makedirs(frog_dest_dir) |
| 159 | 180 |
| 160 for filename in os.listdir(frog_src_dir): | 181 for filename in os.listdir(frog_src_dir): |
| 161 if filename == 'frog_options.dart': | 182 if filename == 'frog_options.dart': |
| 162 # change config from 'dev' to 'sdk' in frog_options.dart | 183 # change config from 'dev' to 'sdk' in frog_options.dart |
| 163 frog_options_contents = open(join(frog_src_dir, filename)).read() | 184 frog_options_contents = open(join(frog_src_dir, filename)).read() |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 333 |
| 313 # Create and copy tools. | 334 # Create and copy tools. |
| 314 | 335 |
| 315 UTIL = join(SDK_tmp, 'util') | 336 UTIL = join(SDK_tmp, 'util') |
| 316 os.makedirs(UTIL) | 337 os.makedirs(UTIL) |
| 317 | 338 |
| 318 move(SDK_tmp, SDK) | 339 move(SDK_tmp, SDK) |
| 319 | 340 |
| 320 if __name__ == '__main__': | 341 if __name__ == '__main__': |
| 321 sys.exit(Main(sys.argv)) | 342 sys.exit(Main(sys.argv)) |
| OLD | NEW |