OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:io'; | 5 import 'dart:io'; |
6 import 'package:analyzer/src/generated/source.dart' show Source; | 6 import 'package:analyzer/src/generated/source.dart' show Source; |
7 import 'package:analyzer/src/summary/package_bundle_reader.dart' | 7 import 'package:analyzer/src/summary/package_bundle_reader.dart' |
8 show InSummarySource; | 8 show InSummarySource; |
9 import 'package:args/args.dart' show ArgParser, ArgResults; | 9 import 'package:args/args.dart' show ArgParser, ArgResults; |
10 import 'package:args/command_runner.dart' show UsageException; | 10 import 'package:args/command_runner.dart' show UsageException; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 : outPaths.map((p) => | 163 : outPaths.map((p) => |
164 '${path.withoutExtension(p)}.${compilerOpts.summaryExtension}'); | 164 '${path.withoutExtension(p)}.${compilerOpts.summaryExtension}'); |
165 | 165 |
166 // place next to every compiled module | 166 // place next to every compiled module |
167 for (var summaryPath in summaryPaths) { | 167 for (var summaryPath in summaryPaths) { |
168 // Only overwrite if summary changed. This plays better with timestamp | 168 // Only overwrite if summary changed. This plays better with timestamp |
169 // based build systems. | 169 // based build systems. |
170 var file = new File(summaryPath); | 170 var file = new File(summaryPath); |
171 if (!file.existsSync() || | 171 if (!file.existsSync() || |
172 _changed(file.readAsBytesSync(), module.summaryBytes)) { | 172 _changed(file.readAsBytesSync(), module.summaryBytes)) { |
| 173 if (!file.parent.existsSync()) file.parent.createSync(recursive: true); |
173 file.writeAsBytesSync(module.summaryBytes); | 174 file.writeAsBytesSync(module.summaryBytes); |
174 } | 175 } |
175 } | 176 } |
176 } | 177 } |
177 } | 178 } |
178 | 179 |
179 String _moduleForLibrary( | 180 String _moduleForLibrary( |
180 String moduleRoot, Source source, CompilerOptions compilerOpts) { | 181 String moduleRoot, Source source, CompilerOptions compilerOpts) { |
181 if (source is InSummarySource) { | 182 if (source is InSummarySource) { |
182 var summaryPath = source.summaryPath; | 183 var summaryPath = source.summaryPath; |
(...skipping 20 matching lines...) Expand all Loading... |
203 '\n\n${_argParser.usage}'; | 204 '\n\n${_argParser.usage}'; |
204 | 205 |
205 void _usageException(String message) { | 206 void _usageException(String message) { |
206 throw new UsageException(message, _usageMessage); | 207 throw new UsageException(message, _usageMessage); |
207 } | 208 } |
208 | 209 |
209 /// Thrown when the input source code has errors. | 210 /// Thrown when the input source code has errors. |
210 class CompileErrorException implements Exception { | 211 class CompileErrorException implements Exception { |
211 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; | 212 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; |
212 } | 213 } |
OLD | NEW |