OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.cmdline; | 5 library dart2js.cmdline; |
6 | 6 |
7 import 'dart:async' | 7 import 'dart:async' |
8 show Future, EventSink; | 8 show Future, EventSink; |
9 import 'dart:convert' show UTF8, LineSplitter; | 9 import 'dart:convert' show UTF8, LineSplitter; |
10 import 'dart:io' | 10 import 'dart:io' |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // m[0] is the entire match (which will be equal to argument). m[1] | 59 // m[0] is the entire match (which will be equal to argument). m[1] |
60 // is something like "-o" or "--out=", and m[2] is the parameter. | 60 // is something like "-o" or "--out=", and m[2] is the parameter. |
61 Match m = new RegExp('^(-[a-z]|--.+=)(.*)').firstMatch(argument); | 61 Match m = new RegExp('^(-[a-z]|--.+=)(.*)').firstMatch(argument); |
62 if (m == null) { | 62 if (m == null) { |
63 if (isOptionalArgument) return null; | 63 if (isOptionalArgument) return null; |
64 helpAndFail('Unknown option "$argument".'); | 64 helpAndFail('Unknown option "$argument".'); |
65 } | 65 } |
66 return m[2]; | 66 return m[2]; |
67 } | 67 } |
68 | 68 |
69 String extractPath(String argument) { | 69 String extractPath(String argument, {bool isDirectory: true}) { |
70 String path = nativeToUriPath(extractParameter(argument)); | 70 String path = nativeToUriPath(extractParameter(argument)); |
71 return path.endsWith("/") ? path : "$path/"; | 71 return !path.endsWith("/") && isDirectory ? "$path/" : path; |
72 } | 72 } |
73 | 73 |
74 void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { | 74 void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { |
75 // TODO(ahe): Use ../../args/args.dart for parsing options instead. | 75 // TODO(ahe): Use ../../args/args.dart for parsing options instead. |
76 var patterns = <String>[]; | 76 var patterns = <String>[]; |
77 for (OptionHandler handler in handlers) { | 77 for (OptionHandler handler in handlers) { |
78 patterns.add(handler.pattern); | 78 patterns.add(handler.pattern); |
79 } | 79 } |
80 var pattern = new RegExp('^(${patterns.join(")\$|^(")})\$'); | 80 var pattern = new RegExp('^(${patterns.join(")\$|^(")})\$'); |
81 | 81 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 setLibraryRoot(String argument) { | 137 setLibraryRoot(String argument) { |
138 libraryRoot = currentDirectory.resolve(extractPath(argument)); | 138 libraryRoot = currentDirectory.resolve(extractPath(argument)); |
139 } | 139 } |
140 | 140 |
141 setPackageRoot(String argument) { | 141 setPackageRoot(String argument) { |
142 packageRoot = currentDirectory.resolve(extractPath(argument)); | 142 packageRoot = currentDirectory.resolve(extractPath(argument)); |
143 } | 143 } |
144 | 144 |
145 setPackageConfig(String argument) { | 145 setPackageConfig(String argument) { |
146 packageConfig = currentDirectory.resolve(extractPath(argument)); | 146 packageConfig = |
| 147 currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
147 } | 148 } |
148 | 149 |
149 setOutput(Iterator<String> arguments) { | 150 setOutput(Iterator<String> arguments) { |
150 optionsImplyCompilation.add(arguments.current); | 151 optionsImplyCompilation.add(arguments.current); |
151 String path; | 152 String path; |
152 if (arguments.current == '-o') { | 153 if (arguments.current == '-o') { |
153 if (!arguments.moveNext()) { | 154 if (!arguments.moveNext()) { |
154 helpAndFail('Error: Missing file after -o option.'); | 155 helpAndFail('Error: Missing file after -o option.'); |
155 } | 156 } |
156 path = arguments.current; | 157 path = arguments.current; |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 } else if (exitCode == 253) { | 767 } else if (exitCode == 253) { |
767 print(">>> TEST CRASH"); | 768 print(">>> TEST CRASH"); |
768 } else { | 769 } else { |
769 print(">>> TEST FAIL"); | 770 print(">>> TEST FAIL"); |
770 } | 771 } |
771 stderr.writeln(">>> EOF STDERR"); | 772 stderr.writeln(">>> EOF STDERR"); |
772 subscription.resume(); | 773 subscription.resume(); |
773 }); | 774 }); |
774 }); | 775 }); |
775 } | 776 } |
OLD | NEW |