OLD | NEW |
---|---|
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 isDebug: isDebug, isChecked: isChecked); | 84 isDebug: isDebug, isChecked: isChecked); |
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': | 92 case 'dartk': |
93 return ComposedCompilerConfiguration.createDartKConfiguration( | 93 return ComposedCompilerConfiguration.createDartKConfiguration( |
94 isChecked: isChecked, | |
94 isHostChecked: isHostChecked, | 95 isHostChecked: isHostChecked, |
95 useSdk: useSdk, | 96 useSdk: useSdk, |
96 verify: verifyKernel, | 97 verify: verifyKernel, |
97 strong: isStrong); | 98 strong: isStrong); |
98 case 'dartkp': | 99 case 'dartkp': |
99 return ComposedCompilerConfiguration.createDartKPConfiguration( | 100 return ComposedCompilerConfiguration.createDartKPConfiguration( |
101 isChecked: isChecked, | |
100 isHostChecked: isHostChecked, | 102 isHostChecked: isHostChecked, |
101 arch: configuration['arch'], | 103 arch: configuration['arch'], |
102 useBlobs: useBlobs, | 104 useBlobs: useBlobs, |
103 isAndroid: configuration['system'] == 'android', | 105 isAndroid: configuration['system'] == 'android', |
104 useSdk: useSdk, | 106 useSdk: useSdk, |
105 verify: verifyKernel, | 107 verify: verifyKernel, |
106 strong: isStrong); | 108 strong: isStrong); |
107 case 'none': | 109 case 'none': |
108 return new NoneCompilerConfiguration( | 110 return new NoneCompilerConfiguration( |
109 isDebug: isDebug, | 111 isDebug: isDebug, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 ..addAll(vmOptions) | 213 ..addAll(vmOptions) |
212 ..addAll(sharedOptions) | 214 ..addAll(sharedOptions) |
213 ..addAll(originalArguments); | 215 ..addAll(originalArguments); |
214 } | 216 } |
215 } | 217 } |
216 | 218 |
217 /// The "dartk" compiler. | 219 /// The "dartk" compiler. |
218 class DartKCompilerConfiguration extends CompilerConfiguration { | 220 class DartKCompilerConfiguration extends CompilerConfiguration { |
219 final bool verify, strong; | 221 final bool verify, strong; |
220 | 222 |
221 DartKCompilerConfiguration({bool isHostChecked, bool useSdk, this.verify, | 223 DartKCompilerConfiguration({bool isChecked, bool isHostChecked, bool useSdk, |
222 this.strong}) | 224 this.verify, this.strong}) |
223 : super._subclass(isHostChecked: isHostChecked, useSdk: useSdk); | 225 : super._subclass(isChecked: isChecked, isHostChecked: isHostChecked, |
226 useSdk: useSdk); | |
224 | 227 |
225 @override | 228 @override |
226 String computeCompilerPath(String buildDir) { | 229 String computeCompilerPath(String buildDir) { |
227 return 'tools/dartk_wrappers/dartk$executableScriptSuffix'; | 230 return 'tools/dartk_wrappers/dartk$executableScriptSuffix'; |
228 } | 231 } |
229 | 232 |
230 CompilationCommand computeCompilationCommand( | 233 CompilationCommand computeCompilationCommand( |
231 String outputFileName, | 234 String outputFileName, |
232 String buildDir, | 235 String buildDir, |
233 CommandBuilder commandBuilder, | 236 CommandBuilder commandBuilder, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 309 } |
307 | 310 |
308 List<String> extractArguments(List<String> globalArguments, | 311 List<String> extractArguments(List<String> globalArguments, |
309 String previousOutput) { | 312 String previousOutput) { |
310 return _argumentsFunction(globalArguments, previousOutput); | 313 return _argumentsFunction(globalArguments, previousOutput); |
311 } | 314 } |
312 } | 315 } |
313 | 316 |
314 class ComposedCompilerConfiguration extends CompilerConfiguration { | 317 class ComposedCompilerConfiguration extends CompilerConfiguration { |
315 final List<PipelineCommand> pipelineCommands; | 318 final List<PipelineCommand> pipelineCommands; |
316 final bool isPrecompiler; | |
317 | 319 |
318 ComposedCompilerConfiguration(this.pipelineCommands, {this.isPrecompiler: fals e}) | 320 ComposedCompilerConfiguration(this.pipelineCommands) : super._subclass(); |
319 : super._subclass(); | |
320 | 321 |
321 CommandArtifact computeCompilationArtifact( | 322 CommandArtifact computeCompilationArtifact( |
322 String buildDir, | 323 String buildDir, |
323 String tempDir, | 324 String tempDir, |
324 CommandBuilder commandBuilder, | 325 CommandBuilder commandBuilder, |
325 List globalArguments, | 326 List globalArguments, |
326 Map<String, String> environmentOverrides) { | 327 Map<String, String> environmentOverrides) { |
327 | 328 |
328 List<Command> allCommands = []; | 329 List<Command> allCommands = []; |
329 | 330 |
(...skipping 27 matching lines...) Expand all Loading... | |
357 } | 358 } |
358 | 359 |
359 List<String> computeRuntimeArguments( | 360 List<String> computeRuntimeArguments( |
360 RuntimeConfiguration runtimeConfiguration, | 361 RuntimeConfiguration runtimeConfiguration, |
361 String buildDir, | 362 String buildDir, |
362 TestInformation info, | 363 TestInformation info, |
363 List<String> vmOptions, | 364 List<String> vmOptions, |
364 List<String> sharedOptions, | 365 List<String> sharedOptions, |
365 List<String> originalArguments, | 366 List<String> originalArguments, |
366 CommandArtifact artifact) { | 367 CommandArtifact artifact) { |
367 final String suffix = isPrecompiler ? "/out.aotsnapshot" : ""; | 368 CompilerConfiguration lastCompilerConfiguration = |
368 return <String>["${artifact.filename}${suffix}"]; | 369 pipelineCommands.last.compilerConfiguration; |
370 return lastCompilerConfiguration.computeRuntimeArguments( | |
371 runtimeConfiguration, buildDir, info, vmOptions, sharedOptions, | |
372 originalArguments, artifact); | |
369 } | 373 } |
370 | 374 |
371 static ComposedCompilerConfiguration createDartKPConfiguration( | 375 static ComposedCompilerConfiguration createDartKPConfiguration( |
372 {bool isHostChecked, String arch, bool useBlobs, bool isAndroid, | 376 {bool isChecked, bool isHostChecked, String arch, bool useBlobs, |
373 bool useSdk, bool verify, bool strong}) { | 377 bool isAndroid, bool useSdk, bool verify, bool strong}) { |
374 var nested = []; | 378 var nested = []; |
375 | 379 |
376 // Compile with dartk. | 380 // Compile with dartk. |
377 nested.add(new PipelineCommand.runWithGlobalArguments( | 381 nested.add(new PipelineCommand.runWithGlobalArguments( |
378 new DartKCompilerConfiguration(isHostChecked: isHostChecked, | 382 new DartKCompilerConfiguration(isChecked: isChecked, |
379 useSdk: useSdk, verify: verify, strong: strong))); | 383 isHostChecked: isHostChecked, useSdk: useSdk, verify: verify, |
384 strong: strong))); | |
380 | 385 |
381 // Run the normal precompiler. | 386 // Run the normal precompiler. |
382 nested.add(new PipelineCommand.runWithPreviousKernelOutput( | 387 nested.add(new PipelineCommand.runWithPreviousKernelOutput( |
383 new PrecompilerCompilerConfiguration( | 388 new PrecompilerCompilerConfiguration( |
384 arch: arch, useBlobs: useBlobs, isAndroid: isAndroid))); | 389 isChecked: isChecked, arch: arch, useBlobs: useBlobs, |
390 isAndroid: isAndroid))); | |
385 | 391 |
386 return new ComposedCompilerConfiguration(nested, isPrecompiler: true); | 392 return new ComposedCompilerConfiguration(nested); |
387 } | 393 } |
388 | 394 |
389 static ComposedCompilerConfiguration createDartKConfiguration( | 395 static ComposedCompilerConfiguration createDartKConfiguration( |
390 {bool isHostChecked, bool useSdk, bool verify, bool strong}) { | 396 {bool isChecked, bool isHostChecked, bool useSdk, bool verify, |
397 bool strong}) { | |
391 var nested = []; | 398 var nested = []; |
392 | 399 |
393 // Compile with dartk. | 400 // Compile with dartk. |
394 nested.add(new PipelineCommand.runWithGlobalArguments( | 401 nested.add(new PipelineCommand.runWithGlobalArguments( |
395 new DartKCompilerConfiguration(isHostChecked: isHostChecked, | 402 new DartKCompilerConfiguration(isChecked: isChecked, |
396 useSdk: useSdk, verify: verify, strong: strong))); | 403 isHostChecked: isHostChecked, useSdk: useSdk, |
404 verify: verify, strong: strong))); | |
397 | 405 |
398 return new ComposedCompilerConfiguration(nested, isPrecompiler: false); | 406 return new ComposedCompilerConfiguration(nested); |
399 } | 407 } |
400 } | 408 } |
401 | 409 |
402 /// Common configuration for dart2js-based tools, such as, dart2js | 410 /// Common configuration for dart2js-based tools, such as, dart2js |
403 class Dart2xCompilerConfiguration extends CompilerConfiguration { | 411 class Dart2xCompilerConfiguration extends CompilerConfiguration { |
404 final String moniker; | 412 final String moniker; |
405 static Map<String, List<Uri>> _bootstrapDependenciesCache = | 413 static Map<String, List<Uri>> _bootstrapDependenciesCache = |
406 new Map<String, List<Uri>>(); | 414 new Map<String, List<Uri>>(); |
407 | 415 |
408 Dart2xCompilerConfiguration(this.moniker, | 416 Dart2xCompilerConfiguration(this.moniker, |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 TestInformation info, | 698 TestInformation info, |
691 List<String> vmOptions, | 699 List<String> vmOptions, |
692 List<String> sharedOptions, | 700 List<String> sharedOptions, |
693 List<String> originalArguments, | 701 List<String> originalArguments, |
694 CommandArtifact artifact) { | 702 CommandArtifact artifact) { |
695 List<String> args = []; | 703 List<String> args = []; |
696 if (isChecked) { | 704 if (isChecked) { |
697 args.add('--enable_asserts'); | 705 args.add('--enable_asserts'); |
698 args.add('--enable_type_checks'); | 706 args.add('--enable_type_checks'); |
699 } | 707 } |
708 var newOriginalArguments = new List<String>.from(originalArguments); | |
709 for (var i = 0; i < newOriginalArguments .length; i++) { | |
710 if (newOriginalArguments[i].endsWith(".dart")) { | |
711 newOriginalArguments[i] = "${artifact.filename}/out.aotsnapshot"; | |
712 } | |
713 } | |
kustermann
2017/01/17 15:19:54
Maybe I can also get rid of this at some point, bu
| |
700 return args | 714 return args |
701 ..addAll(vmOptions) | 715 ..addAll(vmOptions) |
702 ..addAll(sharedOptions) | 716 ..addAll(sharedOptions) |
703 ..addAll(originalArguments); | 717 ..addAll(newOriginalArguments); |
704 } | 718 } |
705 } | 719 } |
706 | 720 |
707 class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration { | 721 class Dart2AppSnapshotCompilerConfiguration extends CompilerConfiguration { |
708 Dart2AppSnapshotCompilerConfiguration({bool isDebug, bool isChecked}) | 722 Dart2AppSnapshotCompilerConfiguration({bool isDebug, bool isChecked}) |
709 : super._subclass(isDebug: isDebug, isChecked: isChecked); | 723 : super._subclass(isDebug: isDebug, isChecked: isChecked); |
710 | 724 |
711 int computeTimeoutMultiplier() { | 725 int computeTimeoutMultiplier() { |
712 int multiplier = 2; | 726 int multiplier = 2; |
713 if (isDebug) multiplier *= 4; | 727 if (isDebug) multiplier *= 4; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 RuntimeConfiguration runtimeConfiguration, | 862 RuntimeConfiguration runtimeConfiguration, |
849 String buildDir, | 863 String buildDir, |
850 TestInformation info, | 864 TestInformation info, |
851 List<String> vmOptions, | 865 List<String> vmOptions, |
852 List<String> sharedOptions, | 866 List<String> sharedOptions, |
853 List<String> originalArguments, | 867 List<String> originalArguments, |
854 CommandArtifact artifact) { | 868 CommandArtifact artifact) { |
855 return <String>[]; | 869 return <String>[]; |
856 } | 870 } |
857 } | 871 } |
OLD | NEW |