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:io' | 9 import 'dart:io' |
10 show exit, File, FileMode, Platform, RandomAccessFile, FileSystemException; | 10 show exit, File, FileMode, Platform, RandomAccessFile, FileSystemException; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 /** | 49 /** |
50 * Extract the parameter of an option. | 50 * Extract the parameter of an option. |
51 * | 51 * |
52 * For example, in ['--out=fisk.js'] and ['-ohest.js'], the parameters | 52 * For example, in ['--out=fisk.js'] and ['-ohest.js'], the parameters |
53 * are ['fisk.js'] and ['hest.js'], respectively. | 53 * are ['fisk.js'] and ['hest.js'], respectively. |
54 */ | 54 */ |
55 String extractParameter(String argument) { | 55 String extractParameter(String argument) { |
56 // m[0] is the entire match (which will be equal to argument). m[1] | 56 // m[0] is the entire match (which will be equal to argument). m[1] |
57 // is something like "-o" or "--out=", and m[2] is the parameter. | 57 // is something like "-o" or "--out=", and m[2] is the parameter. |
58 Match m = new RegExp('^(-[a-z]|--.+=)(.*)').firstMatch(argument); | 58 Match m = new RegExp('^(-[a-z]|--.+=)(.*)').firstMatch(argument); |
59 if (m == null) helpAndFail('Error: Unknown option "$argument".'); | 59 if (m == null) helpAndFail('Unknown option "$argument".'); |
60 return m[2]; | 60 return m[2]; |
61 } | 61 } |
62 | 62 |
63 String extractPath(String argument) { | 63 String extractPath(String argument) { |
64 String path = nativeToUriPath(extractParameter(argument)); | 64 String path = nativeToUriPath(extractParameter(argument)); |
65 return path.endsWith("/") ? path : "$path/"; | 65 return path.endsWith("/") ? path : "$path/"; |
66 } | 66 } |
67 | 67 |
68 void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { | 68 void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { |
69 // TODO(ahe): Use ../../args/args.dart for parsing options instead. | 69 // TODO(ahe): Use ../../args/args.dart for parsing options instead. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 Uri out = currentDirectory.resolve('out.js'); | 102 Uri out = currentDirectory.resolve('out.js'); |
103 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); | 103 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
104 Uri packageRoot = null; | 104 Uri packageRoot = null; |
105 List<String> options = new List<String>(); | 105 List<String> options = new List<String>(); |
106 bool explicitOut = false; | 106 bool explicitOut = false; |
107 bool wantHelp = false; | 107 bool wantHelp = false; |
108 bool wantVersion = false; | 108 bool wantVersion = false; |
109 String outputLanguage = 'JavaScript'; | 109 String outputLanguage = 'JavaScript'; |
110 bool stripArgumentSet = false; | 110 bool stripArgumentSet = false; |
111 bool analyzeOnly = false; | 111 bool analyzeOnly = false; |
112 bool analyzeAll = false; | |
113 // List of provided options that imply that output is expected. | |
114 List<String> optionsImplyCompilation = <String>[]; | |
112 bool hasDisallowUnsafeEval = false; | 115 bool hasDisallowUnsafeEval = false; |
113 // TODO(johnniwinther): Measure time for reading files. | 116 // TODO(johnniwinther): Measure time for reading files. |
114 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); | 117 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); |
115 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); | 118 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
116 Map<String, dynamic> environment = new Map<String, dynamic>(); | 119 Map<String, dynamic> environment = new Map<String, dynamic>(); |
117 | 120 |
118 passThrough(String argument) => options.add(argument); | 121 passThrough(String argument) => options.add(argument); |
119 | 122 |
120 if (BUILD_ID != null) { | 123 if (BUILD_ID != null) { |
121 passThrough("--build-id=$BUILD_ID"); | 124 passThrough("--build-id=$BUILD_ID"); |
122 } | 125 } |
123 | 126 |
124 setLibraryRoot(String argument) { | 127 setLibraryRoot(String argument) { |
125 libraryRoot = currentDirectory.resolve(extractPath(argument)); | 128 libraryRoot = currentDirectory.resolve(extractPath(argument)); |
126 } | 129 } |
127 | 130 |
128 setPackageRoot(String argument) { | 131 setPackageRoot(String argument) { |
129 packageRoot = currentDirectory.resolve(extractPath(argument)); | 132 packageRoot = currentDirectory.resolve(extractPath(argument)); |
130 } | 133 } |
131 | 134 |
132 setOutput(Iterator<String> arguments) { | 135 setOutput(Iterator<String> arguments) { |
136 optionsImplyCompilation.add(arguments.current); | |
133 String path; | 137 String path; |
134 if (arguments.current == '-o') { | 138 if (arguments.current == '-o') { |
135 if (!arguments.moveNext()) { | 139 if (!arguments.moveNext()) { |
136 helpAndFail('Error: Missing file after -o option.'); | 140 helpAndFail('Error: Missing file after -o option.'); |
137 } | 141 } |
138 path = arguments.current; | 142 path = arguments.current; |
139 } else { | 143 } else { |
140 path = extractParameter(arguments.current); | 144 path = extractParameter(arguments.current); |
141 } | 145 } |
142 explicitOut = true; | 146 explicitOut = true; |
143 out = currentDirectory.resolve(nativeToUriPath(path)); | 147 out = currentDirectory.resolve(nativeToUriPath(path)); |
144 sourceMapOut = Uri.parse('$out.map'); | 148 sourceMapOut = Uri.parse('$out.map'); |
145 } | 149 } |
146 | 150 |
147 setOutputType(String argument) { | 151 setOutputType(String argument) { |
152 optionsImplyCompilation.add(argument); | |
148 if (argument == '--output-type=dart') { | 153 if (argument == '--output-type=dart') { |
149 outputLanguage = OUTPUT_LANGUAGE_DART; | 154 outputLanguage = OUTPUT_LANGUAGE_DART; |
150 if (!explicitOut) { | 155 if (!explicitOut) { |
151 out = currentDirectory.resolve('out.dart'); | 156 out = currentDirectory.resolve('out.dart'); |
152 sourceMapOut = currentDirectory.resolve('out.dart.map'); | 157 sourceMapOut = currentDirectory.resolve('out.dart.map'); |
153 } | 158 } |
154 } | 159 } |
155 passThrough(argument); | 160 passThrough(argument); |
156 } | 161 } |
157 | 162 |
158 String getDepsOutput(Map<String, SourceFile> sourceFiles) { | 163 String getDepsOutput(Map<String, SourceFile> sourceFiles) { |
159 var filenames = new List.from(sourceFiles.keys); | 164 var filenames = new List.from(sourceFiles.keys); |
160 filenames.sort(); | 165 filenames.sort(); |
161 return filenames.join("\n"); | 166 return filenames.join("\n"); |
162 } | 167 } |
163 | 168 |
164 setStrip(String argument) { | 169 setStrip(String argument) { |
170 optionsImplyCompilation.add(argument); | |
165 stripArgumentSet = true; | 171 stripArgumentSet = true; |
166 passThrough(argument); | 172 passThrough(argument); |
167 } | 173 } |
168 | 174 |
169 setAnalyzeOnly(String argument) { | 175 setAnalyzeOnly(String argument) { |
170 analyzeOnly = true; | 176 analyzeOnly = true; |
171 passThrough(argument); | 177 passThrough(argument); |
172 } | 178 } |
173 | 179 |
180 setAnalyzeAll(String argument) { | |
181 analyzeAll = true; | |
182 passThrough(argument); | |
183 } | |
184 | |
174 setVerbose(_) { | 185 setVerbose(_) { |
175 diagnosticHandler.verbose = true; | 186 diagnosticHandler.verbose = true; |
176 passThrough('--verbose'); | 187 passThrough('--verbose'); |
177 } | 188 } |
178 | 189 |
190 implyCompilation(String argument) { | |
191 optionsImplyCompilation.add(argument); | |
192 passThrough(argument); | |
193 } | |
194 | |
179 addInEnvironment(String argument) { | 195 addInEnvironment(String argument) { |
180 int eqIndex = argument.indexOf('='); | 196 int eqIndex = argument.indexOf('='); |
181 String name = argument.substring(2, eqIndex); | 197 String name = argument.substring(2, eqIndex); |
182 String value = argument.substring(eqIndex + 1); | 198 String value = argument.substring(eqIndex + 1); |
183 environment[name] = value; | 199 environment[name] = value; |
184 } | 200 } |
185 | 201 |
186 setCategories(String argument) { | 202 setCategories(String argument) { |
187 List<String> categories = extractParameter(argument).split(','); | 203 List<String> categories = extractParameter(argument).split(','); |
188 Set<String> allowedCategories = | 204 Set<String> allowedCategories = |
189 LIBRARIES.values.map((x) => x.category).toSet(); | 205 LIBRARIES.values.map((x) => x.category).toSet(); |
190 allowedCategories.remove('Shared'); | 206 allowedCategories.remove('Shared'); |
191 allowedCategories.remove('Internal'); | 207 allowedCategories.remove('Internal'); |
192 List<String> allowedCategoriesList = | 208 List<String> allowedCategoriesList = |
193 new List<String>.from(allowedCategories); | 209 new List<String>.from(allowedCategories); |
194 allowedCategoriesList.sort(); | 210 allowedCategoriesList.sort(); |
195 if (categories.contains('all')) { | 211 if (categories.contains('all')) { |
196 categories = allowedCategoriesList; | 212 categories = allowedCategoriesList; |
197 } else { | 213 } else { |
198 String allowedCategoriesString = allowedCategoriesList.join(', '); | 214 String allowedCategoriesString = allowedCategoriesList.join(', '); |
199 for (String category in categories) { | 215 for (String category in categories) { |
200 if (!allowedCategories.contains(category)) { | 216 if (!allowedCategories.contains(category)) { |
201 fail('Error: unsupported library category "$category", ' | 217 fail('Unsupported library category "$category", ' |
202 'supported categories are: $allowedCategoriesString'); | 218 'supported categories are: $allowedCategoriesString'); |
203 } | 219 } |
204 } | 220 } |
205 } | 221 } |
206 passThrough('--categories=${categories.join(",")}'); | 222 passThrough('--categories=${categories.join(",")}'); |
207 } | 223 } |
208 | 224 |
209 handleShortOptions(String argument) { | 225 handleShortOptions(String argument) { |
210 var shortOptions = argument.substring(1).split(""); | 226 var shortOptions = argument.substring(1).split(""); |
211 for (var shortOption in shortOptions) { | 227 for (var shortOption in shortOptions) { |
212 switch (shortOption) { | 228 switch (shortOption) { |
213 case 'v': | 229 case 'v': |
214 setVerbose(null); | 230 setVerbose(null); |
215 break; | 231 break; |
216 case 'h': | 232 case 'h': |
217 case '?': | 233 case '?': |
218 wantHelp = true; | 234 wantHelp = true; |
219 break; | 235 break; |
220 case 'c': | 236 case 'c': |
221 passThrough('--enable-checked-mode'); | 237 passThrough('--enable-checked-mode'); |
222 break; | 238 break; |
223 case 'm': | 239 case 'm': |
224 passThrough('--minify'); | 240 implyCompilation('--minify'); |
225 break; | 241 break; |
226 default: | 242 default: |
227 throw 'Internal error: "$shortOption" did not match'; | 243 throw 'Internal error: "$shortOption" did not match'; |
228 } | 244 } |
229 } | 245 } |
230 } | 246 } |
231 | 247 |
232 Uri computePrecompiledUri() { | 248 Uri computePrecompiledUri() { |
233 String extension = 'precompiled.js'; | 249 String extension = 'precompiled.js'; |
234 String outPath = out.path; | 250 String outPath = out.path; |
(...skipping 13 matching lines...) Expand all Loading... | |
248 new OptionHandler('--suppress-warnings', | 264 new OptionHandler('--suppress-warnings', |
249 (_) => diagnosticHandler.showWarnings = false), | 265 (_) => diagnosticHandler.showWarnings = false), |
250 new OptionHandler('--suppress-hints', | 266 new OptionHandler('--suppress-hints', |
251 (_) => diagnosticHandler.showHints = false), | 267 (_) => diagnosticHandler.showHints = false), |
252 new OptionHandler('--output-type=dart|--output-type=js', setOutputType), | 268 new OptionHandler('--output-type=dart|--output-type=js', setOutputType), |
253 new OptionHandler('--verbose', setVerbose), | 269 new OptionHandler('--verbose', setVerbose), |
254 new OptionHandler('--version', (_) => wantVersion = true), | 270 new OptionHandler('--version', (_) => wantVersion = true), |
255 new OptionHandler('--library-root=.+', setLibraryRoot), | 271 new OptionHandler('--library-root=.+', setLibraryRoot), |
256 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), | 272 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), |
257 new OptionHandler('--allow-mock-compilation', passThrough), | 273 new OptionHandler('--allow-mock-compilation', passThrough), |
258 new OptionHandler('--minify|-m', passThrough), | 274 new OptionHandler('--minify|-m', implyCompilation), |
259 new OptionHandler('--force-strip=.*', setStrip), | 275 new OptionHandler('--force-strip=.*', setStrip), |
260 new OptionHandler('--disable-diagnostic-colors', | 276 new OptionHandler('--disable-diagnostic-colors', |
261 (_) => diagnosticHandler.enableColors = false), | 277 (_) => diagnosticHandler.enableColors = false), |
262 new OptionHandler('--enable-diagnostic-colors', | 278 new OptionHandler('--enable-diagnostic-colors', |
263 (_) => diagnosticHandler.enableColors = true), | 279 (_) => diagnosticHandler.enableColors = true), |
264 new OptionHandler('--enable[_-]checked[_-]mode|--checked', | 280 new OptionHandler('--enable[_-]checked[_-]mode|--checked', |
265 (_) => passThrough('--enable-checked-mode')), | 281 (_) => passThrough('--enable-checked-mode')), |
266 new OptionHandler('--enable-concrete-type-inference', | 282 new OptionHandler('--enable-concrete-type-inference', |
267 (_) => passThrough('--enable-concrete-type-inference')), | 283 (_) => implyCompilation( |
284 '--enable-concrete-type-inference')), | |
268 new OptionHandler('--trust-type-annotations', | 285 new OptionHandler('--trust-type-annotations', |
269 (_) => passThrough('--trust-type-annotations')), | 286 (_) => implyCompilation('--trust-type-annotations')), |
270 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), | 287 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), |
271 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), | 288 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), |
272 new OptionHandler('--analyze-all', passThrough), | 289 new OptionHandler('--analyze-all', setAnalyzeAll), |
273 new OptionHandler('--analyze-only', setAnalyzeOnly), | 290 new OptionHandler('--analyze-only', setAnalyzeOnly), |
274 new OptionHandler('--analyze-signatures-only', passThrough), | 291 new OptionHandler('--analyze-signatures-only', setAnalyzeOnly), |
275 new OptionHandler('--disable-native-live-type-analysis', passThrough), | 292 new OptionHandler('--disable-native-live-type-analysis', passThrough), |
276 new OptionHandler('--categories=.*', setCategories), | 293 new OptionHandler('--categories=.*', setCategories), |
277 new OptionHandler('--disable-type-inference', passThrough), | 294 new OptionHandler('--disable-type-inference', implyCompilation), |
278 new OptionHandler('--terse', passThrough), | 295 new OptionHandler('--terse', passThrough), |
279 new OptionHandler('--dump-info', passThrough), | 296 new OptionHandler('--dump-info', implyCompilation), |
280 new OptionHandler('--disallow-unsafe-eval', | 297 new OptionHandler('--disallow-unsafe-eval', |
281 (_) => hasDisallowUnsafeEval = true), | 298 (_) => hasDisallowUnsafeEval = true), |
282 new OptionHandler('--hide-package-warnings', passThrough), | 299 new OptionHandler('--hide-package-warnings', passThrough), |
283 new OptionHandler('-D.+=.*', addInEnvironment), | 300 new OptionHandler('-D.+=.*', addInEnvironment), |
284 | 301 |
285 // The following two options must come last. | 302 // The following two options must come last. |
286 new OptionHandler('-.*', (String argument) { | 303 new OptionHandler('-.*', (String argument) { |
287 helpAndFail('Error: Unknown option "$argument".'); | 304 helpAndFail("Unknown option '$argument'."); |
288 }), | 305 }), |
289 new OptionHandler('.*', (String argument) { | 306 new OptionHandler('.*', (String argument) { |
290 arguments.add(nativeToUriPath(argument)); | 307 arguments.add(nativeToUriPath(argument)); |
291 }) | 308 }) |
292 ]; | 309 ]; |
293 | 310 |
294 parseCommandLine(handlers, argv); | 311 parseCommandLine(handlers, argv); |
295 if (wantHelp || wantVersion) { | 312 if (wantHelp || wantVersion) { |
296 helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose); | 313 helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose); |
297 } | 314 } |
298 | 315 |
299 if (hasDisallowUnsafeEval) { | 316 if (hasDisallowUnsafeEval) { |
300 String precompiledName = | 317 String precompiledName = |
301 relativize(currentDirectory, computePrecompiledUri(), isWindows); | 318 relativize(currentDirectory, computePrecompiledUri(), isWindows); |
302 helpAndFail("Error: option '--disallow-unsafe-eval' has been removed." | 319 helpAndFail("Option '--disallow-unsafe-eval' has been removed." |
303 " Instead, the compiler generates a file named" | 320 " Instead, the compiler generates a file named" |
304 " '$precompiledName'."); | 321 " '$precompiledName'."); |
305 } | 322 } |
306 | 323 |
307 if (outputLanguage != OUTPUT_LANGUAGE_DART && stripArgumentSet) { | 324 if (outputLanguage != OUTPUT_LANGUAGE_DART && stripArgumentSet) { |
308 helpAndFail('Error: --force-strip may only be used with ' | 325 helpAndFail("Option '--force-strip' may only be used with " |
309 '--output-type=dart'); | 326 "'--output-type=dart'."); |
310 } | 327 } |
311 if (arguments.isEmpty) { | 328 if (arguments.isEmpty) { |
312 helpAndFail('Error: No Dart file specified.'); | 329 helpAndFail('No Dart file specified.'); |
313 } | 330 } |
314 if (arguments.length > 1) { | 331 if (arguments.length > 1) { |
315 var extra = arguments.sublist(1); | 332 var extra = arguments.sublist(1); |
316 helpAndFail('Error: Extra arguments: ${extra.join(" ")}'); | 333 helpAndFail('Extra arguments: ${extra.join(" ")}'); |
317 } | 334 } |
318 | 335 |
319 Uri uri = currentDirectory.resolve(arguments[0]); | 336 Uri uri = currentDirectory.resolve(arguments[0]); |
320 if (packageRoot == null) { | 337 if (packageRoot == null) { |
321 packageRoot = uri.resolve('./packages/'); | 338 packageRoot = uri.resolve('./packages/'); |
322 } | 339 } |
323 | 340 |
324 diagnosticHandler.info('package root is $packageRoot'); | 341 if ((analyzeOnly || analyzeAll) && !optionsImplyCompilation.isEmpty) { |
342 if (!analyzeOnly) { | |
343 diagnosticHandler.info( | |
344 "Option '--analyze-all' implies '--analyze-only'.", | |
345 api.Diagnostic.INFO); | |
346 } | |
347 diagnosticHandler.info( | |
348 "Options $optionsImplyCompilation indicate that output is expected, " | |
349 "but compilation is turned off by the option '--analyze-only'.", | |
350 api.Diagnostic.INFO); | |
351 } | |
352 if (analyzeAll) { | |
floitsch
2014/03/07 14:03:35
*nit*: 'if' on one line.
Johnni Winther
2014/03/10 07:03:08
Done.
| |
353 analyzeOnly = true; | |
354 } | |
355 | |
356 diagnosticHandler.info('Package root is $packageRoot'); | |
325 | 357 |
326 int totalCharactersWritten = 0; | 358 int totalCharactersWritten = 0; |
327 | 359 |
328 options.add('--source-map=$sourceMapOut'); | 360 options.add('--source-map=$sourceMapOut'); |
329 | 361 |
330 List<String> allOutputFiles = new List<String>(); | 362 List<String> allOutputFiles = new List<String>(); |
331 | 363 |
332 compilationDone(String code) { | 364 compilationDone(String code) { |
333 if (analyzeOnly) return; | 365 if (analyzeOnly) return; |
334 if (code == null) { | 366 if (code == null) { |
335 fail('Error: Compilation failed.'); | 367 fail('Compilation failed.'); |
336 } | 368 } |
337 writeString(Uri.parse('$out.deps'), | 369 writeString(Uri.parse('$out.deps'), |
338 getDepsOutput(inputProvider.sourceFiles)); | 370 getDepsOutput(inputProvider.sourceFiles)); |
339 diagnosticHandler.info( | 371 diagnosticHandler.info( |
340 'compiled ${inputProvider.dartCharactersRead} characters Dart ' | 372 'compiled ${inputProvider.dartCharactersRead} characters Dart ' |
341 '-> $totalCharactersWritten characters $outputLanguage ' | 373 '-> $totalCharactersWritten characters $outputLanguage ' |
342 'in ${relativize(currentDirectory, out, isWindows)}'); | 374 'in ${relativize(currentDirectory, out, isWindows)}'); |
343 if (diagnosticHandler.verbose) { | 375 if (diagnosticHandler.verbose) { |
344 String input = uriPathToNative(arguments[0]); | 376 String input = uriPathToNative(arguments[0]); |
345 print('Dart file ($input) compiled to $outputLanguage.'); | 377 print('Dart file ($input) compiled to $outputLanguage.'); |
(...skipping 22 matching lines...) Expand all Loading... | |
368 uri = computePrecompiledUri(); | 400 uri = computePrecompiledUri(); |
369 diagnosticHandler.info( | 401 diagnosticHandler.info( |
370 "File ($uri) is compatible with header" | 402 "File ($uri) is compatible with header" |
371 " \"Content-Security-Policy: script-src 'self'\""); | 403 " \"Content-Security-Policy: script-src 'self'\""); |
372 } else if (extension == 'js.map' || extension == 'dart.map') { | 404 } else if (extension == 'js.map' || extension == 'dart.map') { |
373 uri = sourceMapOut; | 405 uri = sourceMapOut; |
374 } else if (extension == 'info.html') { | 406 } else if (extension == 'info.html') { |
375 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); | 407 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); |
376 uri = out.resolve('${outName}.$extension'); | 408 uri = out.resolve('${outName}.$extension'); |
377 } else { | 409 } else { |
378 fail('Error: Unknown extension: $extension'); | 410 fail('Unknown extension: $extension'); |
379 } | 411 } |
380 } else { | 412 } else { |
381 uri = out.resolve('$name.$extension'); | 413 uri = out.resolve('$name.$extension'); |
382 } | 414 } |
383 | 415 |
384 if (uri.scheme != 'file') { | 416 if (uri.scheme != 'file') { |
385 fail('Error: Unhandled scheme ${uri.scheme} in $uri.'); | 417 fail('Unhandled scheme ${uri.scheme} in $uri.'); |
386 } | 418 } |
387 | 419 |
388 RandomAccessFile output; | 420 RandomAccessFile output; |
389 try { | 421 try { |
390 output = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); | 422 output = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); |
391 } on FileSystemException catch(e) { | 423 } on FileSystemException catch(e) { |
392 fail('$e'); | 424 fail('$e'); |
393 } | 425 } |
394 | 426 |
395 allOutputFiles.add(relativize(currentDirectory, uri, isWindows)); | 427 allOutputFiles.add(relativize(currentDirectory, uri, isWindows)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 } | 485 } |
454 | 486 |
455 class AbortLeg { | 487 class AbortLeg { |
456 final message; | 488 final message; |
457 AbortLeg(this.message); | 489 AbortLeg(this.message); |
458 toString() => 'Aborted due to --throw-on-error: $message'; | 490 toString() => 'Aborted due to --throw-on-error: $message'; |
459 } | 491 } |
460 | 492 |
461 void writeString(Uri uri, String text) { | 493 void writeString(Uri uri, String text) { |
462 if (uri.scheme != 'file') { | 494 if (uri.scheme != 'file') { |
463 fail('Error: Unhandled scheme ${uri.scheme}.'); | 495 fail('Unhandled scheme ${uri.scheme}.'); |
464 } | 496 } |
465 var file = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); | 497 var file = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); |
466 file.writeStringSync(text); | 498 file.writeStringSync(text); |
467 file.closeSync(); | 499 file.closeSync(); |
468 } | 500 } |
469 | 501 |
470 void fail(String message) { | 502 void fail(String message) { |
471 if (diagnosticHandler != null) { | 503 if (diagnosticHandler != null) { |
472 diagnosticHandler.diagnosticHandler( | 504 diagnosticHandler.diagnosticHandler( |
473 null, -1, -1, message, api.Diagnostic.ERROR); | 505 null, -1, -1, message, api.Diagnostic.ERROR); |
474 } else { | 506 } else { |
475 print(message); | 507 print('Error: $message'); |
476 } | 508 } |
477 exitFunc(1); | 509 exitFunc(1); |
478 } | 510 } |
479 | 511 |
480 Future compilerMain(List<String> arguments) { | 512 Future compilerMain(List<String> arguments) { |
481 var root = uriPathToNative("/$LIBRARY_ROOT"); | 513 var root = uriPathToNative("/$LIBRARY_ROOT"); |
482 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root'] | 514 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root'] |
483 ..addAll(arguments); | 515 ..addAll(arguments); |
484 return compile(arguments); | 516 return compile(arguments); |
485 } | 517 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 Define an environment variable. | 559 Define an environment variable. |
528 | 560 |
529 --version | 561 --version |
530 Display version information. | 562 Display version information. |
531 | 563 |
532 -p<path>, --package-root=<path> | 564 -p<path>, --package-root=<path> |
533 Where to find packages, that is, "package:..." imports. | 565 Where to find packages, that is, "package:..." imports. |
534 | 566 |
535 --analyze-all | 567 --analyze-all |
536 Analyze all code. Without this option, the compiler only analyzes | 568 Analyze all code. Without this option, the compiler only analyzes |
537 code that is reachable from [main]. This option is useful for | 569 code that is reachable from [main]. This option implies --analyze-only. |
538 finding errors in libraries, but using it can result in bigger and | |
539 slower output. | |
540 | 570 |
541 --analyze-only | 571 --analyze-only |
542 Analyze but do not generate code. | 572 Analyze but do not generate code. |
543 | 573 |
544 --analyze-signatures-only | 574 --analyze-signatures-only |
545 Skip analysis of method bodies and field initializers. This option implies | 575 Skip analysis of method bodies and field initializers. This option implies |
546 --analyze-only. | 576 --analyze-only. |
547 | 577 |
548 --suppress-warnings | 578 --suppress-warnings |
549 Do not display any warnings. | 579 Do not display any warnings. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 } | 672 } |
643 } | 673 } |
644 | 674 |
645 try { | 675 try { |
646 return compilerMain(arguments).catchError(onError); | 676 return compilerMain(arguments).catchError(onError); |
647 } catch (exception, trace) { | 677 } catch (exception, trace) { |
648 onError(exception, trace); | 678 onError(exception, trace); |
649 return new Future.value(); | 679 return new Future.value(); |
650 } | 680 } |
651 } | 681 } |
OLD | NEW |