Index: tools/testing/dart/compiler_configuration.dart |
diff --git a/tools/testing/dart/compiler_configuration.dart b/tools/testing/dart/compiler_configuration.dart |
index 49368ce1cc60234084f1e0b2310966c7de4bd1df..3613dcd166ccb71b17f48800a3be4a7566db507f 100644 |
--- a/tools/testing/dart/compiler_configuration.dart |
+++ b/tools/testing/dart/compiler_configuration.dart |
@@ -89,6 +89,17 @@ abstract class CompilerConfiguration { |
arch: configuration['arch'], |
useBlobs: useBlobs, |
isAndroid: configuration['system'] == 'android'); |
+ case 'dartk': |
+ return ComposedCompilerConfiguration.createDartKConfiguration( |
+ isHostChecked: isHostChecked, |
+ useSdk: useSdk); |
+ case 'dartkp': |
+ return ComposedCompilerConfiguration.createDartKPConfiguration( |
+ isHostChecked: isHostChecked, |
+ arch: configuration['arch'], |
+ useBlobs: useBlobs, |
+ isAndroid: configuration['system'] == 'android', |
+ useSdk: useSdk); |
case 'none': |
return new NoneCompilerConfiguration( |
isDebug: isDebug, |
@@ -199,6 +210,184 @@ class NoneCompilerConfiguration extends CompilerConfiguration { |
} |
} |
+/// The "dartk" compiler. |
+class DartKCompilerConfiguration extends CompilerConfiguration { |
+ DartKCompilerConfiguration({bool isHostChecked, bool useSdk}) |
+ : super._subclass(isHostChecked: isHostChecked, useSdk: useSdk); |
+ |
+ @override |
+ String computeCompilerPath(String buildDir) { |
+ return 'third_party/pkg/kernel/bin/dartk.dart'; |
+ } |
+ |
+ CompilationCommand computeCompilationCommand( |
+ String outputFileName, |
+ String buildDir, |
+ CommandBuilder commandBuilder, |
+ List arguments, |
+ Map<String, String> environmentOverrides) { |
+ var extraArguments = [ |
+ '--sdk', |
+ '$buildDir/obj/gen/patched_sdk', |
+ '--link', |
+ '--target=vm', |
+ '--out', |
+ outputFileName |
+ ]; |
+ return commandBuilder.getKernelCompilationCommand( |
+ 'dartk', |
+ outputFileName, |
+ true, |
+ bootstrapDependencies(buildDir), |
+ computeCompilerPath(buildDir), |
+ []..addAll(arguments)..addAll(extraArguments), |
+ environmentOverrides); |
+ } |
+ |
+ CommandArtifact computeCompilationArtifact( |
+ String buildDir, |
+ String tempDir, |
+ CommandBuilder commandBuilder, |
+ List arguments, |
+ Map<String, String> environmentOverrides) { |
+ return new CommandArtifact(<Command>[ |
+ this.computeCompilationCommand('$tempDir/out.dill', buildDir, |
+ CommandBuilder.instance, arguments, environmentOverrides) |
+ ], '$tempDir/out.dill', 'application/dart'); |
+ } |
+} |
+ |
+typedef List<String> CompilerArgumentsFunction( |
+ List<String> globalArguments, |
+ String previousCompilerOutput); |
+ |
+class PipelineCommand { |
+ final CompilerConfiguration compilerConfiguration; |
+ final CompilerArgumentsFunction _argumentsFunction; |
+ |
+ PipelineCommand._(this.compilerConfiguration, this._argumentsFunction); |
+ |
+ factory PipelineCommand.runWithGlobalArguments(CompilerConfiguration conf) { |
+ return new PipelineCommand._(conf, (List<String> globalArguments, |
+ String previousOutput) { |
+ assert(previousOutput == null); |
+ return globalArguments; |
+ }); |
+ } |
+ |
+ factory PipelineCommand.runWithDartOrKernelFile(CompilerConfiguration conf) { |
+ return new PipelineCommand._(conf, (List<String> globalArguments, |
+ String previousOutput) { |
+ var filtered = globalArguments |
+ .where((String name) => name.endsWith('.dart') || |
+ name.endsWith('.dill')) |
+ .toList(); |
+ assert(filtered.length == 1); |
+ return filtered; |
+ }); |
+ } |
+ |
+ factory PipelineCommand.runWithPreviousKernelOutput( |
+ CompilerConfiguration conf) { |
+ return new PipelineCommand._(conf, (List<String> globalArguments, |
+ String previousOutput) { |
+ assert(previousOutput.endsWith('.dill')); |
+ return [previousOutput]; |
+ }); |
+ } |
+ |
+ List<String> extractArguments(List<String> globalArguments, |
+ String previousOutput) { |
+ return _argumentsFunction(globalArguments, previousOutput); |
+ } |
+} |
+ |
+class ComposedCompilerConfiguration extends CompilerConfiguration { |
+ final List<PipelineCommand> pipelineCommands; |
+ |
+ ComposedCompilerConfiguration(this.pipelineCommands) |
+ : super._subclass(); |
+ |
+ CommandArtifact computeCompilationArtifact( |
+ String buildDir, |
+ String tempDir, |
+ CommandBuilder commandBuilder, |
+ List globalArguments, |
+ Map<String, String> environmentOverrides) { |
+ |
+ List<Command> allCommands = []; |
+ |
+ // The first compilation command is as usual. |
+ var arguments = pipelineCommands[0].extractArguments(globalArguments, null); |
+ CommandArtifact artifact = |
+ pipelineCommands[0].compilerConfiguration.computeCompilationArtifact( |
+ buildDir, tempDir, commandBuilder, arguments, environmentOverrides); |
+ allCommands.addAll(artifact.commands); |
+ |
+ // The following compilation commands are based on the output of the |
+ // previous one. |
+ for (int i = 1; i < pipelineCommands.length; i++) { |
+ PipelineCommand pc = pipelineCommands[i]; |
+ |
+ arguments = pc.extractArguments(globalArguments, artifact.filename); |
+ artifact = pc.compilerConfiguration.computeCompilationArtifact( |
+ buildDir, tempDir, commandBuilder, arguments, environmentOverrides); |
+ |
+ allCommands.addAll(artifact.commands); |
+ } |
+ |
+ return new CommandArtifact( |
+ allCommands, artifact.filename, artifact.mimeType); |
+ } |
+ |
+ List<String> computeCompilerArguments(vmOptions, sharedOptions, args) { |
+ // The result will be passed as an input to [extractArguments] |
+ // (i.e. the arguments to the [PipelineCommand]). |
+ return new List<String>.from(sharedOptions)..addAll(args); |
+ } |
+ |
+ List<String> computeRuntimeArguments( |
+ RuntimeConfiguration runtimeConfiguration, |
+ String buildDir, |
+ TestInformation info, |
+ List<String> vmOptions, |
+ List<String> sharedOptions, |
+ List<String> originalArguments, |
+ CommandArtifact artifact) { |
+ return <String>[artifact.filename]; |
+ } |
+ |
+ static ComposedCompilerConfiguration createDartKPConfiguration( |
+ {bool isHostChecked, String arch, bool useBlobs, bool isAndroid, |
+ bool useSdk}) { |
+ var nested = []; |
+ |
+ // Compile with dartk. |
+ nested.add(new PipelineCommand.runWithGlobalArguments( |
+ new DartKCompilerConfiguration(isHostChecked: isHostChecked, |
+ useSdk: useSdk))); |
+ |
+ // Run the normal precompiler. |
+ nested.add(new PipelineCommand.runWithPreviousKernelOutput( |
+ new PrecompilerCompilerConfiguration( |
+ arch: arch, useBlobs: useBlobs, isAndroid: isAndroid))); |
+ |
+ return new ComposedCompilerConfiguration(nested); |
+ } |
+ |
+ static ComposedCompilerConfiguration createDartKConfiguration( |
+ {bool isHostChecked, bool useSdk}) { |
+ var nested = []; |
+ |
+ // Compile with dartk. |
+ nested.add(new PipelineCommand.runWithGlobalArguments( |
+ new DartKCompilerConfiguration(isHostChecked: isHostChecked, |
+ useSdk: useSdk))); |
+ |
+ return new ComposedCompilerConfiguration(nested); |
+ } |
+} |
+ |
/// Common configuration for dart2js-based tools, such as, dart2js |
class Dart2xCompilerConfiguration extends CompilerConfiguration { |
final String moniker; |