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

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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 204
213 json_frog_dest_dir = join(LIB, 'json', 'frog') 205 json_frog_dest_dir = join(LIB, 'json', 'frog')
214 json_compiler_dest_dir = join(LIB, 'json', 'compiler')
215 os.makedirs(json_frog_dest_dir) 206 os.makedirs(json_frog_dest_dir)
216 os.makedirs(json_compiler_dest_dir)
217 207
218 for filename in json_frog_sources: 208 for filename in json_frog_sources:
219 copyfile(join(HOME, 'frog', 'lib', filename), 209 copyfile(join(HOME, 'frog', 'lib', filename),
220 join(json_frog_dest_dir, filename)) 210 join(json_frog_dest_dir, filename))
221 211
222 for filename in json_compiler_sources: 212 # Create json_frog.dart from whole cloth.
223 copyfile(join(HOME, 'compiler', filename),
224 join(json_compiler_dest_dir, os.path.basename(filename)))
225
226 # Create json_compiler.dart and json_frog.dart from whole cloth.
227 dest_file = open(join(LIB, 'json', 'json_compiler.dart'), 'w')
228 dest_file.write('#library("dart:json");\n')
229 dest_file.write('#import("compiler/json.dart");\n')
230 dest_file.close()
231 dest_file = open(join(LIB, 'json', 'json_frog.dart'), 'w') 213 dest_file = open(join(LIB, 'json', 'json_frog.dart'), 'w')
232 dest_file.write('#library("dart:json");\n') 214 dest_file.write('#library("dart:json");\n')
233 dest_file.write('#import("frog/json.dart");\n') 215 dest_file.write('#import("frog/json.dart");\n')
234 dest_file.close() 216 dest_file.close()
235 217
236 # 218 #
237 # Create and populate lib/dom. 219 # Create and populate lib/dom.
238 # 220 #
239 dom_src_dir = join(HOME, 'client', 'dom') 221 dom_src_dir = join(HOME, 'client', 'dom')
240 dom_dest_dir = join(LIB, 'dom') 222 dom_dest_dir = join(LIB, 'dom')
241 os.makedirs(dom_dest_dir) 223 os.makedirs(dom_dest_dir)
242 224
243 for filename in os.listdir(dom_src_dir): 225 for filename in os.listdir(dom_src_dir):
244 src_file = join(dom_src_dir, filename) 226 src_file = join(dom_src_dir, filename)
245 dest_file = join(dom_dest_dir, filename) 227 dest_file = join(dom_dest_dir, filename)
246 if filename.endswith('.dart') or filename.endswith('.js'): 228 if filename.endswith('.dart') or filename.endswith('.js'):
247 copyfile(src_file, dest_file) 229 copyfile(src_file, dest_file)
248 elif isdir(src_file): 230 elif isdir(src_file):
249 if filename not in ['benchmarks', 'idl', 'scripts', 'snippets', '.svn']: 231 if filename not in ['benchmarks', 'idl', 'scripts', 'snippets', '.svn']:
250 copytree(src_file, dest_file, 232 copytree(src_file, dest_file,
251 ignore=ignore_patterns('.svn', 'interface', 'wrapping', 233 ignore=ignore_patterns('.svn', 'interface', 'wrapping',
252 '*monkey*')) 234 '*monkey*'))
253 235
254 # 236 #
255 # Create and populate lib/core. 237 # Create and populate lib/core.
256 # 238 #
257 239
258 # First, copy corelib/* to lib/{compiler, frog, runtime} 240 # First, copy corelib/* to lib/{frog, runtime}
259 for filename in corelib_sources: 241 for filename in corelib_sources:
260 for target_dir in ['compiler', 'frog', 'runtime']: 242 for target_dir in ['frog', 'runtime']:
261 copyfile(join('corelib', 'src', filename), 243 copyfile(join('corelib', 'src', filename),
262 join(corelib_dest_dir, target_dir, filename)) 244 join(corelib_dest_dir, target_dir, filename))
263 245
264 # Next, copy the compiler sources on top of {core,coreimpl}/compiler
265 for filename in corelib_compiler_sources:
266 if filename.endswith('.dart'):
267 filename = re.sub('lib/','', filename)
268 if (not filename.startswith('implementation/') and
269 not filename.startswith('corelib')):
270 copyfile(join('compiler', 'lib', filename),
271 join(corelib_dest_dir, 'compiler', filename))
272
273 # Next, copy the frog library source on top of core/frog 246 # Next, copy the frog library source on top of core/frog
274 # TOOD(dgrove): move json to top-level 247 # TOOD(dgrove): move json to top-level
275 for filename in corelib_frog_sources: 248 for filename in corelib_frog_sources:
276 copyfile(join('frog', 'lib', filename), 249 copyfile(join('frog', 'lib', filename),
277 join(corelib_dest_dir, 'frog', filename)) 250 join(corelib_dest_dir, 'frog', filename))
278 251
279 # Next, copy the runtime library source on top of core/runtime 252 # Next, copy the runtime library source on top of core/runtime
280 for filename in corelib_runtime_sources: 253 for filename in corelib_runtime_sources:
281 if filename.endswith('.dart'): 254 if filename.endswith('.dart'):
282 copyfile(join('runtime', 'lib', filename), 255 copyfile(join('runtime', 'lib', filename),
(...skipping 15 matching lines...) Expand all
298 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w') 271 dest_file = open(join(corelib_dest_dir, 'core_runtime.dart'), 'w')
299 dest_file.write('#library("dart:core");\n') 272 dest_file.write('#library("dart:core");\n')
300 dest_file.write('#import("dart:coreimpl");\n') 273 dest_file.write('#import("dart:coreimpl");\n')
301 for filename in corelib_sources: 274 for filename in corelib_sources:
302 dest_file.write('#source("runtime/' + filename + '");\n') 275 dest_file.write('#source("runtime/' + filename + '");\n')
303 for filename in corelib_runtime_sources: 276 for filename in corelib_runtime_sources:
304 if filename.endswith('.dart'): 277 if filename.endswith('.dart'):
305 dest_file.write('#source("runtime/' + filename + '");\n') 278 dest_file.write('#source("runtime/' + filename + '");\n')
306 dest_file.close() 279 dest_file.close()
307 280
308 # construct lib/core_compiler.dart from whole cloth.
309 dest_file = open(join(corelib_dest_dir, 'core_compiler.dart'), 'w')
310 dest_file.write('#library("dart:core");\n')
311 dest_file.write('#import("dart:coreimpl");\n')
312 for filename in os.listdir(join(corelib_dest_dir, 'compiler')):
313 dest_file.write('#import("compiler/' + filename + '");\n')
314 dest_file.close()
315
316 # 281 #
317 # Create and populate lib/coreimpl. 282 # Create and populate lib/coreimpl.
318 # 283 #
319 284
320 # First, copy corelib/src/implementation to corelib/{compiler, frog, runtime}. 285 # First, copy corelib/src/implementation to corelib/{frog, runtime}.
321 for filename in coreimpl_sources: 286 for filename in coreimpl_sources:
322 for target_dir in ['compiler', 'frog', 'runtime']: 287 for target_dir in ['frog', 'runtime']:
323 copyfile(join('corelib', 'src', 'implementation', filename), 288 copyfile(join('corelib', 'src', 'implementation', filename),
324 join(coreimpl_dest_dir, target_dir, filename)) 289 join(coreimpl_dest_dir, target_dir, filename))
325 290
326 # Next, copy {compiler, frog, runtime}-specific implementations.
327 for filename in corelib_compiler_sources:
328 if (filename.endswith(".dart")):
329 if filename.startswith("lib/implementation/"):
330 filename = os.path.basename(filename)
331 copyfile(join('compiler', 'lib', 'implementation', filename),
332 join(coreimpl_dest_dir, 'compiler', filename))
333 291
334 for filename in coreimpl_frog_sources: 292 for filename in coreimpl_frog_sources:
335 copyfile(join('frog', 'lib', filename), 293 copyfile(join('frog', 'lib', filename),
336 join(coreimpl_dest_dir, 'frog', filename)) 294 join(coreimpl_dest_dir, 'frog', filename))
337 295
338 for filename in coreimpl_runtime_sources: 296 for filename in coreimpl_runtime_sources:
339 if filename.endswith('.dart'): 297 if filename.endswith('.dart'):
340 copyfile(join('runtime', 'lib', filename), 298 copyfile(join('runtime', 'lib', filename),
341 join(coreimpl_dest_dir, 'runtime', filename)) 299 join(coreimpl_dest_dir, 'runtime', filename))
342 300
(...skipping 11 matching lines...) Expand all
354 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth. 312 # Construct lib/coreimpl/coreimpl_runtime.dart from whole cloth.
355 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w') 313 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_runtime.dart'), 'w')
356 dest_file.write('#library("dart:coreimpl");\n') 314 dest_file.write('#library("dart:coreimpl");\n')
357 for filename in coreimpl_sources: 315 for filename in coreimpl_sources:
358 dest_file.write('#source("runtime/' + filename + '");\n') 316 dest_file.write('#source("runtime/' + filename + '");\n')
359 for filename in coreimpl_runtime_sources: 317 for filename in coreimpl_runtime_sources:
360 if filename.endswith('.dart'): 318 if filename.endswith('.dart'):
361 dest_file.write('#source("runtime/' + filename + '");\n') 319 dest_file.write('#source("runtime/' + filename + '");\n')
362 dest_file.close() 320 dest_file.close()
363 321
364 # construct lib/coreimpl_compiler.dart from whole cloth.
365 dest_file = open(join(coreimpl_dest_dir, 'coreimpl_compiler.dart'), 'w')
366 dest_file.write('#library("dart:coreimpl");\n')
367 for filename in os.listdir(join(coreimpl_dest_dir, 'compiler')):
368 dest_file.write('#import("compiler/' + filename + '");\n')
369 dest_file.close()
370 322
371 # Create and copy tools. 323 # Create and copy tools.
372 324
373 UTIL = join(SDK_tmp, 'util') 325 UTIL = join(SDK_tmp, 'util')
374 os.makedirs(UTIL) 326 os.makedirs(UTIL)
375 327
376 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'), 328 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'),
377 ignore=ignore_patterns('.svn')) 329 ignore=ignore_patterns('.svn'))
378 330
379 move(SDK_tmp, SDK) 331 move(SDK_tmp, SDK)
380 332
381 if __name__ == '__main__': 333 if __name__ == '__main__':
382 sys.exit(Main(sys.argv)) 334 sys.exit(Main(sys.argv))
OLDNEW
« frog/frogc.bat ('K') | « tools/build.py ('k') | tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698