OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** The entry point to the compiler. Used to implement `bin/dwc.dart`. */ | 5 /** The entry point to the compiler. Used to implement `bin/dwc.dart`. */ |
6 library dwc; | 6 library dwc; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'package:logging/logging.dart' show Level; | 10 import 'package:logging/logging.dart' show Level; |
11 | 11 |
12 import 'src/compiler.dart'; | 12 import 'src/compiler.dart'; |
13 import 'src/file_system.dart'; | 13 import 'src/file_system.dart'; |
14 import 'src/file_system/console.dart'; | 14 import 'src/file_system/console.dart'; |
15 import 'src/files.dart'; | 15 import 'src/files.dart'; |
16 import 'src/messages.dart'; | 16 import 'src/messages.dart'; |
17 import 'src/options.dart'; | 17 import 'src/options.dart'; |
18 import 'src/utils.dart'; | 18 import 'src/utils.dart'; |
19 | 19 |
20 FileSystem fileSystem; | 20 FileSystem fileSystem; |
21 | 21 |
22 void main() { | 22 void main(args) { |
23 run(new Options().arguments).then((result) { | 23 run(args).then((result) { |
24 exit(result.success ? 0 : 1); | 24 exit(result.success ? 0 : 1); |
25 }); | 25 }); |
26 } | 26 } |
27 | 27 |
28 /** Contains the result of a compiler run. */ | 28 /** Contains the result of a compiler run. */ |
29 class CompilerResult { | 29 class CompilerResult { |
30 final bool success; | 30 final bool success; |
31 | 31 |
32 /** Map of output path to source, if there is one */ | 32 /** Map of output path to source, if there is one */ |
33 final Map<String, String> outputs; | 33 final Map<String, String> outputs; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // A broken symlink works like a file | 148 // A broken symlink works like a file |
149 var toFile = new File(linkPath); | 149 var toFile = new File(linkPath); |
150 if (toFile.existsSync()) { | 150 if (toFile.existsSync()) { |
151 toFile.deleteSync(); | 151 toFile.deleteSync(); |
152 } | 152 } |
153 | 153 |
154 var targetPath = path.join(path.dirname(options.inputFile), 'packages'); | 154 var targetPath = path.join(path.dirname(options.inputFile), 'packages'); |
155 // [fullPathSync] will canonicalize the path, resolving any symlinks. | 155 // [fullPathSync] will canonicalize the path, resolving any symlinks. |
156 // TODO(sigmund): once it's possible in dart:io, we just want to use a full | 156 // TODO(sigmund): once it's possible in dart:io, we just want to use a full |
157 // path, but not necessarily resolve symlinks. | 157 // path, but not necessarily resolve symlinks. |
158 var target = new File(targetPath).fullPathSync().toString(); | 158 var target = new File(targetPath).absolute.resolveSymbolicLinksSync(); |
159 return createSymlink(target, linkPath, messages: messages); | 159 return createSymlink(target, linkPath, messages: messages); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 // TODO(jmesserly): this code was taken from Pub's io library. | 163 // TODO(jmesserly): this code was taken from Pub's io library. |
164 // Added error handling and don't return the file result, to match the code | 164 // Added error handling and don't return the file result, to match the code |
165 // we had previously. Also "target" and "link" only accept strings. And inlined | 165 // we had previously. Also "target" and "link" only accept strings. And inlined |
166 // the relevant parts of runProcess. Note that it uses "cmd" to get the path | 166 // the relevant parts of runProcess. Note that it uses "cmd" to get the path |
167 // on Windows. | 167 // on Windows. |
168 /** | 168 /** |
(...skipping 20 matching lines...) Expand all Loading... |
189 if (result.exitCode != 0) { | 189 if (result.exitCode != 0) { |
190 var details = 'subprocess stdout:\n${result.stdout}\n' | 190 var details = 'subprocess stdout:\n${result.stdout}\n' |
191 'subprocess stderr:\n${result.stderr}'; | 191 'subprocess stderr:\n${result.stderr}'; |
192 messages.error( | 192 messages.error( |
193 'unable to create symlink\n target: $target\n link:$link\n$details', | 193 'unable to create symlink\n target: $target\n link:$link\n$details', |
194 null); | 194 null); |
195 } | 195 } |
196 return null; | 196 return null; |
197 }); | 197 }); |
198 } | 198 } |
OLD | NEW |