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

Side by Side Diff: tools/testing/dart/compiler_configuration.dart

Issue 2451623006: Reland "Merge more Kernel infrastructure from kernel_sdk SDK fork." (Closed)
Patch Set: Fix Created 4 years, 1 month 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
« no previous file with comments | « tools/testing/dart/co19_test_config.dart ('k') | tools/testing/dart/test_configurations.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library compiler_configuration; 5 library compiler_configuration;
6 6
7 import 'dart:io' show Platform; 7 import 'dart:io' show Platform;
8 8
9 import 'runtime_configuration.dart' show RuntimeConfiguration; 9 import 'runtime_configuration.dart' show RuntimeConfiguration;
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 case 'dart2app': 82 case 'dart2app':
83 return new Dart2AppSnapshotCompilerConfiguration( 83 return new Dart2AppSnapshotCompilerConfiguration(
84 isDebug: isDebug, isChecked: isChecked, useBlobs: useBlobs); 84 isDebug: isDebug, isChecked: isChecked, useBlobs: useBlobs);
85 case 'precompiler': 85 case 'precompiler':
86 return new PrecompilerCompilerConfiguration( 86 return new PrecompilerCompilerConfiguration(
87 isDebug: isDebug, 87 isDebug: isDebug,
88 isChecked: isChecked, 88 isChecked: isChecked,
89 arch: configuration['arch'], 89 arch: configuration['arch'],
90 useBlobs: useBlobs, 90 useBlobs: useBlobs,
91 isAndroid: configuration['system'] == 'android'); 91 isAndroid: configuration['system'] == 'android');
92 case 'dartk':
93 return ComposedCompilerConfiguration.createDartKConfiguration(
94 isHostChecked: isHostChecked,
95 useSdk: useSdk);
96 case 'dartkp':
97 return ComposedCompilerConfiguration.createDartKPConfiguration(
98 isHostChecked: isHostChecked,
99 arch: configuration['arch'],
100 useBlobs: useBlobs,
101 isAndroid: configuration['system'] == 'android',
102 useSdk: useSdk);
92 case 'none': 103 case 'none':
93 return new NoneCompilerConfiguration( 104 return new NoneCompilerConfiguration(
94 isDebug: isDebug, 105 isDebug: isDebug,
95 isChecked: isChecked, 106 isChecked: isChecked,
96 isHostChecked: isHostChecked, 107 isHostChecked: isHostChecked,
97 useSdk: useSdk, 108 useSdk: useSdk,
98 hotReload: hotReload, 109 hotReload: hotReload,
99 hotReloadRollback: hotReloadRollback); 110 hotReloadRollback: hotReloadRollback);
100 default: 111 default:
101 throw "Unknown compiler '$compiler'"; 112 throw "Unknown compiler '$compiler'";
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } else if (hotReloadRollback) { 203 } else if (hotReloadRollback) {
193 args.add('--hot-reload-rollback-test-mode'); 204 args.add('--hot-reload-rollback-test-mode');
194 } 205 }
195 return args 206 return args
196 ..addAll(vmOptions) 207 ..addAll(vmOptions)
197 ..addAll(sharedOptions) 208 ..addAll(sharedOptions)
198 ..addAll(originalArguments); 209 ..addAll(originalArguments);
199 } 210 }
200 } 211 }
201 212
213 /// The "dartk" compiler.
214 class DartKCompilerConfiguration extends CompilerConfiguration {
215 DartKCompilerConfiguration({bool isHostChecked, bool useSdk})
216 : super._subclass(isHostChecked: isHostChecked, useSdk: useSdk);
217
218 @override
219 String computeCompilerPath(String buildDir) {
220 return 'third_party/pkg/kernel/bin/dartk.dart';
221 }
222
223 CompilationCommand computeCompilationCommand(
224 String outputFileName,
225 String buildDir,
226 CommandBuilder commandBuilder,
227 List arguments,
228 Map<String, String> environmentOverrides) {
229 var extraArguments = [
230 '--sdk',
231 '$buildDir/obj/gen/patched_sdk',
232 '--link',
233 '--target=vm',
234 '--out',
235 outputFileName
236 ];
237 return commandBuilder.getKernelCompilationCommand(
238 'dartk',
239 outputFileName,
240 true,
241 bootstrapDependencies(buildDir),
242 computeCompilerPath(buildDir),
243 []..addAll(arguments)..addAll(extraArguments),
244 environmentOverrides);
245 }
246
247 CommandArtifact computeCompilationArtifact(
248 String buildDir,
249 String tempDir,
250 CommandBuilder commandBuilder,
251 List arguments,
252 Map<String, String> environmentOverrides) {
253 return new CommandArtifact(<Command>[
254 this.computeCompilationCommand('$tempDir/out.dill', buildDir,
255 CommandBuilder.instance, arguments, environmentOverrides)
256 ], '$tempDir/out.dill', 'application/dart');
257 }
258 }
259
260 typedef List<String> CompilerArgumentsFunction(
261 List<String> globalArguments,
262 String previousCompilerOutput);
263
264 class PipelineCommand {
265 final CompilerConfiguration compilerConfiguration;
266 final CompilerArgumentsFunction _argumentsFunction;
267
268 PipelineCommand._(this.compilerConfiguration, this._argumentsFunction);
269
270 factory PipelineCommand.runWithGlobalArguments(CompilerConfiguration conf) {
271 return new PipelineCommand._(conf, (List<String> globalArguments,
272 String previousOutput) {
273 assert(previousOutput == null);
274 return globalArguments;
275 });
276 }
277
278 factory PipelineCommand.runWithDartOrKernelFile(CompilerConfiguration conf) {
279 return new PipelineCommand._(conf, (List<String> globalArguments,
280 String previousOutput) {
281 var filtered = globalArguments
282 .where((String name) => name.endsWith('.dart') ||
283 name.endsWith('.dill'))
284 .toList();
285 assert(filtered.length == 1);
286 return filtered;
287 });
288 }
289
290 factory PipelineCommand.runWithPreviousKernelOutput(
291 CompilerConfiguration conf) {
292 return new PipelineCommand._(conf, (List<String> globalArguments,
293 String previousOutput) {
294 assert(previousOutput.endsWith('.dill'));
295 return [previousOutput];
296 });
297 }
298
299 List<String> extractArguments(List<String> globalArguments,
300 String previousOutput) {
301 return _argumentsFunction(globalArguments, previousOutput);
302 }
303 }
304
305 class ComposedCompilerConfiguration extends CompilerConfiguration {
306 final List<PipelineCommand> pipelineCommands;
307
308 ComposedCompilerConfiguration(this.pipelineCommands)
309 : super._subclass();
310
311 CommandArtifact computeCompilationArtifact(
312 String buildDir,
313 String tempDir,
314 CommandBuilder commandBuilder,
315 List globalArguments,
316 Map<String, String> environmentOverrides) {
317
318 List<Command> allCommands = [];
319
320 // The first compilation command is as usual.
321 var arguments = pipelineCommands[0].extractArguments(globalArguments, null);
322 CommandArtifact artifact =
323 pipelineCommands[0].compilerConfiguration.computeCompilationArtifact(
324 buildDir, tempDir, commandBuilder, arguments, environmentOverrides);
325 allCommands.addAll(artifact.commands);
326
327 // The following compilation commands are based on the output of the
328 // previous one.
329 for (int i = 1; i < pipelineCommands.length; i++) {
330 PipelineCommand pc = pipelineCommands[i];
331
332 arguments = pc.extractArguments(globalArguments, artifact.filename);
333 artifact = pc.compilerConfiguration.computeCompilationArtifact(
334 buildDir, tempDir, commandBuilder, arguments, environmentOverrides);
335
336 allCommands.addAll(artifact.commands);
337 }
338
339 return new CommandArtifact(
340 allCommands, artifact.filename, artifact.mimeType);
341 }
342
343 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) {
344 // The result will be passed as an input to [extractArguments]
345 // (i.e. the arguments to the [PipelineCommand]).
346 return new List<String>.from(sharedOptions)..addAll(args);
347 }
348
349 List<String> computeRuntimeArguments(
350 RuntimeConfiguration runtimeConfiguration,
351 String buildDir,
352 TestInformation info,
353 List<String> vmOptions,
354 List<String> sharedOptions,
355 List<String> originalArguments,
356 CommandArtifact artifact) {
357 return <String>[artifact.filename];
358 }
359
360 static ComposedCompilerConfiguration createDartKPConfiguration(
361 {bool isHostChecked, String arch, bool useBlobs, bool isAndroid,
362 bool useSdk}) {
363 var nested = [];
364
365 // Compile with dartk.
366 nested.add(new PipelineCommand.runWithGlobalArguments(
367 new DartKCompilerConfiguration(isHostChecked: isHostChecked,
368 useSdk: useSdk)));
369
370 // Run the normal precompiler.
371 nested.add(new PipelineCommand.runWithPreviousKernelOutput(
372 new PrecompilerCompilerConfiguration(
373 arch: arch, useBlobs: useBlobs, isAndroid: isAndroid)));
374
375 return new ComposedCompilerConfiguration(nested);
376 }
377
378 static ComposedCompilerConfiguration createDartKConfiguration(
379 {bool isHostChecked, bool useSdk}) {
380 var nested = [];
381
382 // Compile with dartk.
383 nested.add(new PipelineCommand.runWithGlobalArguments(
384 new DartKCompilerConfiguration(isHostChecked: isHostChecked,
385 useSdk: useSdk)));
386
387 return new ComposedCompilerConfiguration(nested);
388 }
389 }
390
202 /// Common configuration for dart2js-based tools, such as, dart2js 391 /// Common configuration for dart2js-based tools, such as, dart2js
203 class Dart2xCompilerConfiguration extends CompilerConfiguration { 392 class Dart2xCompilerConfiguration extends CompilerConfiguration {
204 final String moniker; 393 final String moniker;
205 static Map<String, List<Uri>> _bootstrapDependenciesCache = 394 static Map<String, List<Uri>> _bootstrapDependenciesCache =
206 new Map<String, List<Uri>>(); 395 new Map<String, List<Uri>>();
207 396
208 Dart2xCompilerConfiguration(this.moniker, 397 Dart2xCompilerConfiguration(this.moniker,
209 {bool isDebug, bool isChecked, bool isHostChecked, bool useSdk}) 398 {bool isDebug, bool isChecked, bool isHostChecked, bool useSdk})
210 : super._subclass( 399 : super._subclass(
211 isDebug: isDebug, 400 isDebug: isDebug,
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 RuntimeConfiguration runtimeConfiguration, 828 RuntimeConfiguration runtimeConfiguration,
640 String buildDir, 829 String buildDir,
641 TestInformation info, 830 TestInformation info,
642 List<String> vmOptions, 831 List<String> vmOptions,
643 List<String> sharedOptions, 832 List<String> sharedOptions,
644 List<String> originalArguments, 833 List<String> originalArguments,
645 CommandArtifact artifact) { 834 CommandArtifact artifact) {
646 return <String>[]; 835 return <String>[];
647 } 836 }
648 } 837 }
OLDNEW
« no previous file with comments | « tools/testing/dart/co19_test_config.dart ('k') | tools/testing/dart/test_configurations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698