Index: pkg/dev_compiler/lib/src/compiler/command.dart |
diff --git a/pkg/dev_compiler/lib/src/compiler/command.dart b/pkg/dev_compiler/lib/src/compiler/command.dart |
index eff733c6e4a3ad82ac940353793313066c846110..352fb0880cba81d2d66bcd34e00437cfc7008a02 100644 |
--- a/pkg/dev_compiler/lib/src/compiler/command.dart |
+++ b/pkg/dev_compiler/lib/src/compiler/command.dart |
@@ -81,6 +81,15 @@ $stackTrace |
} |
} |
+bool _changed(List<int> list1, List<int> list2) { |
+ var length = list1.length; |
+ if (length != list2.length) return true; |
+ for (var i = 0; i < length; ++i) { |
+ if (list1[i] != list2[i]) return true; |
+ } |
+ return false; |
+} |
+ |
void _compile(ArgResults argResults, void printFn(Object obj)) { |
var compiler = |
new ModuleCompiler(new AnalyzerOptions.fromArguments(argResults)); |
@@ -150,7 +159,13 @@ void _compile(ArgResults argResults, void printFn(Object obj)) { |
if (module.summaryBytes != null) { |
var summaryPath = |
path.withoutExtension(outPath) + '.${compilerOpts.summaryExtension}'; |
- new File(summaryPath).writeAsBytesSync(module.summaryBytes); |
+ // Only overwrite if summary changed. This plays better with timestamp |
+ // based build systems. |
+ var file = new File(summaryPath); |
+ if (!file.existsSync() || |
+ _changed(file.readAsBytesSync(), module.summaryBytes)) { |
+ file.writeAsBytesSync(module.summaryBytes); |
+ } |
} |
} |
} |