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/ | 21 # ......snapshots/ |
22 # ........utils_wrapper.dart.snapshot | 22 # ........utils_wrapper.dart.snapshot |
| 23 # ........pub.dart.snapshot |
23 # ....include/ | 24 # ....include/ |
24 # ......dart_api.h | 25 # ......dart_api.h |
25 # ......dart_debugger_api.h | 26 # ......dart_debugger_api.h |
26 # ....lib/ | 27 # ....lib/ |
27 # ......_internal/ | 28 # ......_internal/ |
28 # ......async/ | 29 # ......async/ |
29 # ......collection/ | 30 # ......collection/ |
30 # ......_collection_dev/ | 31 # ......_collection_dev/ |
31 # ......core/ | 32 # ......core/ |
32 # ......crypto/ | 33 # ......crypto/ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 from os.path import basename, dirname, join, realpath, exists, isdir | 72 from os.path import basename, dirname, join, realpath, exists, isdir |
72 | 73 |
73 # TODO(dgrove): Only import modules following Google style guide. | 74 # TODO(dgrove): Only import modules following Google style guide. |
74 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move | 75 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move |
75 | 76 |
76 | 77 |
77 def GetOptions(): | 78 def GetOptions(): |
78 options = optparse.OptionParser(usage='usage: %prog [options]') | 79 options = optparse.OptionParser(usage='usage: %prog [options]') |
79 options.add_option("--sdk_output_dir", | 80 options.add_option("--sdk_output_dir", |
80 help='Where to output the sdk') | 81 help='Where to output the sdk') |
81 options.add_option("--utils_snapshot_location", | 82 options.add_option("--snapshot_location", |
82 help='Location of the utils snapshot.') | 83 help='Location of the snapshots.') |
83 return options.parse_args() | 84 return options.parse_args() |
84 | 85 |
85 | 86 |
86 def ReplaceInFiles(paths, subs): | 87 def ReplaceInFiles(paths, subs): |
87 '''Reads a series of files, applies a series of substitutions to each, and | 88 '''Reads a series of files, applies a series of substitutions to each, and |
88 saves them back out. subs should by a list of (pattern, replace) tuples.''' | 89 saves them back out. subs should by a list of (pattern, replace) tuples.''' |
89 for path in paths: | 90 for path in paths: |
90 contents = open(path).read() | 91 contents = open(path).read() |
91 for pattern, replace in subs: | 92 for pattern, replace in subs: |
92 contents = re.sub(pattern, replace, contents) | 93 contents = re.sub(pattern, replace, contents) |
(...skipping 19 matching lines...) Expand all Loading... |
112 dest = join(dest_dir, basename(src_file) + file_extension) | 113 dest = join(dest_dir, basename(src_file) + file_extension) |
113 Copy(src, dest) | 114 Copy(src, dest) |
114 | 115 |
115 | 116 |
116 def CopyDartScripts(home, sdk_root): | 117 def CopyDartScripts(home, sdk_root): |
117 for executable in ['dart2js', 'dartanalyzer', 'dartdoc', 'pub']: | 118 for executable in ['dart2js', 'dartanalyzer', 'dartdoc', 'pub']: |
118 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), | 119 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), |
119 os.path.join(sdk_root, 'bin')) | 120 os.path.join(sdk_root, 'bin')) |
120 | 121 |
121 | 122 |
122 def CopySnapshots(snapshot, sdk_root): | 123 def CopySnapshots(snapshots, sdk_root): |
123 copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot))) | 124 for snapshot in ['utils_wrapper', 'pub']: |
| 125 snapshot += '.dart.snapshot' |
| 126 copyfile(join(snapshots, snapshot), |
| 127 join(sdk_root, 'bin', 'snapshots', snapshot)) |
124 | 128 |
125 | 129 |
126 def Main(argv): | 130 def Main(argv): |
127 # Pull in all of the gypi files which will be munged into the sdk. | 131 # Pull in all of the gypi files which will be munged into the sdk. |
128 HOME = dirname(dirname(realpath(__file__))) | 132 HOME = dirname(dirname(realpath(__file__))) |
129 | 133 |
130 (options, args) = GetOptions() | 134 (options, args) = GetOptions() |
131 | 135 |
132 SDK = options.sdk_output_dir | 136 SDK = options.sdk_output_dir |
133 SDK_tmp = '%s.tmp' % SDK | 137 SDK_tmp = '%s.tmp' % SDK |
134 | 138 |
135 SNAPSHOT = options.utils_snapshot_location | 139 SNAPSHOT = options.snapshot_location |
136 | 140 |
137 # TODO(dgrove) - deal with architectures that are not ia32. | 141 # TODO(dgrove) - deal with architectures that are not ia32. |
138 | 142 |
139 if exists(SDK): | 143 if exists(SDK): |
140 rmtree(SDK) | 144 rmtree(SDK) |
141 | 145 |
142 if exists(SDK_tmp): | 146 if exists(SDK_tmp): |
143 rmtree(SDK_tmp) | 147 rmtree(SDK_tmp) |
144 | 148 |
145 os.makedirs(SDK_tmp) | 149 os.makedirs(SDK_tmp) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 202 |
199 LIB = join(SDK_tmp, 'lib') | 203 LIB = join(SDK_tmp, 'lib') |
200 os.makedirs(LIB) | 204 os.makedirs(LIB) |
201 | 205 |
202 # | 206 # |
203 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. | 207 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
204 # | 208 # |
205 | 209 |
206 os.makedirs(join(LIB, 'html')) | 210 os.makedirs(join(LIB, 'html')) |
207 | 211 |
208 for library in ['_internal', | 212 for library in [join('_internal', 'compiler'), |
| 213 join('_internal', 'dartdoc'), |
| 214 join('_internal', 'pub', 'resource'), |
209 'async', 'collection', '_collection_dev', 'core', | 215 'async', 'collection', '_collection_dev', 'core', |
210 'crypto', 'io', 'isolate', | 216 'crypto', 'io', 'isolate', |
211 join('chrome', 'dart2js'), join('chrome', 'dartium'), | 217 join('chrome', 'dart2js'), join('chrome', 'dartium'), |
212 join('html', 'dart2js'), join('html', 'dartium'), | 218 join('html', 'dart2js'), join('html', 'dartium'), |
213 join('html', 'html_common'), | 219 join('html', 'html_common'), |
214 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), | 220 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), |
215 'json', 'math', 'mirrors', 'typed_data', | 221 'json', 'math', 'mirrors', 'typed_data', |
216 join('svg', 'dart2js'), join('svg', 'dartium'), | 222 join('svg', 'dart2js'), join('svg', 'dartium'), |
217 'uri', 'utf', | 223 'uri', 'utf', |
218 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), | 224 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), |
219 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), | 225 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), |
220 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: | 226 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: |
221 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), | 227 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), |
222 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | 228 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh', |
| 229 '.gitignore')) |
| 230 |
| 231 # Copy lib/_internal/libraries.dart. |
| 232 copyfile(join(HOME, 'sdk', 'lib', '_internal', 'libraries.dart'), |
| 233 join(LIB, '_internal', 'libraries.dart')) |
223 | 234 |
224 # Create and copy packages. | 235 # Create and copy packages. |
225 PACKAGES = join(SDK_tmp, 'packages') | 236 PACKAGES = join(SDK_tmp, 'packages') |
226 os.makedirs(PACKAGES) | 237 os.makedirs(PACKAGES) |
227 | 238 |
228 # | 239 # |
229 # Create and populate packages/{args, intl, logging, meta, unittest, ...} | 240 # Create and populate packages/{args, intl, logging, meta, unittest, ...} |
230 # | 241 # |
231 | 242 |
232 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', | 243 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', |
(...skipping 28 matching lines...) Expand all Loading... |
261 # Create and copy dartanalyzer into 'util' | 272 # Create and copy dartanalyzer into 'util' |
262 DARTANALYZER_SRC = join(HOME, build_dir, 'dartanalyzer') | 273 DARTANALYZER_SRC = join(HOME, build_dir, 'dartanalyzer') |
263 DARTANALYZER_DEST = join(UTIL, 'dartanalyzer') | 274 DARTANALYZER_DEST = join(UTIL, 'dartanalyzer') |
264 os.makedirs(DARTANALYZER_DEST) | 275 os.makedirs(DARTANALYZER_DEST) |
265 | 276 |
266 jarFiles = glob.glob(join(DARTANALYZER_SRC, '*.jar')) | 277 jarFiles = glob.glob(join(DARTANALYZER_SRC, '*.jar')) |
267 | 278 |
268 for jarFile in jarFiles: | 279 for jarFile in jarFiles: |
269 copyfile(jarFile, join(DARTANALYZER_DEST, os.path.basename(jarFile))) | 280 copyfile(jarFile, join(DARTANALYZER_DEST, os.path.basename(jarFile))) |
270 | 281 |
271 PUB_DEST = join(SDK_tmp, 'lib', '_internal', 'pub') | |
272 | |
273 | |
274 # Copy in 7zip for Windows. | 282 # Copy in 7zip for Windows. |
275 if HOST_OS == 'win32': | 283 if HOST_OS == 'win32': |
276 copytree(join(HOME, 'third_party', '7zip'), | 284 copytree(join(HOME, 'third_party', '7zip'), |
277 join(PUB_DEST, 'resource', '7zip'), | 285 join(SDK_tmp, 'lib', '_internal', 'pub', 'resource', '7zip'), |
278 ignore=ignore_patterns('.svn')) | 286 ignore=ignore_patterns('.svn')) |
279 | 287 |
280 ReplaceInFiles([ | |
281 join(PUB_DEST, 'lib', 'src', 'io.dart'), | |
282 ], [ | |
283 ("../../../../third_party/7zip/7za.exe", | |
284 "resource/7zip/7za.exe"), | |
285 ]) | |
286 | |
287 # Copy dart2js/dartdoc/pub. | 288 # Copy dart2js/dartdoc/pub. |
288 CopyDartScripts(HOME, SDK_tmp) | 289 CopyDartScripts(HOME, SDK_tmp) |
289 CopySnapshots(SNAPSHOT, SDK_tmp) | 290 CopySnapshots(SNAPSHOT, SDK_tmp) |
290 | 291 |
291 # Write the 'version' file | 292 # Write the 'version' file |
292 version = utils.GetVersion() | 293 version = utils.GetVersion() |
293 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') | 294 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') |
294 versionFile.write(version + '\n') | 295 versionFile.write(version + '\n') |
295 versionFile.close() | 296 versionFile.close() |
296 | 297 |
297 # Write the 'revision' file | 298 # Write the 'revision' file |
298 revision = utils.GetSVNRevision() | 299 revision = utils.GetSVNRevision() |
299 | 300 |
300 if revision is not None: | 301 if revision is not None: |
301 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 302 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
302 f.write(revision + '\n') | 303 f.write(revision + '\n') |
303 f.close() | 304 f.close() |
304 | 305 |
305 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) | 306 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) |
306 | 307 |
307 move(SDK_tmp, SDK) | 308 move(SDK_tmp, SDK) |
308 | 309 |
309 if __name__ == '__main__': | 310 if __name__ == '__main__': |
310 sys.exit(Main(sys.argv)) | 311 sys.exit(Main(sys.argv)) |
OLD | NEW |