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 # ......dartdoc | |
18 # ......dartfmt | 19 # ......dartfmt |
19 # ......dart2js | 20 # ......dart2js |
20 # ......dartanalyzer | 21 # ......dartanalyzer |
21 # ......pub | 22 # ......pub |
22 # ......snapshots/ | 23 # ......snapshots/ |
23 # ........analysis_server.dart.snapshot | 24 # ........analysis_server.dart.snapshot |
24 # ........dart2js.dart.snapshot | 25 # ........dart2js.dart.snapshot |
25 # ........dartanalyzer.dart.snapshot | 26 # ........dartanalyzer.dart.snapshot |
27 # ........dartdoc.dart.snapshot | |
26 # ........dartfmt.dart.snapshot | 28 # ........dartfmt.dart.snapshot |
27 # ........pub.dart.snapshot | 29 # ........pub.dart.snapshot |
28 # ........utils_wrapper.dart.snapshot | 30 # ........utils_wrapper.dart.snapshot |
31 #.........resources/ | |
32 #...........dartdoc/ | |
33 #..............packages | |
34 #.............resources/ | |
35 #.............templates/ | |
29 # ....include/ | 36 # ....include/ |
30 # ......dart_api.h | 37 # ......dart_api.h |
31 # ......dart_mirrors_api.h | 38 # ......dart_mirrors_api.h |
32 # ......dart_native_api.h | 39 # ......dart_native_api.h |
33 # ......dart_tools_api.h | 40 # ......dart_tools_api.h |
34 # ....lib/ | 41 # ....lib/ |
35 # ......_internal/ | 42 # ......_internal/ |
36 # ......async/ | 43 # ......async/ |
37 # ......collection/ | 44 # ......collection/ |
38 # ......convert/ | 45 # ......convert/ |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 if dest_file.endswith('_sdk'): | 114 if dest_file.endswith('_sdk'): |
108 dest_file = dest_file.replace('_sdk', '') | 115 dest_file = dest_file.replace('_sdk', '') |
109 | 116 |
110 src = src_file + file_extension | 117 src = src_file + file_extension |
111 dest = join(dest_dir, dest_file + file_extension) | 118 dest = join(dest_dir, dest_file + file_extension) |
112 Copy(src, dest) | 119 Copy(src, dest) |
113 | 120 |
114 | 121 |
115 def CopyDartScripts(home, sdk_root): | 122 def CopyDartScripts(home, sdk_root): |
116 for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt_sdk', 'docgen', | 123 for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt_sdk', 'docgen', |
117 'dartdocgen', 'pub_sdk']: | 124 'dartdocgen', 'pub_sdk', 'dartdoc']: |
118 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), | 125 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), |
119 os.path.join(sdk_root, 'bin')) | 126 os.path.join(sdk_root, 'bin')) |
120 | 127 |
121 | 128 |
122 def CopySnapshots(snapshots, sdk_root): | 129 def CopySnapshots(snapshots, sdk_root): |
123 for snapshot in ['analysis_server', 'dart2js', 'dartanalyzer', 'dartfmt', | 130 for snapshot in ['analysis_server', 'dart2js', 'dartanalyzer', 'dartfmt', |
124 'utils_wrapper', 'pub']: | 131 'utils_wrapper', 'pub', 'dartdoc']: |
125 snapshot += '.dart.snapshot' | 132 snapshot += '.dart.snapshot' |
126 copyfile(join(snapshots, snapshot), | 133 copyfile(join(snapshots, snapshot), |
127 join(sdk_root, 'bin', 'snapshots', snapshot)) | 134 join(sdk_root, 'bin', 'snapshots', snapshot)) |
128 | 135 |
136 def CopyDartdocResources(home,sdk_root): | |
137 RESOURCE_DIR = join(sdk_root, 'bin', 'snapshots', 'resources') | |
138 os.makedirs(RESOURCE_DIR) | |
Bill Hesse
2015/08/18 22:15:21
This first makedirs is redundant, because makedirs
| |
139 DARTDOC = join(RESOURCE_DIR, 'dartdoc') | |
140 os.makedirs(DARTDOC) | |
141 | |
142 copytree(join(home, 'third_party', 'pkg', 'dartdoc', 'lib', 'templates'), | |
Bill Hesse
2015/08/18 22:15:21
In fact, copytree is documented to create all nece
keertip
2015/08/18 22:34:36
Did not know that. Removed the makedirs.
| |
143 join(DARTDOC, 'templates')) | |
144 copytree(join(home, 'third_party', 'pkg', 'dartdoc', 'lib', 'resources'), | |
145 join(DARTDOC, 'resources')) | |
146 # write the .packages file | |
147 PACKAGES_FILE = join(DARTDOC, '.packages') | |
148 packages_file = open(PACKAGES_FILE, 'w') | |
149 packages_file.write('dartdoc:.') | |
150 packages_file.close() | |
151 | |
129 | 152 |
130 def Main(): | 153 def Main(): |
131 # Pull in all of the gypi files which will be munged into the sdk. | 154 # Pull in all of the gypi files which will be munged into the sdk. |
132 HOME = dirname(dirname(realpath(__file__))) | 155 HOME = dirname(dirname(realpath(__file__))) |
133 | 156 |
134 (options, args) = GetOptions() | 157 (options, args) = GetOptions() |
135 | 158 |
136 SDK = options.sdk_output_dir | 159 SDK = options.sdk_output_dir |
137 SDK_tmp = '%s.tmp' % SDK | 160 SDK_tmp = '%s.tmp' % SDK |
138 | 161 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 267 |
245 # Copy in 7zip for Windows. | 268 # Copy in 7zip for Windows. |
246 if HOST_OS == 'win32': | 269 if HOST_OS == 'win32': |
247 copytree(join(HOME, 'third_party', '7zip'), | 270 copytree(join(HOME, 'third_party', '7zip'), |
248 join(RESOURCE, '7zip'), | 271 join(RESOURCE, '7zip'), |
249 ignore=ignore_patterns('.svn')) | 272 ignore=ignore_patterns('.svn')) |
250 | 273 |
251 # Copy dart2js/pub. | 274 # Copy dart2js/pub. |
252 CopyDartScripts(HOME, SDK_tmp) | 275 CopyDartScripts(HOME, SDK_tmp) |
253 CopySnapshots(SNAPSHOT, SDK_tmp) | 276 CopySnapshots(SNAPSHOT, SDK_tmp) |
277 CopyDartdocResources(HOME, SDK_tmp) | |
254 | 278 |
255 # Write the 'version' file | 279 # Write the 'version' file |
256 version = utils.GetVersion() | 280 version = utils.GetVersion() |
257 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') | 281 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') |
258 versionFile.write(version + '\n') | 282 versionFile.write(version + '\n') |
259 versionFile.close() | 283 versionFile.close() |
260 | 284 |
261 # Write the 'revision' file | 285 # Write the 'revision' file |
262 revision = utils.GetGitRevision() | 286 revision = utils.GetGitRevision() |
263 | 287 |
264 if revision is not None: | 288 if revision is not None: |
265 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 289 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
266 f.write('%s\n' % revision) | 290 f.write('%s\n' % revision) |
267 f.close() | 291 f.close() |
268 | 292 |
269 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) | 293 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) |
270 Copy(join(HOME, 'sdk', 'api_readme.md'), join(SDK_tmp, 'lib', 'api_readme.md') ) | 294 Copy(join(HOME, 'sdk', 'api_readme.md'), join(SDK_tmp, 'lib', 'api_readme.md') ) |
271 | 295 |
272 move(SDK_tmp, SDK) | 296 move(SDK_tmp, SDK) |
273 | 297 |
274 if __name__ == '__main__': | 298 if __name__ == '__main__': |
275 sys.exit(Main()) | 299 sys.exit(Main()) |
OLD | NEW |