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

Side by Side Diff: tools/create_sdk.py

Issue 10908097: revert 11882 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « lib/config/import_any.config ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # ....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 # ......_internal/ 25 # ......builtin/
26 # ........builtin_runtime.dart
27 # ......io/
28 # ........io_runtime.dart
29 # ........runtime/
26 # ......compiler/ 30 # ......compiler/
27 # ......config/
28 # ......core/ 31 # ......core/
32 # ........core_runtime.dart
33 # ........runtime/
29 # ......coreimpl/ 34 # ......coreimpl/
35 # ........coreimpl_runtime.dart
36 # ........runtime/
37 # ......dart2js/
38 # ......isolate/
39 # ........isolate_{dart2js, runtime}.dart
40 # ........dart2js/
41 # ......dom/
42 # ........dom.dart
43 # ......html/
44 # ........html_dart2js.dart
45 # ........html_dartium.dart
30 # ......crypto/ 46 # ......crypto/
31 # ......html/ 47 # ........crypto.dart
32 # ......io/ 48 # ........(implementation files)
33 # ......isolate/
34 # ......json/ 49 # ......json/
35 # ......math/ 50 # ........json_frog.dart
51 #.........json.dart
52 # ........{frog}/
36 # ......mirrors/ 53 # ......mirrors/
54 # ........mirrors.dart
37 # ......uri/ 55 # ......uri/
56 # ........uri.dart
38 # ......utf/ 57 # ......utf/
39 # ......web/ 58 # ......web/
59 # ........web.dart
40 # ....pkg/ 60 # ....pkg/
41 # ......args/ 61 # ......args/
42 # ......dartdoc/ 62 # ......dartdoc/
43 # ......intl/ 63 # ......intl/
44 # ......logging/ 64 # ......logging/
45 # ......unittest/
46 # ......(more will come here) 65 # ......(more will come here)
47 # ....util/ 66 # ....util/
48 # ......analyzer/ 67 # ......analyzer/
49 # ........dart_analyzer.jar 68 # ........dart_analyzer.jar
50 # ........(third-party libraries for dart_analyzer) 69 # ........(third-party libraries for dart_analyzer)
51 # ......pub/ 70 # ......pub/
52 # ......(more will come here) 71 # ......(more will come here)
53 72
54 73
55 74
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 file_extension = '' 114 file_extension = ''
96 if utils.GuessOS() == 'win32': 115 if utils.GuessOS() == 'win32':
97 file_extension = '.bat' 116 file_extension = '.bat'
98 117
99 src = src_file + file_extension 118 src = src_file + file_extension
100 dest = join(dest_dir, basename(src_file) + file_extension) 119 dest = join(dest_dir, basename(src_file) + file_extension)
101 Copy(src, dest) 120 Copy(src, dest)
102 121
103 122
104 def CopyDart2Js(build_dir, sdk_root, revision): 123 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'))
105 if revision: 142 if revision:
106 ReplaceInFiles([os.path.join(sdk_root, 'lib', 'compiler', 143 ReplaceInFiles([os.path.join(dart2js_lib,
107 'implementation', 'compiler.dart')], 144 'compiler/implementation/compiler.dart')],
108 [(r"BUILD_ID = 'build number could not be determined'", 145 [(r"BUILD_ID = 'build number could not be determined'",
109 r"BUILD_ID = '%s'" % revision)]) 146 r"BUILD_ID = '%s'" % revision)])
110 if utils.GuessOS() == 'win32': 147 if utils.GuessOS() == 'win32':
111 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') 148 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat')
112 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) 149 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js)
113 ReplaceInFiles([dart2js], 150 ReplaceInFiles([dart2js],
114 [(r'%SCRIPTPATH%\.\.\\lib', 151 [(r'%SCRIPTPATH%\.\.\\lib',
115 r'%SCRIPTPATH%..\lib')]) 152 r'%SCRIPTPATH%..\lib\dart2js\lib')])
116 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') 153 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat')
117 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) 154 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc)
118 else: 155 else:
119 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') 156 dart2js = os.path.join(sdk_root, 'bin', 'dart2js')
120 Copy(os.path.join(build_dir, 'dart2js'), dart2js) 157 Copy(os.path.join(build_dir, 'dart2js'), dart2js)
121 ReplaceInFiles([dart2js], 158 ReplaceInFiles([dart2js],
122 [(r'\$BIN_DIR/\.\./\.\./lib', 159 [(r'\$BIN_DIR/\.\./\.\./lib',
123 r'$BIN_DIR/../lib')]) 160 r'$BIN_DIR/../lib/dart2js/lib')])
124 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') 161 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc')
125 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) 162 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc)
126 163
127 164
128 def Main(argv): 165 def Main(argv):
129 # Pull in all of the gpyi files which will be munged into the sdk. 166 # Pull in all of the gpyi files which will be munged into the sdk.
130 io_runtime_sources = \ 167 io_runtime_sources = \
131 (eval(open("runtime/bin/io_sources.gypi").read()))['sources'] 168 (eval(open("runtime/bin/io_sources.gypi").read()))['sources']
132 169
133 HOME = dirname(dirname(realpath(__file__))) 170 HOME = dirname(dirname(realpath(__file__)))
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 # Construct lib/io/io_runtime.dart from whole cloth. 247 # Construct lib/io/io_runtime.dart from whole cloth.
211 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a') 248 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a')
212 for filename in io_runtime_sources: 249 for filename in io_runtime_sources:
213 assert filename.endswith('.dart') 250 assert filename.endswith('.dart')
214 if filename == 'io.dart': 251 if filename == 'io.dart':
215 continue 252 continue
216 dest_file.write('#source("runtime/' + filename + '");\n') 253 dest_file.write('#source("runtime/' + filename + '");\n')
217 dest_file.close() 254 dest_file.close()
218 255
219 # 256 #
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 #
220 # Create and populate lib/dom. 290 # Create and populate lib/dom.
221 # 291 #
222 dom_src_dir = join(HOME, 'lib', 'dom') 292 dom_src_dir = join(HOME, 'lib', 'dom')
223 dom_dest_dir = join(LIB, 'dom') 293 dom_dest_dir = join(LIB, 'dom')
224 os.makedirs(dom_dest_dir) 294 os.makedirs(dom_dest_dir)
225 295
226 copyfile(join(dom_src_dir, 'dart2js', 'dom_dart2js.dart'), 296 copyfile(join(dom_src_dir, 'dart2js', 'dom_dart2js.dart'),
227 join(dom_dest_dir, 'dom_dart2js.dart')) 297 join(dom_dest_dir, 'dom_dart2js.dart'))
228 298
229 # 299 #
230 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. 300 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}.
231 # 301 #
232 302
233 for library in ['_internal', 'compiler', 'config', 'html', 'core', 'coreimpl', 303 for library in ['_internal', 'core', 'coreimpl', 'crypto', 'isolate', 'json',
234 'crypto', 'isolate', 'json', 'math', 'mirrors', 'uri', 'utf', 304 'math', 'mirrors', 'uri', 'utf', 'web']:
235 'web']: 305 src_dir = join(HOME, 'lib', library)
236 copytree(join(HOME, 'lib', library), join(LIB, library), 306 dest_dir = join(LIB, library)
237 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) 307 os.makedirs(dest_dir)
238 308
239 # TODO(dgrove): fix this really ugly hack 309 for filename in os.listdir(src_dir):
240 ReplaceInFiles( 310 if filename.endswith('.dart'):
241 [join(LIB, 'compiler', 'implementation', 'lib', 'io.dart')], 311 copyfile(join(src_dir, filename), join(dest_dir, filename))
242 [('../../runtime/bin', '../io/runtime')])
243 312
244 # Create and copy pkg. 313 # Create and copy pkg.
245 PKG = join(SDK_tmp, 'pkg') 314 PKG = join(SDK_tmp, 'pkg')
246 os.makedirs(PKG) 315 os.makedirs(PKG)
247 316
248 # 317 #
249 # Create and populate pkg/{args, intl, logging, unittest} 318 # Create and populate pkg/{args, intl, logging, unittest}
250 # 319 #
251 320
252 for library in ['args', 'dartdoc', 'intl', 'logging', 'unittest']: 321 for library in ['args', 'intl', 'logging', 'unittest']:
253 copytree(join(HOME, 'pkg', library), join(PKG, library), 322 src_dir = join(HOME, 'pkg', library)
254 ignore=ignore_patterns('*.svn', 'doc', 'docs', 323 dest_dir = join(PKG, library)
255 '*.py', '*.gypi', '*.sh')) 324 os.makedirs(dest_dir)
256 325
257 # Fixup dartdoc 326 for filename in os.listdir(src_dir):
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.
258 ReplaceInFiles([ 340 ReplaceInFiles([
259 join(PKG, 'dartdoc', 'dartdoc.dart'), 341 join(PKG, 'dartdoc', 'dartdoc.dart'),
260 ], [ 342 ], [
261 ("final bool IN_SDK = false;", 343 ("final bool IN_SDK = false;",
262 "final bool IN_SDK = true;"), 344 "final bool IN_SDK = true;"),
263 ]) 345 ])
264 346
265 347
266 # Create and copy tools. 348 # Create and copy tools.
267 UTIL = join(SDK_tmp, 'util') 349 UTIL = join(SDK_tmp, 'util')
(...skipping 13 matching lines...) Expand all
281 join("guava", "r09", "guava-r09.jar"), 363 join("guava", "r09", "guava-r09.jar"),
282 join("json", "r2_20080312", "json.jar") ] 364 join("json", "r2_20080312", "json.jar") ]
283 for jarToCopy in jarsToCopy: 365 for jarToCopy in jarsToCopy:
284 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy)) 366 dest_dir = join (ANALYZER_DEST, os.path.dirname(jarToCopy))
285 os.makedirs(dest_dir) 367 os.makedirs(dest_dir)
286 dest_file = join (ANALYZER_DEST, jarToCopy) 368 dest_file = join (ANALYZER_DEST, jarToCopy)
287 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy) 369 src_file = join(ANALYZER_HOME, 'util', 'analyzer', jarToCopy)
288 copyfile(src_file, dest_file) 370 copyfile(src_file, dest_file)
289 371
290 # Create and populate util/pub. 372 # Create and populate util/pub.
291 copytree(join(HOME, 'utils', 'pub'), join(UTIL, 'pub'), 373 pub_src_dir = join(HOME, 'utils', 'pub')
374 pub_dst_dir = join(UTIL, 'pub')
375 copytree(pub_src_dir, pub_dst_dir,
292 ignore=ignore_patterns('.svn', 'sdk')) 376 ignore=ignore_patterns('.svn', 'sdk'))
293 377
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
294 revision = utils.GetSVNRevision() 386 revision = utils.GetSVNRevision()
295 387
296 # Copy dart2js. 388 # Copy dart2js.
297 CopyDart2Js(build_dir, SDK_tmp, revision) 389 CopyDart2Js(build_dir, SDK_tmp, revision)
298 390
299 # Write the 'revision' file 391 # Write the 'revision' file
300 if revision is not None: 392 if revision is not None:
301 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: 393 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
302 f.write(revision + '\n') 394 f.write(revision + '\n')
303 f.close() 395 f.close()
304 396
305 move(SDK_tmp, SDK) 397 move(SDK_tmp, SDK)
306 utils.Touch(os.path.join(SDK, 'create.stamp')) 398 utils.Touch(os.path.join(SDK, 'create.stamp'))
307 399
308 if __name__ == '__main__': 400 if __name__ == '__main__':
309 sys.exit(Main(sys.argv)) 401 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « lib/config/import_any.config ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698