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

Side by Side Diff: tools/create_sdk.py

Issue 9004001: Fix build so we can make a Windows SDK! (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | « tools/build.py ('k') | tools/utils.py » ('j') | 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) 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 # ........runtime/ 22 # ........runtime/
23 # ......core/ 23 # ......core/
24 # ........core_{compiler, frog, runtime}.dart 24 # ........core_{frog, runtime}.dart
25 # ........{compiler, frog, runtime}/ 25 # ........{frog, runtime}/
26 # ......coreimpl/ 26 # ......coreimpl/
27 # ........coreimpl_{compiler, frog, runtime}.dart 27 # ........coreimpl_{frog, runtime}.dart
28 # ........{compiler, frog, runtime}/ 28 # ........{frog, runtime}/
29 # ......dom/ 29 # ......dom/
30 # ........dom.dart 30 # ........dom.dart
31 # ......frog/ 31 # ......frog/
32 # ......html/ 32 # ......html/
33 # ........html.dart 33 # ........html.dart
34 # ......htmlimpl/ 34 # ......htmlimpl/
35 # ........htmlimpl.dart 35 # ........htmlimpl.dart
36 # ......json/ 36 # ......json/
37 # ........json_{compiler, frog}.dart 37 # ........json_{frog}.dart
38 # ........{compiler, frog}/ 38 # ........{frog}/
39 # ......(more will come here - io, etc) 39 # ......(more will come here - io, etc)
40 # ....util/ 40 # ....util/
41 # ......dartdoc/ 41 # ......dartdoc/
42 # ......(more will come here) 42 # ......(more will come here)
43 43
44 44
45 45
46 import os 46 import os
47 import re 47 import re
48 import sys 48 import sys
49 import tempfile 49 import tempfile
50 import utils 50 import utils
51 51
52 from os.path import dirname, join, realpath, exists, isdir 52 from os.path import dirname, join, realpath, exists, isdir
53 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move 53 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
54 54
55 def Main(argv): 55 def Main(argv):
56 # Pull in all of the gpyi files which will be munged into the sdk. 56 # Pull in all of the gpyi files which will be munged into the sdk.
57 builtin_runtime_sources = \ 57 builtin_runtime_sources = \
58 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] 58 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources']
59 corelib_sources = \ 59 corelib_sources = \
60 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] 60 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources']
61 corelib_frog_sources = \ 61 corelib_frog_sources = \
62 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources'] 62 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources']
63 corelib_runtime_sources = \ 63 corelib_runtime_sources = \
64 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] 64 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources']
65 corelib_compiler_sources = \
66 (eval(open("compiler/compiler_corelib_sources.gypi").read())) \
67 ['variables']['compiler_corelib_resources']
68 coreimpl_sources = \ 65 coreimpl_sources = \
69 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ 66 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\
70 ['sources'] 67 ['sources']
71 coreimpl_frog_sources = \ 68 coreimpl_frog_sources = \
72 (eval(open("frog/lib/frog_coreimpl_sources.gypi").read()))['sources'] 69 (eval(open("frog/lib/frog_coreimpl_sources.gypi").read()))['sources']
73 coreimpl_runtime_sources = \ 70 coreimpl_runtime_sources = \
74 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources'] 71 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources']
75 json_compiler_sources = \
76 (eval(open("compiler/jsonlib_sources.gypi").read())) \
77 ['variables']['jsonlib_resources']
78 json_frog_sources = \ 72 json_frog_sources = \
79 (eval(open("frog/lib/frog_json_sources.gypi").read()))['sources'] 73 (eval(open("frog/lib/frog_json_sources.gypi").read()))['sources']
80 74
81 HOME = dirname(dirname(realpath(__file__))) 75 HOME = dirname(dirname(realpath(__file__)))
82 76
83 SDK_tmp = tempfile.mkdtemp() 77 SDK_tmp = tempfile.mkdtemp()
84 SDK = argv[1] 78 SDK = argv[1]
85 79
86 # TODO(dgrove) - deal with architectures that are not ia32. 80 # TODO(dgrove) - deal with architectures that are not ia32.
87 81
88 if exists(SDK): 82 if exists(SDK):
89 rmtree(SDK) 83 rmtree(SDK)
90 84
91 # Create and populate sdk/bin. 85 # Create and populate sdk/bin.
92 BIN = join(SDK_tmp, 'bin') 86 BIN = join(SDK_tmp, 'bin')
93 os.makedirs(BIN) 87 os.makedirs(BIN)
94 88
95 # Copy the Dart VM binary into sdk/bin. 89 # Copy the Dart VM binary into sdk/bin.
96 # TODO(dgrove) - deal with architectures that are not ia32. 90 # TODO(dgrove) - deal with architectures that are not ia32.
97 build_dir = os.path.dirname(argv[1]) 91 build_dir = os.path.dirname(argv[1])
98 frogc_src_binary = join(HOME, 'frog', 'frogc') 92 frogc_file_extension = ''
99 frogc_dest_binary = join(BIN, 'frogc') 93 dart_file_extension = ''
100 if utils.GuessOS() == 'win32': 94 if utils.GuessOS() == 'win32':
101 # TODO(dgrove) - deal with frogc.bat 95 dart_file_extension = '.exe'
102 dart_src_binary = join(HOME, build_dir, 'dart.exe') 96 frogc_file_extension = '.bat'
103 dart_dest_binary = join(BIN, 'dart.exe') 97 dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension)
104 else: 98 dart_dest_binary = join(BIN, 'dart' + dart_file_extension)
105 dart_src_binary = join(HOME, build_dir, 'dart') 99 frogc_src_binary = join(HOME, 'frog', 'frogc' + frogc_file_extension)
106 dart_dest_binary = join(BIN, 'dart') 100 frogc_dest_binary = join(BIN, 'frogc' + frogc_file_extension)
107 copyfile(dart_src_binary, dart_dest_binary) 101 copyfile(dart_src_binary, dart_dest_binary)
108 copymode(dart_src_binary, dart_dest_binary) 102 copymode(dart_src_binary, dart_dest_binary)
109 copyfile(frogc_src_binary, frogc_dest_binary) 103 copyfile(frogc_src_binary, frogc_dest_binary)
110 copymode(frogc_src_binary, frogc_dest_binary) 104 copymode(frogc_src_binary, frogc_dest_binary)
111 105
112 # Create sdk/bin/frogc.dart, and hack as needed. 106 # Create sdk/bin/frogc.dart, and hack as needed.
113 frog_src_dir = join(HOME, 'frog') 107 frog_src_dir = join(HOME, 'frog')
114 108
115 # Convert frogc.dart's imports from import('*') -> import('frog/*'). 109 # Convert frogc.dart's imports from import('*') -> import('frog/*').
116 frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read() 110 frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read()
117 frogc_dest = open(join(BIN, 'frogc.dart'), 'w') 111 frogc_dest = open(join(BIN, 'frogc.dart'), 'w')
118 frogc_dest.write( 112 frogc_dest.write(
119 re.sub("#import\('", "#import('../lib/frog/", frogc_contents)) 113 re.sub("#import\('", "#import('../lib/frog/", frogc_contents))
120 frogc_dest.close() 114 frogc_dest.close()
121 115
122 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart. 116 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart.
123 117
124 # 118 #
125 # Create and populate sdk/lib. 119 # Create and populate sdk/lib.
126 # 120 #
127 121
128 LIB = join(SDK_tmp, 'lib') 122 LIB = join(SDK_tmp, 'lib')
129 os.makedirs(LIB) 123 os.makedirs(LIB)
130 corelib_dest_dir = join(LIB, 'core') 124 corelib_dest_dir = join(LIB, 'core')
131 os.makedirs(corelib_dest_dir) 125 os.makedirs(corelib_dest_dir)
132 os.makedirs(join(corelib_dest_dir, 'compiler'))
133 os.makedirs(join(corelib_dest_dir, 'frog')) 126 os.makedirs(join(corelib_dest_dir, 'frog'))
134 os.makedirs(join(corelib_dest_dir, 'runtime')) 127 os.makedirs(join(corelib_dest_dir, 'runtime'))
135 128
136 coreimpl_dest_dir = join(LIB, 'coreimpl') 129 coreimpl_dest_dir = join(LIB, 'coreimpl')
137 os.makedirs(coreimpl_dest_dir) 130 os.makedirs(coreimpl_dest_dir)
138 os.makedirs(join(coreimpl_dest_dir, 'compiler'))
139 os.makedirs(join(coreimpl_dest_dir, 'frog')) 131 os.makedirs(join(coreimpl_dest_dir, 'frog'))
140 os.makedirs(join(coreimpl_dest_dir, 'frog', 'node')) 132 os.makedirs(join(coreimpl_dest_dir, 'frog', 'node'))
141 os.makedirs(join(coreimpl_dest_dir, 'runtime')) 133 os.makedirs(join(coreimpl_dest_dir, 'runtime'))
142 134
143 135
144 # 136 #
145 # Create and populate lib/runtime. 137 # Create and populate lib/runtime.
146 # 138 #
147 builtin_dest_dir = join(LIB, 'builtin') 139 builtin_dest_dir = join(LIB, 'builtin')
148 os.makedirs(builtin_dest_dir) 140 os.makedirs(builtin_dest_dir)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 copytree(join(html_src_dir, 'src'), join(target_dir, 'src'), 195 copytree(join(html_src_dir, 'src'), join(target_dir, 'src'),
204 ignore=ignore_patterns('.svn')) 196 ignore=ignore_patterns('.svn'))
205 copytree(join(html_src_dir, 'generated'), join(target_dir, 'generated'), 197 copytree(join(html_src_dir, 'generated'), join(target_dir, 'generated'),
206 ignore=ignore_patterns('.svn')) 198 ignore=ignore_patterns('.svn'))
207 199
208 200
209 # 201 #
210 # Create and populate lib/json. 202 # Create and populate lib/json.
211 # 203 #
212 json_dest_dir = join(LIB, 'json') 204 json_dest_dir = join(LIB, 'json')
213 json_compiler_dest_dir = join(LIB, 'json', 'compiler')
214 os.makedirs(json_dest_dir) 205 os.makedirs(json_dest_dir)
215 os.makedirs(json_compiler_dest_dir)
216 206
217 for filename in json_frog_sources: 207 for filename in json_frog_sources:
218 copyfile(join(HOME, 'frog', 'lib', filename), 208 copyfile(join(HOME, 'frog', 'lib', filename),
219 join(json_dest_dir, filename)) 209 join(json_dest_dir, filename))
220 210
221 for filename in json_compiler_sources:
222 copyfile(join(HOME, 'compiler', filename),
223 join(json_compiler_dest_dir, os.path.basename(filename)))
224
225 # Create json_compiler.dart from whole cloth.
226 dest_file = open(join(LIB, 'json', 'json_compiler.dart'), 'w')
227 dest_file.write('#library("dart:json");\n')
228 dest_file.write('#import("compiler/json.dart");\n')
229 dest_file.close()
230
231 # 211 #
232 # Create and populate lib/dom. 212 # Create and populate lib/dom.
233 # 213 #
234 dom_src_dir = join(HOME, 'client', 'dom') 214 dom_src_dir = join(HOME, 'client', 'dom')
235 dom_dest_dir = join(LIB, 'dom') 215 dom_dest_dir = join(LIB, 'dom')
236 os.makedirs(dom_dest_dir) 216 os.makedirs(dom_dest_dir)
237 217
238 for filename in os.listdir(dom_src_dir): 218 for filename in os.listdir(dom_src_dir):
239 src_file = join(dom_src_dir, filename) 219 src_file = join(dom_src_dir, filename)
240 dest_file = join(dom_dest_dir, filename) 220 dest_file = join(dom_dest_dir, filename)
241 if filename.endswith('.dart') or filename.endswith('.js'): 221 if filename.endswith('.dart') or filename.endswith('.js'):
242 copyfile(src_file, dest_file) 222 copyfile(src_file, dest_file)
243 elif isdir(src_file): 223 elif isdir(src_file):
244 if filename not in ['benchmarks', 'idl', 'scripts', 'snippets', '.svn']: 224 if filename not in ['benchmarks', 'idl', 'scripts', 'snippets', '.svn']:
245 copytree(src_file, dest_file, 225 copytree(src_file, dest_file,
246 ignore=ignore_patterns('.svn', 'interface', 'wrapping', 226 ignore=ignore_patterns('.svn', 'interface', 'wrapping',
247 '*monkey*')) 227 '*monkey*'))
248 228
249 # 229 #
250 # Create and populate lib/core. 230 # Create and populate lib/core.
251 # 231 #
252 232
253 # First, copy corelib/* to lib/{compiler, frog, runtime} 233 # First, copy corelib/* to lib/{frog, runtime}
254 for filename in corelib_sources: 234 for filename in corelib_sources:
255 for target_dir in ['compiler', 'frog', 'runtime']: 235 for target_dir in ['frog', 'runtime']:
256 copyfile(join('corelib', 'src', filename), 236 copyfile(join('corelib', 'src', filename),
257 join(corelib_dest_dir, target_dir, filename)) 237 join(corelib_dest_dir, target_dir, filename))
258 238
259 # Next, copy the compiler sources on top of {core,coreimpl}/compiler
260 for filename in corelib_compiler_sources:
261 if filename.endswith('.dart'):
262 filename = re.sub('lib/','', filename)
263 if (not filename.startswith('implementation/') and
264 not filename.startswith('corelib')):
265 copyfile(join('compiler', 'lib', filename),
266 join(corelib_dest_dir, 'compiler', filename))
267
268 # Next, copy the frog library source on top of core/frog 239 # Next, copy the frog library source on top of core/frog
269 # TOOD(dgrove): move json to top-level 240 # TOOD(dgrove): move json to top-level
270 for filename in corelib_frog_sources: 241 for filename in corelib_frog_sources:
271 copyfile(join('frog', 'lib', filename), 242 copyfile(join('frog', 'lib', filename),
272 join(corelib_dest_dir, 'frog', filename)) 243 join(corelib_dest_dir, 'frog', filename))
273 244
274 # Next, copy the runtime library source on top of core/runtime 245 # Next, copy the runtime library source on top of core/runtime
275 for filename in corelib_runtime_sources: 246 for filename in corelib_runtime_sources:
276 if filename.endswith('.dart'): 247 if filename.endswith('.dart'):
277 copyfile(join('runtime', 'lib', filename), 248 copyfile(join('runtime', 'lib', filename),
(...skipping 15 matching lines...) Expand all
293 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w') 264 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w')
294 dest_file.write('#library("dart:core");\n') 265 dest_file.write('#library("dart:core");\n')
295 dest_file.write('#import("dart:coreimpl");\n') 266 dest_file.write('#import("dart:coreimpl");\n')
296 for filename in corelib_sources: 267 for filename in corelib_sources:
297 dest_file.write('#source("runtime/' + filename + '");\n') 268 dest_file.write('#source("runtime/' + filename + '");\n')
298 for filename in corelib_runtime_sources: 269 for filename in corelib_runtime_sources:
299 if filename.endswith('.dart'): 270 if filename.endswith('.dart'):
300 dest_file.write('#source("runtime/' + filename + '");\n') 271 dest_file.write('#source("runtime/' + filename + '");\n')
301 dest_file.close() 272 dest_file.close()
302 273
303 # construct lib/core_compiler.dart from whole cloth.
304 dest_file = open(join(corelib_dest_dir, 'core_compiler.dart'), 'w')
305 dest_file.write('#library("dart:core");\n')
306 dest_file.write('#import("dart:coreimpl");\n')
307 for filename in os.listdir(join(corelib_dest_dir, 'compiler')):
308 dest_file.write('#import("compiler/' + filename + '");\n')
309 dest_file.close()
310
311 # 274 #
312 # Create and populate lib/coreimpl. 275 # Create and populate lib/coreimpl.
313 # 276 #
314 277
315 # First, copy corelib/src/implementation to corelib/{compiler, frog, runtime}. 278 # First, copy corelib/src/implementation to corelib/{frog, runtime}.
316 for filename in coreimpl_sources: 279 for filename in coreimpl_sources:
317 for target_dir in ['compiler', 'frog', 'runtime']: 280 for target_dir in ['frog', 'runtime']:
318 copyfile(join('corelib', 'src', 'implementation', filename), 281 copyfile(join('corelib', 'src', 'implementation', filename),
319 join(coreimpl_dest_dir, target_dir, filename)) 282 join(coreimpl_dest_dir, target_dir, filename))
320 283
321 # Next, copy {compiler, frog, runtime}-specific implementations.
322 for filename in corelib_compiler_sources:
323 if (filename.endswith(".dart")):
324 if filename.startswith("lib/implementation/"):
325 filename = os.path.basename(filename)
326 copyfile(join('compiler', 'lib', 'implementation', filename),
327 join(coreimpl_dest_dir, 'compiler', filename))
328
329 for filename in coreimpl_frog_sources: 284 for filename in coreimpl_frog_sources:
330 copyfile(join('frog', 'lib', filename), 285 copyfile(join('frog', 'lib', filename),
331 join(coreimpl_dest_dir, 'frog', filename)) 286 join(coreimpl_dest_dir, 'frog', filename))
332 287
333 for filename in coreimpl_runtime_sources: 288 for filename in coreimpl_runtime_sources:
334 if filename.endswith('.dart'): 289 if filename.endswith('.dart'):
335 copyfile(join('runtime', 'lib', filename), 290 copyfile(join('runtime', 'lib', filename),
336 join(coreimpl_dest_dir, 'runtime', filename)) 291 join(coreimpl_dest_dir, 'runtime', filename))
337 292
338 293
(...skipping 10 matching lines...) Expand all
349 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth. 304 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth.
350 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w') 305 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w')
351 dest_file.write('#library("dart:coreimpl");\n') 306 dest_file.write('#library("dart:coreimpl");\n')
352 for filename in coreimpl_sources: 307 for filename in coreimpl_sources:
353 dest_file.write('#source("runtime/' + filename + '");\n') 308 dest_file.write('#source("runtime/' + filename + '");\n')
354 for filename in coreimpl_runtime_sources: 309 for filename in coreimpl_runtime_sources:
355 if filename.endswith('.dart'): 310 if filename.endswith('.dart'):
356 dest_file.write('#source("runtime/' + filename + '");\n') 311 dest_file.write('#source("runtime/' + filename + '");\n')
357 dest_file.close() 312 dest_file.close()
358 313
359 # construct lib/coreimpl_compiler.dart from whole cloth.
360 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_compiler.dart'), 'w')
361 dest_file.write('#library("dart:coreimpl");\n')
362 for filename in os.listdir(join(coreimpl_dest_dir, 'compiler')):
363 dest_file.write('#import("compiler/' + filename + '");\n')
364 dest_file.close()
365
366 # Create and copy tools. 314 # Create and copy tools.
367 315
368 UTIL = join(SDK_tmp, 'util') 316 UTIL = join(SDK_tmp, 'util')
369 os.makedirs(UTIL) 317 os.makedirs(UTIL)
370 318
371 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'), 319 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'),
372 ignore=ignore_patterns('.svn')) 320 ignore=ignore_patterns('.svn'))
373 321
374 move(SDK_tmp, SDK) 322 move(SDK_tmp, SDK)
375 323
376 if __name__ == '__main__': 324 if __name__ == '__main__':
377 sys.exit(Main(sys.argv)) 325 sys.exit(Main(sys.argv))
326
OLDNEW
« no previous file with comments | « tools/build.py ('k') | tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698