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

Side by Side Diff: dart/tools/create_sdk.py

Issue 9877001: Fix the SDK build after frog/leg rename. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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 | « no previous file | 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. 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 #
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 # ......(more will come here) 50 # ......(more will come here)
51 51
52 52
53 53
54 import os 54 import os
55 import re 55 import re
56 import sys 56 import sys
57 import tempfile 57 import tempfile
58 import utils 58 import utils
59 59
60 # TODO(dgrove): Only import modules following Google style guide.
60 from os.path import dirname, join, realpath, exists, isdir 61 from os.path import dirname, join, realpath, exists, isdir
62
63 # TODO(dgrove): Only import modules following Google style guide.
61 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move 64 from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
62 65
63 def ReplaceInFiles(paths, subs): 66 def ReplaceInFiles(paths, subs):
64 '''Reads a series of files, applies a series of substitutions to each, and 67 '''Reads a series of files, applies a series of substitutions to each, and
65 saves them back out. subs should by a list of (pattern, replace) tuples.''' 68 saves them back out. subs should by a list of (pattern, replace) tuples.'''
66 for path in paths: 69 for path in paths:
67 contents = open(path).read() 70 contents = open(path).read()
68 for pattern, replace in subs: 71 for pattern, replace in subs:
69 contents = re.sub(pattern, replace, contents) 72 contents = re.sub(pattern, replace, contents)
70 73
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 copyfile(frogc_src_binary, frogc_dest_binary) 127 copyfile(frogc_src_binary, frogc_dest_binary)
125 copymode(frogc_src_binary, frogc_dest_binary) 128 copymode(frogc_src_binary, frogc_dest_binary)
126 129
127 # Create sdk/bin/frogc.dart, and hack as needed. 130 # Create sdk/bin/frogc.dart, and hack as needed.
128 frog_src_dir = join(HOME, 'frog') 131 frog_src_dir = join(HOME, 'frog')
129 132
130 # Convert frogc.dart's imports from import('*') -> import('frog/*'). 133 # Convert frogc.dart's imports from import('*') -> import('frog/*').
131 frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read() 134 frogc_contents = open(join(frog_src_dir, 'frogc.dart')).read()
132 frogc_dest = open(join(BIN, 'frogc.dart'), 'w') 135 frogc_dest = open(join(BIN, 'frogc.dart'), 'w')
133 frogc_dest.write( 136 frogc_dest.write(
134 re.sub("#import\('", "#import('../lib/frog/", frogc_contents)) 137 re.sub(r"#import\('([^.])", r"#import('../lib/frog/\1", frogc_contents))
135 frogc_dest.close() 138 frogc_dest.close()
136 139
137 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart. 140 # TODO(dgrove): copy and fix up frog.dart, minfrogc.dart.
138 141
139 # 142 #
140 # Create and populate sdk/lib. 143 # Create and populate sdk/lib.
141 # 144 #
142 145
143 LIB = join(SDK_tmp, 'lib') 146 LIB = join(SDK_tmp, 'lib')
144 os.makedirs(LIB) 147 os.makedirs(LIB)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 193
191 # Construct lib/io/io_runtime.dart from whole cloth. 194 # Construct lib/io/io_runtime.dart from whole cloth.
192 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a') 195 dest_file = open(join(io_dest_dir, 'io_runtime.dart'), 'a')
193 for filename in io_runtime_sources: 196 for filename in io_runtime_sources:
194 assert filename.endswith('.dart') 197 assert filename.endswith('.dart')
195 if filename == 'io.dart': 198 if filename == 'io.dart':
196 continue 199 continue
197 dest_file.write('#source("runtime/' + filename + '");\n') 200 dest_file.write('#source("runtime/' + filename + '");\n')
198 dest_file.close() 201 dest_file.close()
199 202
203 #
204 # Create and populate lib/compiler.
205 #
206 compiler_src_dir = join(HOME, 'lib', 'compiler')
207 compiler_dest_dir = join(LIB, 'compiler')
208
209 copytree(compiler_src_dir, compiler_dest_dir, ignore=ignore_patterns('.svn'))
210
211 # Remap imports in lib/compiler/* .
212 for (dirpath, subdirs, filenames) in os.walk(compiler_dest_dir):
213 for filename in filenames:
214 if filename.endswith('.dart'):
215 filename = join(dirpath, filename)
216 file_contents = open(filename).read()
217 file = open(filename, 'w')
218 file_contents = re.sub(r"\.\./lib", "..", file_contents)
219 file_contents = re.sub(r"\.\./frog/", "frog/", file_contents)
220 file.write(file_contents)
221 file.close()
200 222
201 # 223 #
202 # Create and populate lib/frog. 224 # Create and populate lib/frog.
203 # 225 #
226 # TODO(dgrove): Frog is not a dart library and should not live in lib.
227 #
204 frog_dest_dir = join(LIB, 'frog') 228 frog_dest_dir = join(LIB, 'frog')
205 os.makedirs(frog_dest_dir) 229 os.makedirs(frog_dest_dir)
206 230
207 for filename in os.listdir(frog_src_dir): 231 for filename in os.listdir(frog_src_dir):
208 if filename == 'frog_options.dart': 232 if filename == 'frog_options.dart':
209 # change config from 'dev' to 'sdk' in frog_options.dart 233 # change config from 'dev' to 'sdk' in frog_options.dart
210 frog_options_contents = open(join(frog_src_dir, filename)).read() 234 frog_options_contents = open(join(frog_src_dir, filename)).read()
211 frog_options_dest = open(join(frog_dest_dir, filename), 'w') 235 frog_options_dest = open(join(frog_dest_dir, filename), 'w')
212 frog_options_dest.write(re.sub("final config = \'dev\';", 236 frog_options_dest.write(re.sub("final config = \'dev\';",
213 "final config = \'sdk\';", 237 "final config = \'sdk\';",
214 frog_options_contents)) 238 frog_options_contents))
215 frog_options_dest.close() 239 frog_options_dest.close()
216 elif filename.endswith('.dart'): 240 elif filename.endswith('.dart'):
217 copyfile(join(frog_src_dir, filename), join(frog_dest_dir, filename)) 241 copyfile(join(frog_src_dir, filename), join(frog_dest_dir, filename))
218 242
219 leg_dest_dir = join(frog_dest_dir, 'leg')
220 copytree(join(frog_src_dir, 'leg'), leg_dest_dir,
221 ignore=ignore_patterns('.svn'))
222
223 # Remap imports in frog/leg/* .
224 for filename in os.listdir(leg_dest_dir):
225 if filename.endswith('.dart'):
226 file_contents = open(join(leg_dest_dir, filename)).read()
227 file = open(join(leg_dest_dir, filename), 'w')
228 file.write(re.sub("../../lib", "../..", file_contents))
229 file.close()
230 243
231 copytree(join(frog_src_dir, 'server'), join(frog_dest_dir, 'server'), 244 copytree(join(frog_src_dir, 'server'), join(frog_dest_dir, 'server'),
232 ignore=ignore_patterns('.svn')) 245 ignore=ignore_patterns('.svn'))
233 246
234 # Remap imports in frog/... . 247 # Remap imports in frog/... .
235 for (dirpath, subdirs, _) in os.walk(frog_dest_dir): 248 for (dirpath, subdirs, filenames) in os.walk(frog_dest_dir):
236 for subdir in subdirs: 249 for filename in filenames:
237 for filename in os.listdir(join(dirpath, subdir)): 250 if filename.endswith('.dart'):
238 if filename.endswith('.dart'): 251 file_contents = open(join(dirpath, filename)).read()
239 file_contents = open(join(dirpath, subdir, filename)).read() 252 file = open(join(dirpath, filename), 'w')
240 file = open(join(dirpath, subdir, filename), 'w') 253 file.write(re.sub(r"\.\./lib/", "../", file_contents))
241 file.write(re.sub("../lib/", "../", file_contents)) 254 file.close()
242 file.close()
243 255
244 # 256 #
245 # Create and populate lib/html. 257 # Create and populate lib/html.
246 # 258 #
247 html_src_dir = join(HOME, 'lib', 'html') 259 html_src_dir = join(HOME, 'lib', 'html')
248 html_dest_dir = join(LIB, 'html') 260 html_dest_dir = join(LIB, 'html')
249 os.makedirs(html_dest_dir) 261 os.makedirs(html_dest_dir)
250 262
251 copyfile(join(html_src_dir, 'frog', 'html_frog.dart'), 263 copyfile(join(html_src_dir, 'frog', 'html_frog.dart'),
252 join(html_dest_dir, 'html_frog.dart')) 264 join(html_dest_dir, 'html_frog.dart'))
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 404
393 # Create and copy tools. 405 # Create and copy tools.
394 406
395 UTIL = join(SDK_tmp, 'util') 407 UTIL = join(SDK_tmp, 'util')
396 os.makedirs(UTIL) 408 os.makedirs(UTIL)
397 409
398 move(SDK_tmp, SDK) 410 move(SDK_tmp, SDK)
399 411
400 if __name__ == '__main__': 412 if __name__ == '__main__':
401 sys.exit(Main(sys.argv)) 413 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698