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

Side by Side Diff: tools/create_sdk.py

Issue 8819030: Create the SDK in a temporary directory and copy it as a final step. (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 | « dart.gyp ('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) 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. The SDK will be 7 # A script which will be invoked from gyp to create an SDK.
8 # used either from the command-line or from the editor. Top structure is 8 #
9 # Usage: create_sdk.py sdk_directory
10 #
11 # The SDK will be used either from the command-line or from the editor.
12 # Top structure is
9 # 13 #
10 # ..sdk/ 14 # ..sdk/
11 # ....bin/ 15 # ....bin/
12 # ......dart or dart.exe (executable) 16 # ......dart or dart.exe (executable)
13 # ......frogc.dart 17 # ......frogc.dart
14 # ......frogsh (coming later) 18 # ......frogsh (coming later)
15 # ....lib/ 19 # ....lib/
16 # ......builtin/ 20 # ......builtin/
17 # ........builtin_runtime.dart 21 # ........builtin_runtime.dart
18 # ........runtime/ 22 # ........runtime/
19 # ......core/ 23 # ......core/
20 # ........core_{compiler, frog, runtime}.dart 24 # ........core_{compiler, frog, runtime}.dart
21 # ........{compiler, frog, runtime}/ 25 # ........{compiler, frog, runtime}/
22 # ......coreimpl/ 26 # ......coreimpl/
23 # ........coreimpl_{compiler, frog, runtime}.dart 27 # ........coreimpl_{compiler, frog, runtime}.dart
24 # ........{compiler, frog, runtime}/ 28 # ........{compiler, frog, runtime}/
25 # ......dom/ 29 # ......dom/
26 # ........dom.dart 30 # ........dom.dart
27 # ......frog/ 31 # ......frog/
28 # ......html/ 32 # ......html/
29 # ........html.dart 33 # ........html.dart
30 # ......htmlimpl/ 34 # ......htmlimpl/
31 # ........htmlimpl.dart 35 # ........htmlimpl.dart
32 # ......json/ 36 # ......json/
33 # ........json_{compiler, frog}.dart 37 # ........json_{compiler, frog}.dart
34 # ........{compiler, frog}/ 38 # ........{compiler, frog}/
35 # ......(more will come here - io, etc) 39 # ......(more will come here - io, etc)
36 # ....tools/ 40 # ....util/
37 # ......dartdoc/ 41 # ......dartdoc/
38 # ......(more will come here) 42 # ......(more will come here)
39 43
40 44
41 45
42 import os 46 import os
43 import re 47 import re
44 import sys 48 import sys
49 import tempfile
45 import utils 50 import utils
46 51
47 from os.path import dirname, join, realpath, exists, isdir 52 from os.path import dirname, join, realpath, exists, isdir
48 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree 53 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
49 54
50 def Main(argv): 55 def Main(argv):
51 # 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.
52 builtin_runtime_sources = \ 57 builtin_runtime_sources = \
53 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources'] 58 (eval(open("runtime/bin/builtin_sources.gypi").read()))['sources']
54 corelib_sources = \ 59 corelib_sources = \
55 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources'] 60 (eval(open("corelib/src/corelib_sources.gypi").read()))['sources']
56 corelib_frog_sources = \ 61 corelib_frog_sources = \
57 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources'] 62 (eval(open("frog/lib/frog_corelib_sources.gypi").read()))['sources']
58 corelib_runtime_sources = \ 63 corelib_runtime_sources = \
59 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources'] 64 (eval(open("runtime/lib/lib_sources.gypi").read()))['sources']
60 corelib_compiler_sources = \ 65 corelib_compiler_sources = \
61 (eval(open("compiler/compiler_corelib_sources.gypi").read())) \ 66 (eval(open("compiler/compiler_corelib_sources.gypi").read())) \
62 ['variables']['compiler_corelib_resources'] 67 ['variables']['compiler_corelib_resources']
63 coreimpl_sources = \ 68 coreimpl_sources = \
64 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\ 69 (eval(open("corelib/src/implementation/corelib_impl_sources.gypi").read()))\
65 ['sources'] 70 ['sources']
66 coreimpl_frog_sources = \ 71 coreimpl_frog_sources = \
67 (eval(open("frog/lib/frog_coreimpl_sources.gypi").read()))['sources'] 72 (eval(open("frog/lib/frog_coreimpl_sources.gypi").read()))['sources']
68 coreimpl_runtime_sources = \ 73 coreimpl_runtime_sources = \
69 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources'] 74 (eval(open("runtime/lib/lib_impl_sources.gypi").read()))['sources']
70 json_compiler_sources = \ 75 json_compiler_sources = \
71 (eval(open("compiler/jsonlib_sources.gypi").read())) \ 76 (eval(open("compiler/jsonlib_sources.gypi").read())) \
72 ['variables']['jsonlib_resources'] 77 ['variables']['jsonlib_resources']
73 json_frog_sources = \ 78 json_frog_sources = \
74 (eval(open("frog/lib/frog_json_sources.gypi").read()))['sources'] 79 (eval(open("frog/lib/frog_json_sources.gypi").read()))['sources']
75 80
76 HOME = dirname(dirname(realpath(__file__))) 81 HOME = dirname(dirname(realpath(__file__)))
77 82
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 if (os.path.basename(os.path.dirname(SDK)) != 87 if (os.path.basename(os.path.dirname(SDK)) !=
82 utils.GetBuildConf('release', 'ia32')): 88 utils.GetBuildConf('release', 'ia32')):
83 print "SDK is not built in Debug mode." 89 print "SDK is not built in Debug mode."
84 if not os.path.exists(SDK): 90 if not os.path.exists(SDK):
85 # leave empty dir behind 91 # leave empty dir behind
86 os.makedirs(SDK) 92 os.makedirs(SDK)
87 exit(0) 93 exit(0)
88 94
89 if exists(SDK): 95 if exists(SDK):
90 rmtree(SDK) 96 rmtree(SDK)
91 97
92 # Create and populate sdk/bin. 98 # Create and populate sdk/bin.
93 BIN = join(SDK, 'bin') 99 BIN = join(SDK_tmp, 'bin')
94 os.makedirs(BIN) 100 os.makedirs(BIN)
95 101
96 # Copy the Dart VM binary into sdk/bin. 102 # Copy the Dart VM binary into sdk/bin.
97 # TODO(dgrove) - deal with architectures that are not ia32. 103 # TODO(dgrove) - deal with architectures that are not ia32.
98 build_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32') 104 build_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
99 if utils.GuessOS() == 'win32': 105 if utils.GuessOS() == 'win32':
100 dart_src_binary = join(join(HOME, build_dir), 'dart.exe') 106 dart_src_binary = join(join(HOME, build_dir), 'dart.exe')
101 dart_dest_binary = join(BIN, 'dart.exe') 107 dart_dest_binary = join(BIN, 'dart.exe')
102 else: 108 else:
103 dart_src_binary = join(join(HOME, build_dir), 'dart') 109 dart_src_binary = join(join(HOME, build_dir), 'dart')
(...skipping 10 matching lines...) Expand all
114 frogc_dest.write( 120 frogc_dest.write(
115 re.sub("#import\('", "#import('../lib/frog/", frogc_contents)) 121 re.sub("#import\('", "#import('../lib/frog/", frogc_contents))
116 frogc_dest.close() 122 frogc_dest.close()
117 123
118 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart. 124 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart.
119 125
120 # 126 #
121 # Create and populate sdk/lib. 127 # Create and populate sdk/lib.
122 # 128 #
123 129
124 LIB = join(SDK, 'lib') 130 LIB = join(SDK_tmp, 'lib')
125 os.makedirs(LIB) 131 os.makedirs(LIB)
126 corelib_dest_dir = join(LIB, 'core') 132 corelib_dest_dir = join(LIB, 'core')
127 os.makedirs(corelib_dest_dir) 133 os.makedirs(corelib_dest_dir)
128 os.makedirs(join(corelib_dest_dir, 'compiler')) 134 os.makedirs(join(corelib_dest_dir, 'compiler'))
129 os.makedirs(join(corelib_dest_dir, 'frog')) 135 os.makedirs(join(corelib_dest_dir, 'frog'))
130 os.makedirs(join(corelib_dest_dir, 'runtime')) 136 os.makedirs(join(corelib_dest_dir, 'runtime'))
131 137
132 coreimpl_dest_dir = join(LIB, 'coreimpl') 138 coreimpl_dest_dir = join(LIB, 'coreimpl')
133 os.makedirs(coreimpl_dest_dir) 139 os.makedirs(coreimpl_dest_dir)
134 os.makedirs(join(coreimpl_dest_dir, 'compiler')) 140 os.makedirs(join(coreimpl_dest_dir, 'compiler'))
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 dest_file.write('#source("runtime/' + filename + '");\n') 350 dest_file.write('#source("runtime/' + filename + '");\n')
345 for filename in coreimpl_runtime_sources: 351 for filename in coreimpl_runtime_sources:
346 if filename.endswith('.dart'): 352 if filename.endswith('.dart'):
347 dest_file.write('#source("runtime/' + filename + '");\n') 353 dest_file.write('#source("runtime/' + filename + '");\n')
348 dest_file.close() 354 dest_file.close()
349 355
350 # TODO(dgrove) - create lib/coreimpl/coreimpl_compiler.dart . 356 # TODO(dgrove) - create lib/coreimpl/coreimpl_compiler.dart .
351 357
352 # Create and copy tools. 358 # Create and copy tools.
353 359
354 UTIL = join(SDK, 'tools') 360 UTIL = join(SDK_tmp, 'util')
355 os.makedirs(UTIL) 361 os.makedirs(UTIL)
356 362
357 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'), 363 copytree(join(HOME, 'utils', 'dartdoc'), join(UTIL, 'dartdoc'),
358 ignore=ignore_patterns('.svn')) 364 ignore=ignore_patterns('.svn'))
359 365
366 copytree(SDK_tmp, SDK)
ahe 2011/12/07 11:23:29 Have you considered this approach (in shell script
ahe 2011/12/07 11:25:11 Actually, there is another downside to the current
367 rmtree(SDK_tmp)
368
360 if __name__ == '__main__': 369 if __name__ == '__main__':
361 sys.exit(Main(sys.argv)) 370 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « dart.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698