Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: lib/src/compiler/command.dart

Issue 2176763002: fix #606, allow specifying the summary file extension (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/src/compiler/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/command.dart
diff --git a/lib/src/compiler/command.dart b/lib/src/compiler/command.dart
index d9c96a329eaf65774efbfb5bec844068054eee97..cd498b7f31761a74beba96858697111a1c4c2e16 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,11 @@ 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)) {
+ var buildUnitPath =
+ summaryPath.substring(0, summaryPath.length - ext.length);
+ return path.relative(buildUnitPath, from: moduleRoot);
}
throw usageException(
« no previous file with comments | « no previous file | lib/src/compiler/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698