Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: tools/create_sdk.py

Issue 13945008: Move the dart2js snapshot into bin directory of sdk root. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/
22 # ........utils_wrapper.dart.snapshot
21 # ....include/ 23 # ....include/
22 # ......dart_api.h 24 # ......dart_api.h
23 # ......dart_debugger_api.h 25 # ......dart_debugger_api.h
24 # ....lib/ 26 # ....lib/
25 # ......_internal/ 27 # ......_internal/
26 # ......async/ 28 # ......async/
27 # ......collection/ 29 # ......collection/
28 # ......_collection_dev/ 30 # ......_collection_dev/
29 # ......core/ 31 # ......core/
30 # ......crypto/ 32 # ......crypto/
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 using the appropriate platform-specific file extension.''' 94 using the appropriate platform-specific file extension.'''
93 file_extension = '' 95 file_extension = ''
94 if HOST_OS == 'win32': 96 if HOST_OS == 'win32':
95 file_extension = '.bat' 97 file_extension = '.bat'
96 98
97 src = src_file + file_extension 99 src = src_file + file_extension
98 dest = join(dest_dir, basename(src_file) + file_extension) 100 dest = join(dest_dir, basename(src_file) + file_extension)
99 Copy(src, dest) 101 Copy(src, dest)
100 102
101 103
102 def CopyDartScripts(home, build_dir, sdk_root, version): 104 def CopyDartScripts(home, sdk_root):
103 if version:
104 ReplaceInFiles([os.path.join(sdk_root, 'lib', '_internal', 'compiler',
105 'implementation', 'compiler.dart')],
106 [(r"BUILD_ID = 'build number could not be determined'",
107 r"BUILD_ID = '%s'" % version)])
108 # TODO(dgrove) - add pub once issue 6619 is fixed 105 # TODO(dgrove) - add pub once issue 6619 is fixed
109 for executable in ['dart2js', 'dartdoc']: 106 for executable in ['dart2js', 'dartdoc']:
110 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), 107 CopyShellScript(os.path.join(home, 'sdk', 'bin', executable),
111 os.path.join(sdk_root, 'bin')) 108 os.path.join(sdk_root, 'bin'))
112 109
113 subprocess.call([os.path.join(build_dir, 'dart'),
114 '--generate-script-snapshot=%s' %
115 os.path.join(sdk_root, 'lib', '_internal', 'compiler',
116 'implementation', 'dart2js.dart.snapshot'),
117 os.path.join(sdk_root, 'lib', '_internal', 'compiler',
118 'implementation', 'dart2js.dart')])
119 110
111 def CopySnapshots(snapshot, sdk_root):
112 copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot)))
120 113
121 114
122 def Main(argv): 115 def Main(argv):
123 # Pull in all of the gpyi files which will be munged into the sdk. 116 # Pull in all of the gypi files which will be munged into the sdk.
124 HOME = dirname(dirname(realpath(__file__))) 117 HOME = dirname(dirname(realpath(__file__)))
125 118
119 # TODO(ricow): change to use option parser, issue 9820.
126 SDK = argv[1] 120 SDK = argv[1]
127 SDK_tmp = '%s.tmp' % SDK 121 SDK_tmp = '%s.tmp' % SDK
128 122
123 SNAPSHOT_LOCATION = argv[2]
124 SNAPSHOT = join(SNAPSHOT_LOCATION, 'utils_wrapper.dart.snapshot')
125
129 # TODO(dgrove) - deal with architectures that are not ia32. 126 # TODO(dgrove) - deal with architectures that are not ia32.
130 127
131 if exists(SDK): 128 if exists(SDK):
132 rmtree(SDK) 129 rmtree(SDK)
133 130
134 if exists(SDK_tmp): 131 if exists(SDK_tmp):
135 rmtree(SDK_tmp) 132 rmtree(SDK_tmp)
136 133
137 os.makedirs(SDK_tmp) 134 os.makedirs(SDK_tmp)
138 135
139 # Create and populate sdk/bin. 136 # Create and populate sdk/bin.
140 BIN = join(SDK_tmp, 'bin') 137 BIN = join(SDK_tmp, 'bin')
141 os.makedirs(BIN) 138 os.makedirs(BIN)
142 139
140 os.makedirs(join(BIN, 'snapshots'))
141
143 # Copy the Dart VM binary and the Windows Dart VM link library 142 # Copy the Dart VM binary and the Windows Dart VM link library
144 # into sdk/bin. 143 # into sdk/bin.
145 # 144 #
146 # TODO(dgrove) - deal with architectures that are not ia32. 145 # TODO(dgrove) - deal with architectures that are not ia32.
147 build_dir = os.path.dirname(argv[1]) 146 build_dir = os.path.dirname(argv[1])
148 dart_file_extension = '' 147 dart_file_extension = ''
149 analyzer_file_extension = '' 148 analyzer_file_extension = ''
150 if HOST_OS == 'win32': 149 if HOST_OS == 'win32':
151 dart_file_extension = '.exe' 150 dart_file_extension = '.exe'
152 analyzer_file_extension = '.bat' 151 analyzer_file_extension = '.bat'
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 # 191 #
193 192
194 LIB = join(SDK_tmp, 'lib') 193 LIB = join(SDK_tmp, 'lib')
195 os.makedirs(LIB) 194 os.makedirs(LIB)
196 195
197 # 196 #
198 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. 197 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}.
199 # 198 #
200 199
201 os.makedirs(join(LIB, 'html')) 200 os.makedirs(join(LIB, 'html'))
202 for library in ['_internal', 'async', 'collection', '_collection_dev', 'core', 201
202 # Remove _internal/compiler/implementation/lib when we can add that
203 # as part of the dart2js snapshot.
204 for library in ['_internal/compiler/implementation/lib',
205 'async', 'collection', '_collection_dev', 'core',
203 'crypto', 'io', 'isolate', 206 'crypto', 'io', 'isolate',
204 join('chrome', 'dart2js'), join('chrome', 'dartium'), 207 join('chrome', 'dart2js'), join('chrome', 'dartium'),
205 join('html', 'dart2js'), join('html', 'dartium'), 208 join('html', 'dart2js'), join('html', 'dartium'),
206 join('html', 'html_common'), 209 join('html', 'html_common'),
207 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'), 210 join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'),
208 'json', 'math', 'mirrors', 'typeddata', 211 'json', 'math', 'mirrors', 'typeddata',
209 join('svg', 'dart2js'), join('svg', 'dartium'), 212 join('svg', 'dart2js'), join('svg', 'dartium'),
210 'uri', 'utf', 213 'uri', 'utf',
211 join('web_audio', 'dart2js'), join('web_audio', 'dartium'), 214 join('web_audio', 'dart2js'), join('web_audio', 'dartium'),
212 join('web_gl', 'dart2js'), join('web_gl', 'dartium'), 215 join('web_gl', 'dart2js'), join('web_gl', 'dartium'),
213 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]: 216 join('web_sql', 'dart2js'), join('web_sql', 'dartium')]:
214 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), 217 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library),
215 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) 218 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh'))
216 219
220 # Remove this once we can add it as part of the dart2js snapshot.
221 copyfile(join(HOME, 'sdk', 'lib', '_internal', 'libraries.dart'),
222 join(LIB, '_internal', 'libraries.dart'))
217 223
218 # Create and copy packages. 224 # Create and copy packages.
219 PACKAGES = join(SDK_tmp, 'packages') 225 PACKAGES = join(SDK_tmp, 'packages')
220 os.makedirs(PACKAGES) 226 os.makedirs(PACKAGES)
221 227
222 # 228 #
223 # Create and populate packages/{args, intl, logging, meta, unittest, ...} 229 # Create and populate packages/{args, intl, logging, meta, unittest, ...}
224 # 230 #
225 231
226 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos', 232 for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos',
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 join(join(UTIL, 'pub'), '7zip'), 268 join(join(UTIL, 'pub'), '7zip'),
263 ignore=ignore_patterns('.svn')) 269 ignore=ignore_patterns('.svn'))
264 270
265 ReplaceInFiles([ 271 ReplaceInFiles([
266 join(UTIL, 'pub', 'io.dart'), 272 join(UTIL, 'pub', 'io.dart'),
267 ], [ 273 ], [
268 ("../../third_party/7zip/7za.exe", 274 ("../../third_party/7zip/7za.exe",
269 "7zip/7za.exe"), 275 "7zip/7za.exe"),
270 ]) 276 ])
271 277
272 version = utils.GetVersion()
273
274 # Copy dart2js/dartdoc/pub. 278 # Copy dart2js/dartdoc/pub.
275 CopyDartScripts(HOME, build_dir, SDK_tmp, version) 279 CopyDartScripts(HOME, SDK_tmp)
280 CopySnapshots(SNAPSHOT, SDK_tmp)
276 281
277 # Write the 'version' file 282 # Write the 'version' file
283 version = utils.GetVersion()
278 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') 284 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w')
279 versionFile.write(version + '\n') 285 versionFile.write(version + '\n')
280 versionFile.close() 286 versionFile.close()
281 287
282 # Write the 'revision' file 288 # Write the 'revision' file
283 revision = utils.GetSVNRevision() 289 revision = utils.GetSVNRevision()
284 290
285 if revision is not None: 291 if revision is not None:
286 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 292 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
287 f.write(revision + '\n') 293 f.write(revision + '\n')
288 f.close() 294 f.close()
289 295
290 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) 296 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README'))
291 297
292 move(SDK_tmp, SDK) 298 move(SDK_tmp, SDK)
293 299
294 if __name__ == '__main__': 300 if __name__ == '__main__':
295 sys.exit(Main(sys.argv)) 301 sys.exit(Main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698