Chromium Code Reviews| Index: lib/src/options.dart |
| diff --git a/lib/src/options.dart b/lib/src/options.dart |
| index 3fa1334431d8c67b0b344c02ed77b13647447861..5245cc7cf3a8c6edd5bbdf870defe59213ca5f18 100644 |
| --- a/lib/src/options.dart |
| +++ b/lib/src/options.dart |
| @@ -145,6 +145,10 @@ class CompilerOptions { |
| /// to this directory. |
| final String inputBaseDir; |
| + /// True to save compiler messages to a file. |
| + /// Useful for incremental compilation and tests. |
| + final bool saveMessages; |
| + |
| CompilerOptions( |
| {this.strongOptions: const StrongModeOptions(), |
| this.sourceOptions: const SourceResolverOptions(), |
| @@ -162,8 +166,9 @@ class CompilerOptions { |
| this.host: 'localhost', |
| this.port: 8080, |
| this.runtimeDir, |
| - this.inputs, |
| - this.inputBaseDir}); |
| + this.inputs: const [], |
| + this.inputBaseDir, |
| + this.saveMessages: false}); |
| } |
| /// Parses options from the command-line |
| @@ -191,7 +196,7 @@ CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) { |
| } |
| var runtimeDir = args['runtime-dir']; |
| if (runtimeDir == null) { |
| - runtimeDir = _computeRuntimeDir(); |
| + runtimeDir = _computedRuntimeDir; |
| } |
| var outputDir = args['out']; |
| if (outputDir == null && (serverMode || forceOutDir)) { |
| @@ -248,6 +253,7 @@ CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) { |
| host: args['host'], |
| port: int.parse(args['port']), |
| runtimeDir: runtimeDir, |
| + saveMessages: args['save-messages'], |
| inputs: args.rest); |
| } |
| @@ -315,12 +321,16 @@ final ArgParser argParser = StrongModeOptions.addArguments(new ArgParser() |
| ..addOption('dump-info-file', |
| abbr: 'f', |
| help: 'Dump info json file (requires dump-info)', |
| - defaultsTo: null)); |
| + defaultsTo: null) |
| + ..addFlag('save-messages', help: 'Save compiler messages to a text file')); |
| /// Tries to find the `lib/runtime/` directory of the dev_compiler package. This |
| /// works when running devc from it's sources or from a snapshot that is |
| /// activated via `pub global activate`. |
| -String _computeRuntimeDir() { |
| +final String _computedRuntimeDir = () { |
| + // TODO(jmesserly): if we're in the test runner we can't get our runtime path. |
| + if (Platform.script.scheme == 'data') return null; |
| + |
| var scriptPath = path.fromUri(Platform.script); |
| var file = path.basename(scriptPath); |
| var dir = path.dirname(scriptPath); |
| @@ -367,4 +377,20 @@ String _computeRuntimeDir() { |
| return path.join(dir, cacheDir, 'lib', 'runtime'); |
| } |
| return null; |
| -} |
| +}(); |
| + |
| +/// The timestamp of the compiler itself. Used to invalidate output if the |
| +/// compiler itself changes. |
|
Leaf
2015/09/04 21:46:31
At some point, we should probably include a versio
|
| +final DateTime compilerLastModified = () { |
| + if (_computedRuntimeDir == null) return null; |
| + |
| + DateTime lastModify = null; |
| + var compilerLib = new Directory(path.join(_computedRuntimeDir, '..')); |
| + for (var file in compilerLib.listSync(recursive: true)) { |
| + if (file is File && file.path.endsWith('.dart')) { |
| + var modify = file.lastModifiedSync(); |
| + if (lastModify == null || modify.isAfter(lastModify)) lastModify = modify; |
| + } |
| + } |
| + return lastModify; |
| +}(); |