OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 20 matching lines...) Expand all Loading... | |
31 # ......io/ | 31 # ......io/ |
32 # ......isolate/ | 32 # ......isolate/ |
33 # ......json/ | 33 # ......json/ |
34 # ......math/ | 34 # ......math/ |
35 # ......mirrors/ | 35 # ......mirrors/ |
36 # ......uri/ | 36 # ......uri/ |
37 # ......utf/ | 37 # ......utf/ |
38 # ......scalarlist/ | 38 # ......scalarlist/ |
39 # ....pkg/ | 39 # ....pkg/ |
40 # ......args/ | 40 # ......args/ |
41 # ......compiler/ | |
42 # ......dartdoc/ | |
43 #.......htmlescape/ | 41 #.......htmlescape/ |
44 # ......intl/ | 42 # ......intl/ |
45 # ......logging/ | 43 # ......logging/ |
46 # ......meta/ | 44 # ......meta/ |
47 # ......unittest/ | 45 # ......unittest/ |
48 # ......(more will come here) | 46 # ......(more will come here) |
49 # ....util/ | 47 # ....util/ |
50 # ......analyzer/ | 48 # ......analyzer/ |
51 # ........dart_analyzer.jar | 49 # ........dart_analyzer.jar |
52 # ........(third-party libraries for dart_analyzer) | 50 # ........(third-party libraries for dart_analyzer) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 if utils.GuessOS() == 'win32': | 97 if utils.GuessOS() == 'win32': |
100 file_extension = '.bat' | 98 file_extension = '.bat' |
101 | 99 |
102 src = src_file + file_extension | 100 src = src_file + file_extension |
103 dest = join(dest_dir, basename(src_file) + file_extension) | 101 dest = join(dest_dir, basename(src_file) + file_extension) |
104 Copy(src, dest) | 102 Copy(src, dest) |
105 | 103 |
106 | 104 |
107 def CopyDart2Js(build_dir, sdk_root, version): | 105 def CopyDart2Js(build_dir, sdk_root, version): |
108 if version: | 106 if version: |
109 ReplaceInFiles([os.path.join(sdk_root, 'pkg', 'compiler', | 107 ReplaceInFiles([os.path.join(sdk_root, 'lib', '_internal', 'compiler', |
110 'implementation', 'compiler.dart')], | 108 'implementation', 'compiler.dart')], |
111 [(r"BUILD_ID = 'build number could not be determined'", | 109 [(r"BUILD_ID = 'build number could not be determined'", |
112 r"BUILD_ID = '%s'" % version)]) | 110 r"BUILD_ID = '%s'" % version)]) |
113 if utils.GuessOS() == 'win32': | 111 if utils.GuessOS() == 'win32': |
114 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') | 112 dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat') |
115 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) | 113 Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js) |
116 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') | 114 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat') |
117 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) | 115 Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc) |
118 # TODO(dgrove) - fix this once issue 4788 is addressed. | |
119 ReplaceInFiles([dart2js], | |
120 [(r'%SCRIPTPATH%\.\.\\\.\.\\lib', r'%SCRIPTPATH%..\\pkg')]) | |
121 ReplaceInFiles([dartdoc], | |
122 [(r'%SCRIPTPATH%\.\.\\\.\.\\pkg', r'%SCRIPTPATH%..\\pkg')]) | |
123 else: | 116 else: |
124 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') | 117 dart2js = os.path.join(sdk_root, 'bin', 'dart2js') |
125 Copy(os.path.join(build_dir, 'dart2js'), dart2js) | 118 Copy(os.path.join(build_dir, 'dart2js'), dart2js) |
126 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') | 119 dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc') |
127 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) | 120 Copy(os.path.join(build_dir, 'dartdoc'), dartdoc) |
128 | 121 |
129 # TODO(dgrove) - fix this once issue 4788 is addressed. | |
130 ReplaceInFiles([dart2js], | |
131 [(r'\$BIN_DIR/\.\./\.\./lib', r'$BIN_DIR/../pkg')]) | |
132 ReplaceInFiles([dartdoc], | |
133 [(r'\$BIN_DIR/\.\./\.\.', r'$BIN_DIR/..')]) | |
134 | |
135 # TODO(ahe): Enable for Windows as well. | 122 # TODO(ahe): Enable for Windows as well. |
136 subprocess.call([os.path.join(build_dir, 'gen_snapshot'), | 123 subprocess.call([os.path.join(build_dir, 'gen_snapshot'), |
137 | |
138 # TODO(ahe): Remove option when | |
139 # http://dartbug.com/5989 is fixed. | |
140 '--optimization_counter_threshold=-1', | |
141 | |
142 '--script_snapshot=%s' % | 124 '--script_snapshot=%s' % |
143 os.path.join(sdk_root, 'pkg', 'compiler', | 125 os.path.join(sdk_root, 'lib', '_internal', 'compiler', |
144 'implementation', 'dart2js.dart.snapshot'), | 126 'implementation', 'dart2js.dart.snapshot'), |
145 os.path.join(sdk_root, 'pkg', 'compiler', | 127 os.path.join(sdk_root, 'lib', '_internal', 'compiler', |
146 'implementation', 'dart2js.dart')]) | 128 'implementation', 'dart2js.dart')]) |
147 | 129 |
148 | 130 |
149 | 131 |
150 def Main(argv): | 132 def Main(argv): |
151 # Pull in all of the gpyi files which will be munged into the sdk. | 133 # Pull in all of the gpyi files which will be munged into the sdk. |
152 HOME = dirname(dirname(realpath(__file__))) | 134 HOME = dirname(dirname(realpath(__file__))) |
153 | 135 |
154 SDK = argv[1] | 136 SDK = argv[1] |
155 SDK_tmp = '%s.tmp' % SDK | 137 SDK_tmp = '%s.tmp' % SDK |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 os.makedirs(LIB) | 201 os.makedirs(LIB) |
220 | 202 |
221 # | 203 # |
222 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. | 204 # Create and populate lib/{core, crypto, isolate, json, uri, utf, ...}. |
223 # | 205 # |
224 | 206 |
225 os.makedirs(join(LIB, 'html')) | 207 os.makedirs(join(LIB, 'html')) |
226 for library in ['_internal', 'collection', 'core', 'coreimpl', 'crypto', 'io', | 208 for library in ['_internal', 'collection', 'core', 'coreimpl', 'crypto', 'io', |
227 'isolate', join('html', 'dart2js'), join('html', 'dartium'), | 209 'isolate', join('html', 'dart2js'), join('html', 'dartium'), |
228 'json', 'math', 'mirrors', 'scalarlist', 'uri', 'utf']: | 210 'json', 'math', 'mirrors', 'scalarlist', 'uri', 'utf']: |
229 copytree(join(HOME, 'lib', library), join(LIB, library), | 211 copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library), |
230 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | 212 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) |
231 | 213 |
232 | 214 |
233 # Create and copy pkg. | 215 # Create and copy pkg. |
234 PKG = join(SDK_tmp, 'pkg') | 216 PKG = join(SDK_tmp, 'pkg') |
235 os.makedirs(PKG) | 217 os.makedirs(PKG) |
236 | 218 |
237 # | 219 # |
238 # Create and populate pkg/{args, intl, logging, meta, unittest} | 220 # Create and populate pkg/{args, intl, logging, meta, unittest} |
239 # | 221 # |
240 | 222 |
241 for library in ['args', 'htmlescape', 'dartdoc', 'intl', 'logging', | 223 for library in ['args', 'htmlescape', 'intl', 'logging', |
242 'meta', 'unittest']: | 224 'meta', 'unittest']: |
243 copytree(join(HOME, 'pkg', library), join(PKG, library), | 225 copytree(join(HOME, 'pkg', library), join(PKG, library), |
244 ignore=ignore_patterns('*.svn', 'doc', 'docs', | 226 ignore=ignore_patterns('*.svn', 'doc', 'docs', |
245 '*.py', '*.gypi', '*.sh')) | 227 '*.py', '*.gypi', '*.sh')) |
246 | 228 |
247 # TODO(dgrove): Remove this once issue 4788 is addressed. | |
248 copytree(join(HOME, 'lib', 'compiler'), join(PKG, 'compiler'), | |
249 ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh')) | |
250 | |
251 ReplaceInFiles( | |
252 [join(LIB, '_internal', 'libraries.dart')], | |
253 [('"compiler/', '"../pkg/compiler/')]) | |
254 | |
255 # Fixup dartdoc | |
256 # TODO(dgrove): Remove this once issue 4788 is addressed. | |
257 ReplaceInFiles([ | |
258 join(PKG, 'dartdoc', 'lib', 'src', 'mirrors', 'dart2js_mirror.dart'), | |
259 join(PKG, 'dartdoc', 'lib', 'mirrors_util.dart'), | |
260 join(PKG, 'dartdoc', 'lib', 'classify.dart'), | |
261 join(PKG, 'dartdoc', 'lib', 'src', 'client', 'client-live-nav.dart'), | |
262 join(PKG, 'dartdoc', 'lib', 'src', 'client', 'client-static.dart'), | |
263 join(PKG, 'dartdoc', 'lib', 'dartdoc.dart'), | |
264 ], [ | |
265 ("../../lib/compiler", | |
266 "../../pkg/compiler"), | |
267 ]) | |
268 | |
269 # Create and copy tools. | 229 # Create and copy tools. |
270 UTIL = join(SDK_tmp, 'util') | 230 UTIL = join(SDK_tmp, 'util') |
271 os.makedirs(UTIL) | 231 os.makedirs(UTIL) |
272 | 232 |
273 if ShouldCopyAnalyzer(): | 233 if ShouldCopyAnalyzer(): |
274 # Create and copy Analyzer library into 'util' | 234 # Create and copy Analyzer library into 'util' |
275 ANALYZER_DEST = join(UTIL, 'analyzer') | 235 ANALYZER_DEST = join(UTIL, 'analyzer') |
276 os.makedirs(ANALYZER_DEST) | 236 os.makedirs(ANALYZER_DEST) |
277 | 237 |
278 analyzer_src_jar = join(ANALYZER_HOME, 'util', 'analyzer', | 238 analyzer_src_jar = join(ANALYZER_HOME, 'util', 'analyzer', |
(...skipping 26 matching lines...) Expand all Loading... | |
305 ], [ | 265 ], [ |
306 ("var pathTo7zip = '../../third_party/7zip/7za.exe';", | 266 ("var pathTo7zip = '../../third_party/7zip/7za.exe';", |
307 "var pathTo7zip = '7zip/7za.exe';"), | 267 "var pathTo7zip = '7zip/7za.exe';"), |
308 ]) | 268 ]) |
309 | 269 |
310 version = utils.GetVersion() | 270 version = utils.GetVersion() |
311 | 271 |
312 # Copy dart2js. | 272 # Copy dart2js. |
313 CopyDart2Js(build_dir, SDK_tmp, version) | 273 CopyDart2Js(build_dir, SDK_tmp, version) |
314 | 274 |
275 if (utils.GuessOS() == 'win32'): | |
ahe
2012/11/02 08:15:25
FYI: This should be temporary. We will move these
| |
276 ReplaceInFiles([join(SDK_tmp, 'bin', 'dart2js.bat'), | |
277 join(SDK_tmp, 'bin', 'dartdoc.bat'), | |
278 join(SDK_tmp, 'bin', 'pub.bat')], | |
279 [("..\\..\\sdk\\lib", "..\\lib")]) | |
280 else: | |
281 ReplaceInFiles([join(SDK_tmp, 'bin', 'dart2js'), | |
282 join(SDK_tmp, 'bin', 'dartdoc'), | |
283 join(SDK_tmp, 'bin', 'pub')], | |
284 [("../../sdk/lib", "../lib")]) | |
285 | |
286 # Fix up dartdoc. | |
287 # TODO(dgrove): Remove this once sdk and dart-sdk match. | |
288 ReplaceInFiles([join(SDK_tmp, 'lib', '_internal', 'dartdoc', 'lib', 'dartdoc.d art')], | |
ahe
2012/11/02 08:15:25
Long line.
| |
289 [("_internal/dartdoc/lib/src/client/client", | |
290 "lib/_internal/dartdoc/lib/src/client/client")]) | |
291 | |
315 # Write the 'version' file | 292 # Write the 'version' file |
316 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') | 293 versionFile = open(os.path.join(SDK_tmp, 'version'), 'w') |
317 versionFile.write(version + '\n') | 294 versionFile.write(version + '\n') |
318 versionFile.close() | 295 versionFile.close() |
319 | 296 |
320 # Write the 'revision' file | 297 # Write the 'revision' file |
321 revision = utils.GetSVNRevision() | 298 revision = utils.GetSVNRevision() |
322 | 299 |
323 if revision is not None: | 300 if revision is not None: |
324 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: | 301 with open(os.path.join(SDK_tmp, 'revision'), 'w') as f: |
325 f.write(revision + '\n') | 302 f.write(revision + '\n') |
326 f.close() | 303 f.close() |
327 | 304 |
328 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) | 305 Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README')) |
329 | 306 |
330 move(SDK_tmp, SDK) | 307 move(SDK_tmp, SDK) |
331 | 308 |
332 if __name__ == '__main__': | 309 if __name__ == '__main__': |
333 sys.exit(Main(sys.argv)) | 310 sys.exit(Main(sys.argv)) |
OLD | NEW |