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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/command.dart

Issue 2955513002: Dynamically load packages for dartdevc tests in test.dart. (Closed)
Patch Set: Remove TODO that's TODONE. Created 3 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 unified diff | Download patch
OLDNEW
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/command_line/arguments.dart' 6 import 'package:analyzer/src/command_line/arguments.dart'
7 show 7 show
8 defineAnalysisArguments, 8 defineAnalysisArguments,
9 filterUnknownArguments, 9 filterUnknownArguments,
10 ignoreUnrecognizedFlagsFlag; 10 ignoreUnrecognizedFlagsFlag;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 _usageException('Output file $firstOutPath must be within the module ' 173 _usageException('Output file $firstOutPath must be within the module '
174 'root directory $moduleRoot'); 174 'root directory $moduleRoot');
175 } 175 }
176 modulePath = 176 modulePath =
177 path.withoutExtension(path.relative(firstOutPath, from: moduleRoot)); 177 path.withoutExtension(path.relative(firstOutPath, from: moduleRoot));
178 } else { 178 } else {
179 moduleRoot = path.dirname(firstOutPath); 179 moduleRoot = path.dirname(firstOutPath);
180 modulePath = path.basenameWithoutExtension(firstOutPath); 180 modulePath = path.basenameWithoutExtension(firstOutPath);
181 } 181 }
182 182
183 var unit = new BuildUnit(modulePath, libraryRoot, argResults.rest, 183 var unit = new BuildUnit(
184 (source) => _moduleForLibrary(moduleRoot, source, compilerOpts)); 184 modulePath,
185 libraryRoot,
186 argResults.rest,
187 (source) =>
188 _moduleForLibrary(moduleRoot, source, analyzerOptions, compilerOpts));
185 189
186 var module = compiler.compile(unit, compilerOpts); 190 var module = compiler.compile(unit, compilerOpts);
187 module.errors.forEach(printFn); 191 module.errors.forEach(printFn);
188 192
189 if (!module.isValid) { 193 if (!module.isValid) {
190 throw compilerOpts.unsafeForceCompile 194 throw compilerOpts.unsafeForceCompile
191 ? new ForceCompileErrorException() 195 ? new ForceCompileErrorException()
192 : new CompileErrorException(); 196 : new CompileErrorException();
193 } 197 }
194 198
(...skipping 15 matching lines...) Expand all
210 var file = new File(summaryPath); 214 var file = new File(summaryPath);
211 if (!file.existsSync() || 215 if (!file.existsSync() ||
212 _changed(file.readAsBytesSync(), module.summaryBytes)) { 216 _changed(file.readAsBytesSync(), module.summaryBytes)) {
213 if (!file.parent.existsSync()) file.parent.createSync(recursive: true); 217 if (!file.parent.existsSync()) file.parent.createSync(recursive: true);
214 file.writeAsBytesSync(module.summaryBytes); 218 file.writeAsBytesSync(module.summaryBytes);
215 } 219 }
216 } 220 }
217 } 221 }
218 } 222 }
219 223
220 String _moduleForLibrary( 224 String _moduleForLibrary(String moduleRoot, Source source,
221 String moduleRoot, Source source, CompilerOptions compilerOpts) { 225 AnalyzerOptions analyzerOptions, CompilerOptions compilerOpts) {
222 if (source is InSummarySource) { 226 if (source is InSummarySource) {
223 var summaryPath = source.summaryPath; 227 var summaryPath = source.summaryPath;
228
229 if (analyzerOptions.customSummaryModules.containsKey(summaryPath)) {
230 return analyzerOptions.customSummaryModules[summaryPath];
231 }
232
224 var ext = '.${compilerOpts.summaryExtension}'; 233 var ext = '.${compilerOpts.summaryExtension}';
225 if (path.isWithin(moduleRoot, summaryPath) && summaryPath.endsWith(ext)) { 234 if (path.isWithin(moduleRoot, summaryPath) && summaryPath.endsWith(ext)) {
226 var buildUnitPath = 235 var buildUnitPath =
227 summaryPath.substring(0, summaryPath.length - ext.length); 236 summaryPath.substring(0, summaryPath.length - ext.length);
228 return path.url 237 return path.url
229 .joinAll(path.split(path.relative(buildUnitPath, from: moduleRoot))); 238 .joinAll(path.split(path.relative(buildUnitPath, from: moduleRoot)));
230 } 239 }
231 240
232 _usageException('Imported file ${source.uri} is not within the module root ' 241 _usageException('Imported file ${source.uri} is not within the module root '
233 'directory $moduleRoot'); 242 'directory $moduleRoot');
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 /// Thrown when the input source code has errors. 274 /// Thrown when the input source code has errors.
266 class CompileErrorException implements Exception { 275 class CompileErrorException implements Exception {
267 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; 276 toString() => '\nPlease fix all errors before compiling (warnings are okay).';
268 } 277 }
269 278
270 /// Thrown when force compilation failed (probably due to static errors). 279 /// Thrown when force compilation failed (probably due to static errors).
271 class ForceCompileErrorException extends CompileErrorException { 280 class ForceCompileErrorException extends CompileErrorException {
272 toString() => 281 toString() =>
273 '\nForce-compilation not successful. Please check static errors.'; 282 '\nForce-compilation not successful. Please check static errors.';
274 } 283 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/analyzer/context.dart ('k') | pkg/dev_compiler/lib/src/compiler/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698