OLD | NEW |
| (Empty) |
1 #!/usr/bin/env dart | |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
3 // for details. All rights reserved. Use of this source code is governed by a | |
4 // BSD-style license that can be found in the LICENSE file. | |
5 | |
6 /** | |
7 * This utility carves out the embedded bootstrap JavaScript in | |
8 * js.dart as a separate file that may be included directly in html. | |
9 * This is necessary in settings where script injection is disallowed. | |
10 * | |
11 * To run, navigate to the top-level directory for this project and run: | |
12 * .../dart ./tools/create_bootstrap.dart | |
13 */ | |
14 library create_bootstrap; | |
15 | |
16 import 'dart:io'; | |
17 | |
18 final JS_PATTERN = new RegExp(r'final _JS_BOOTSTRAP = r"""((.*\n)*)""";'); | |
19 | |
20 final HEADER = """ | |
21 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
22 // for details. All rights reserved. Use of this source code is governed by a | |
23 // BSD-style license that can be found in the LICENSE file. | |
24 | |
25 // THIS FILE IS AUTO GENERATED. PLEASE DO NOT EDIT. | |
26 | |
27 // TODO(vsm): Move this file once we determine where assets should go. See | |
28 // http://dartbug.com/6101. | |
29 """; | |
30 | |
31 createFile(Path source, Path target) { | |
32 final f = new File.fromPath(source); | |
33 f.readAsString() | |
34 .then((text) { | |
35 final js = JS_PATTERN.firstMatch(text).group(1); | |
36 final out = new File.fromPath(target); | |
37 out.create() | |
38 .then((out) => out.open(mode: FileMode.WRITE) | |
39 .then((file) => file.writeString(HEADER) | |
40 .then((file) => file.writeString(js) | |
41 .then((file) => file.close())))); | |
42 }); | |
43 } | |
44 | |
45 create(Path libPath) { | |
46 final source = libPath.append('js.dart'); | |
47 final target = libPath.append('dart_interop.js'); | |
48 createFile(source, target); | |
49 } | |
50 | |
51 main() { | |
52 final scriptPath = new Path(Platform.script).directoryPath; | |
53 final libPath = scriptPath.join(new Path('../lib')); | |
54 create(libPath); | |
55 } | |
OLD | NEW |