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

Side by Side Diff: tools/create_sdk.py

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