Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 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. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 /// Command line entry point for Dart Development Compiler (dartdevc). | 6 /// Command line entry point for Dart Development Compiler (dartdevc). |
| 7 /// | 7 /// |
| 8 /// Supported commands are | 8 /// Supported commands are |
| 9 /// * compile: builds a collection of dart libraries into a single JS module | 9 /// * compile: builds a collection of dart libraries into a single JS module |
| 10 /// | 10 /// |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 /// that we would be compiling at all, vs running on an in-browser Dart VM), | 33 /// that we would be compiling at all, vs running on an in-browser Dart VM), |
| 34 /// * We wanted a good first impression with our simple examples, so we used | 34 /// * We wanted a good first impression with our simple examples, so we used |
| 35 /// local file servers, and users have an expectation of it now, even though | 35 /// local file servers, and users have an expectation of it now, even though |
| 36 /// it doesn't scale to typical apps that need their own real servers. | 36 /// it doesn't scale to typical apps that need their own real servers. |
| 37 | 37 |
| 38 import 'dart:io'; | 38 import 'dart:io'; |
| 39 import 'package:args/command_runner.dart'; | 39 import 'package:args/command_runner.dart'; |
| 40 import 'package:dev_compiler/src/compiler/command.dart'; | 40 import 'package:dev_compiler/src/compiler/command.dart'; |
| 41 | 41 |
| 42 main(List<String> args) async { | 42 main(List<String> args) async { |
| 43 args = _preprocessArgs(args); | |
| 44 | |
| 43 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); | 45 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); |
| 44 runner.addCommand(new CompileCommand()); | 46 runner.addCommand(new CompileCommand()); |
| 45 try { | 47 try { |
| 46 await runner.run(args); | 48 await runner.run(args); |
| 47 } on UsageException catch (e) { | 49 } on UsageException catch (e) { |
| 48 // Incorrect usage, input file not found, etc. | 50 // Incorrect usage, input file not found, etc. |
| 49 print(e); | 51 print(e); |
| 50 exit(64); | 52 exit(64); |
| 51 } on CompileErrorException catch (e) { | 53 } on CompileErrorException catch (e) { |
| 52 // Code has error(s) and failed to compile. | 54 // Code has error(s) and failed to compile. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 69 print(""); | 71 print(""); |
| 70 print(" dartdevc arguments: " + args.join(' ')); | 72 print(" dartdevc arguments: " + args.join(' ')); |
| 71 print(" dart --version: ${Platform.version}"); | 73 print(" dart --version: ${Platform.version}"); |
| 72 print(""); | 74 print(""); |
| 73 print("```"); | 75 print("```"); |
| 74 print(e); | 76 print(e); |
| 75 print(s); | 77 print(s); |
| 76 print("```"); | 78 print("```"); |
| 77 } | 79 } |
| 78 } | 80 } |
| 81 | |
| 82 /// If the final arg is `@file_path` then read in all the lines of that file | |
| 83 /// and add those as args. | |
|
Jennifer Messerly
2016/04/14 21:02:14
add a comment that this is required by Bazel worke
jakemac
2016/04/14 21:48:25
Done.
| |
| 84 List<String> _preprocessArgs(List<String> args) { | |
| 85 if (args.last.startsWith('@')) { | |
| 86 return new List.from(args) | |
| 87 ..addAll(new File(args.last.substring(1)).readAsLinesSync()); | |
| 88 } else { | |
| 89 return args; | |
| 90 } | |
| 91 } | |
| OLD | NEW |