Chromium Code Reviews| Index: lib/src/compiler/command.dart |
| diff --git a/lib/src/compiler/command.dart b/lib/src/compiler/command.dart |
| index d9c96a329eaf65774efbfb5bec844068054eee97..e3aa12db0372a718958277ca0ba5254579519560 100644 |
| --- a/lib/src/compiler/command.dart |
| +++ b/lib/src/compiler/command.dart |
| @@ -17,9 +17,8 @@ typedef void MessageHandler(Object message); |
| /// The command for invoking the modular compiler. |
| class CompileCommand extends Command { |
| - get name => 'compile'; |
| - get description => 'Compile a set of Dart files into a JavaScript module.'; |
| final MessageHandler messageHandler; |
| + CompilerOptions _compilerOptions; |
| CompileCommand({MessageHandler messageHandler}) |
| : this.messageHandler = messageHandler ?? print { |
| @@ -34,11 +33,14 @@ class CompileCommand extends Command { |
| AnalyzerOptions.addArguments(argParser); |
| } |
| + get name => 'compile'; |
| + get description => 'Compile a set of Dart files into a JavaScript module.'; |
| + |
| @override |
| void run() { |
| var compiler = |
| new ModuleCompiler(new AnalyzerOptions.fromArguments(argResults)); |
| - var compilerOptions = new CompilerOptions.fromArguments(argResults); |
| + _compilerOptions = new CompilerOptions.fromArguments(argResults); |
| var outPath = argResults['out']; |
| if (outPath == null) { |
| @@ -74,7 +76,7 @@ class CompileCommand extends Command { |
| var unit = new BuildUnit(modulePath, buildRoot, argResults.rest, |
| (source) => _moduleForLibrary(moduleRoot, source)); |
| - JSModuleFile module = compiler.compile(unit, compilerOptions); |
| + JSModuleFile module = compiler.compile(unit, _compilerOptions); |
| module.errors.forEach(messageHandler); |
| if (!module.isValid) throw new CompileErrorException(); |
| @@ -87,7 +89,8 @@ class CompileCommand extends Command { |
| .writeAsStringSync(JSON.encode(module.placeSourceMap(mapPath))); |
| } |
| if (module.summaryBytes != null) { |
| - var summaryPath = path.withoutExtension(outPath) + '.sum'; |
| + var summaryPath = path.withoutExtension(outPath) + |
| + '.${_compilerOptions.summaryExtension}'; |
| new File(summaryPath).writeAsBytesSync(module.summaryBytes); |
| } |
| } |
| @@ -95,9 +98,10 @@ class CompileCommand extends Command { |
| String _moduleForLibrary(String moduleRoot, Source source) { |
| if (source is InSummarySource) { |
| var summaryPath = source.summaryPath; |
| - if (path.isWithin(moduleRoot, summaryPath)) { |
| - return path |
| - .withoutExtension(path.relative(summaryPath, from: moduleRoot)); |
| + var ext = '.${_compilerOptions.summaryExtension}'; |
| + if (path.isWithin(moduleRoot, summaryPath) && summaryPath.endsWith(ext)) { |
| + summaryPath = summaryPath.substring(0, summaryPath.length - ext.length); |
|
Paul Berry
2016/07/22 18:27:55
A bit confusing, since this is no longer the summa
Jennifer Messerly
2016/07/22 18:39:45
Great suggestion! Done.
|
| + return path.relative(summaryPath, from: moduleRoot); |
| } |
| throw usageException( |