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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'command.dart'; | 7 import 'command.dart'; |
8 import 'configuration.dart'; | 8 import 'configuration.dart'; |
| 9 import 'path.dart'; |
9 import 'runtime_configuration.dart'; | 10 import 'runtime_configuration.dart'; |
10 import 'test_suite.dart'; | 11 import 'test_suite.dart'; |
11 import 'utils.dart'; | 12 import 'utils.dart'; |
12 | 13 |
13 List<String> replaceDartFileWith(List<String> list, String replacement) { | 14 List<String> replaceDartFileWith(List<String> list, String replacement) { |
14 var copy = new List<String>.from(list); | 15 var copy = new List<String>.from(list); |
15 for (var i = 0; i < copy.length; i++) { | 16 for (var i = 0; i < copy.length; i++) { |
16 if (copy[i].endsWith(".dart")) { | 17 if (copy[i].endsWith(".dart")) { |
17 copy[i] = replacement; | 18 copy[i] = replacement; |
18 } | 19 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 return new Dart2jsCompilerConfiguration( | 67 return new Dart2jsCompilerConfiguration( |
67 isDebug: configuration.mode.isDebug, | 68 isDebug: configuration.mode.isDebug, |
68 isChecked: configuration.isChecked, | 69 isChecked: configuration.isChecked, |
69 isHostChecked: configuration.isHostChecked, | 70 isHostChecked: configuration.isHostChecked, |
70 useSdk: configuration.useSdk, | 71 useSdk: configuration.useSdk, |
71 isCsp: configuration.isCsp, | 72 isCsp: configuration.isCsp, |
72 useFastStartup: configuration.useFastStartup, | 73 useFastStartup: configuration.useFastStartup, |
73 useKernel: configuration.useDart2JSWithKernel, | 74 useKernel: configuration.useDart2JSWithKernel, |
74 extraDart2jsOptions: configuration.dart2jsOptions); | 75 extraDart2jsOptions: configuration.dart2jsOptions); |
75 | 76 |
| 77 case Compiler.dartdevc: |
| 78 return new DartdevcCompilerConfiguration( |
| 79 isDebug: configuration.mode.isDebug, |
| 80 isChecked: configuration.isChecked, |
| 81 isHostChecked: configuration.isHostChecked); |
| 82 break; |
| 83 |
76 case Compiler.appJit: | 84 case Compiler.appJit: |
77 return new AppJitCompilerConfiguration( | 85 return new AppJitCompilerConfiguration( |
78 isDebug: configuration.mode.isDebug, | 86 isDebug: configuration.mode.isDebug, |
79 isChecked: configuration.isChecked); | 87 isChecked: configuration.isChecked); |
80 | 88 |
81 case Compiler.precompiler: | 89 case Compiler.precompiler: |
82 return new PrecompilerCompilerConfiguration( | 90 return new PrecompilerCompilerConfiguration( |
83 isDebug: configuration.mode.isDebug, | 91 isDebug: configuration.mode.isDebug, |
84 isChecked: configuration.isChecked, | 92 isChecked: configuration.isChecked, |
85 arch: configuration.architecture, | 93 arch: configuration.architecture, |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 481 } |
474 | 482 |
475 Command computeCompilationCommand(String outputFileName, String buildDir, | 483 Command computeCompilationCommand(String outputFileName, String buildDir, |
476 List<String> arguments, Map<String, String> environmentOverrides) { | 484 List<String> arguments, Map<String, String> environmentOverrides) { |
477 arguments = arguments.toList(); | 485 arguments = arguments.toList(); |
478 arguments.add('--out=$outputFileName'); | 486 arguments.add('--out=$outputFileName'); |
479 | 487 |
480 return Command.compilation( | 488 return Command.compilation( |
481 moniker, | 489 moniker, |
482 outputFileName, | 490 outputFileName, |
483 !useSdk, | |
484 bootstrapDependencies(buildDir), | 491 bootstrapDependencies(buildDir), |
485 computeCompilerPath(buildDir), | 492 computeCompilerPath(buildDir), |
486 arguments, | 493 arguments, |
487 environmentOverrides); | 494 environmentOverrides, |
| 495 alwaysCompile: !useSdk); |
488 } | 496 } |
489 | 497 |
490 List<Uri> bootstrapDependencies(String buildDir) { | 498 List<Uri> bootstrapDependencies(String buildDir) { |
491 if (!useSdk) return const <Uri>[]; | 499 if (!useSdk) return const <Uri>[]; |
492 return _bootstrapDependenciesCache.putIfAbsent( | 500 return _bootstrapDependenciesCache.putIfAbsent( |
493 buildDir, | 501 buildDir, |
494 () => [ | 502 () => [ |
495 Uri.base | 503 Uri.base |
496 .resolveUri(nativeDirectoryToUri(buildDir)) | 504 .resolveUri(nativeDirectoryToUri(buildDir)) |
497 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') | 505 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 Uri sdk = useSdk | 557 Uri sdk = useSdk |
550 ? nativeDirectoryToUri(buildDir).resolve('dart-sdk/') | 558 ? nativeDirectoryToUri(buildDir).resolve('dart-sdk/') |
551 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath()) | 559 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath()) |
552 .resolve('sdk/'); | 560 .resolve('sdk/'); |
553 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); | 561 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); |
554 return runtimeConfiguration.dart2jsPreambles(preambleDir) | 562 return runtimeConfiguration.dart2jsPreambles(preambleDir) |
555 ..add(artifact.filename); | 563 ..add(artifact.filename); |
556 } | 564 } |
557 } | 565 } |
558 | 566 |
| 567 /// Configuration for dart2js compiler. |
| 568 class DartdevcCompilerConfiguration extends CompilerConfiguration { |
| 569 DartdevcCompilerConfiguration( |
| 570 {bool isDebug, bool isChecked, bool isHostChecked}) |
| 571 : super._subclass( |
| 572 isDebug: isDebug, |
| 573 isChecked: isChecked, |
| 574 isHostChecked: isHostChecked, |
| 575 useSdk: true); |
| 576 |
| 577 String computeCompilerPath(String buildDir) { |
| 578 return "$buildDir/dart-sdk/bin/dartdevc$executableScriptSuffix"; |
| 579 } |
| 580 |
| 581 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir, |
| 582 List<String> arguments, Map<String, String> environmentOverrides) { |
| 583 // TODO(rnystrom): There is a lot of overlap between this code and |
| 584 // _dartdevcCompileCommand() in test_suite.dart. This code path is only hit |
| 585 // when the test is expected to have a compile error. Consider refactoring |
| 586 // to unify the two (and likewise for dart2js). |
| 587 |
| 588 // TODO(rnystrom): Are there other arguments here that we need to keep? |
| 589 // What about arguments specified in the test itself? |
| 590 var inputFile = arguments.last; |
| 591 |
| 592 var compilerArguments = [ |
| 593 "--dart-sdk", |
| 594 "$buildDir/dart-sdk", |
| 595 "--library-root", |
| 596 new Path(inputFile).directoryPath.toString(), |
| 597 "-o", |
| 598 "$tempDir/out.js", |
| 599 inputFile |
| 600 ]; |
| 601 |
| 602 var command = Command.compilation( |
| 603 Compiler.dartdevc.name, |
| 604 "$tempDir/out.js", |
| 605 bootstrapDependencies(buildDir), |
| 606 computeCompilerPath(buildDir), |
| 607 compilerArguments, |
| 608 environmentOverrides); |
| 609 |
| 610 return new CommandArtifact( |
| 611 [command], "$tempDir/out.js", "application/javascript"); |
| 612 } |
| 613 } |
| 614 |
559 class PrecompilerCompilerConfiguration extends CompilerConfiguration { | 615 class PrecompilerCompilerConfiguration extends CompilerConfiguration { |
560 final Architecture arch; | 616 final Architecture arch; |
561 final bool useBlobs; | 617 final bool useBlobs; |
562 final bool isAndroid; | 618 final bool isAndroid; |
563 final bool useDfe; | 619 final bool useDfe; |
564 | 620 |
565 PrecompilerCompilerConfiguration( | 621 PrecompilerCompilerConfiguration( |
566 {bool isDebug, | 622 {bool isDebug, |
567 bool isChecked, | 623 bool isChecked, |
568 this.arch, | 624 this.arch, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 args.add("--snapshot=$tempDir/out.aotsnapshot"); | 671 args.add("--snapshot=$tempDir/out.aotsnapshot"); |
616 args.add("--use-blobs"); | 672 args.add("--use-blobs"); |
617 } else { | 673 } else { |
618 args.add("--snapshot=$tempDir/out.S"); | 674 args.add("--snapshot=$tempDir/out.S"); |
619 } | 675 } |
620 if (isAndroid && arch == Architecture.arm) { | 676 if (isAndroid && arch == Architecture.arm) { |
621 args.add('--no-sim-use-hardfp'); | 677 args.add('--no-sim-use-hardfp'); |
622 } | 678 } |
623 args.addAll(arguments); | 679 args.addAll(arguments); |
624 | 680 |
625 return Command.compilation('precompiler', tempDir, !useSdk, | 681 return Command.compilation('precompiler', tempDir, |
626 bootstrapDependencies(buildDir), exec, args, environmentOverrides); | 682 bootstrapDependencies(buildDir), exec, args, environmentOverrides, |
| 683 alwaysCompile: !useSdk); |
627 } | 684 } |
628 | 685 |
629 Command computeAssembleCommand(String tempDir, String buildDir, | 686 Command computeAssembleCommand(String tempDir, String buildDir, |
630 List arguments, Map<String, String> environmentOverrides) { | 687 List arguments, Map<String, String> environmentOverrides) { |
631 String cc, shared, ldFlags; | 688 String cc, shared, ldFlags; |
632 if (isAndroid) { | 689 if (isAndroid) { |
633 var ndk = "third_party/android_tools/ndk"; | 690 var ndk = "third_party/android_tools/ndk"; |
634 String triple; | 691 String triple; |
635 if (arch == Architecture.arm) { | 692 if (arch == Architecture.arm) { |
636 triple = "arm-linux-androideabi"; | 693 triple = "arm-linux-androideabi"; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 var exec = cc; | 739 var exec = cc; |
683 var args = <String>[]; | 740 var args = <String>[]; |
684 if (ccFlags != null) args.add(ccFlags); | 741 if (ccFlags != null) args.add(ccFlags); |
685 if (ldFlags != null) args.add(ldFlags); | 742 if (ldFlags != null) args.add(ldFlags); |
686 args.add(shared); | 743 args.add(shared); |
687 args.add('-nostdlib'); | 744 args.add('-nostdlib'); |
688 args.add('-o'); | 745 args.add('-o'); |
689 args.add('$tempDir/out.aotsnapshot'); | 746 args.add('$tempDir/out.aotsnapshot'); |
690 args.add('$tempDir/out.S'); | 747 args.add('$tempDir/out.S'); |
691 | 748 |
692 return Command.compilation('assemble', tempDir, !useSdk, | 749 return Command.compilation('assemble', tempDir, |
693 bootstrapDependencies(buildDir), exec, args, environmentOverrides); | 750 bootstrapDependencies(buildDir), exec, args, environmentOverrides, |
| 751 alwaysCompile: !useSdk); |
694 } | 752 } |
695 | 753 |
696 // This step reduces the amount of space needed to run the precompilation | 754 // This step reduces the amount of space needed to run the precompilation |
697 // tests by 60%. | 755 // tests by 60%. |
698 Command computeRemoveAssemblyCommand(String tempDir, String buildDir, | 756 Command computeRemoveAssemblyCommand(String tempDir, String buildDir, |
699 List arguments, Map<String, String> environmentOverrides) { | 757 List arguments, Map<String, String> environmentOverrides) { |
700 var exec = 'rm'; | 758 var exec = 'rm'; |
701 var args = ['$tempDir/out.S']; | 759 var args = ['$tempDir/out.S']; |
702 | 760 |
703 return Command.compilation('remove_assembly', tempDir, !useSdk, | 761 return Command.compilation('remove_assembly', tempDir, |
704 bootstrapDependencies(buildDir), exec, args, environmentOverrides); | 762 bootstrapDependencies(buildDir), exec, args, environmentOverrides, |
| 763 alwaysCompile: !useSdk); |
705 } | 764 } |
706 | 765 |
707 List<String> filterVmOptions(List<String> vmOptions) { | 766 List<String> filterVmOptions(List<String> vmOptions) { |
708 var filtered = vmOptions.toList(); | 767 var filtered = vmOptions.toList(); |
709 filtered.removeWhere( | 768 filtered.removeWhere( |
710 (option) => option.startsWith("--optimization-counter-threshold")); | 769 (option) => option.startsWith("--optimization-counter-threshold")); |
711 filtered.removeWhere( | 770 filtered.removeWhere( |
712 (option) => option.startsWith("--optimization_counter_threshold")); | 771 (option) => option.startsWith("--optimization_counter_threshold")); |
713 return filtered; | 772 return filtered; |
714 } | 773 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 ], snapshot, 'application/dart-snapshot'); | 835 ], snapshot, 'application/dart-snapshot'); |
777 } | 836 } |
778 | 837 |
779 Command computeCompilationCommand(String tempDir, String buildDir, | 838 Command computeCompilationCommand(String tempDir, String buildDir, |
780 List<String> arguments, Map<String, String> environmentOverrides) { | 839 List<String> arguments, Map<String, String> environmentOverrides) { |
781 var exec = "$buildDir/dart"; | 840 var exec = "$buildDir/dart"; |
782 var snapshot = "$tempDir/out.jitsnapshot"; | 841 var snapshot = "$tempDir/out.jitsnapshot"; |
783 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"]; | 842 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"]; |
784 args.addAll(arguments); | 843 args.addAll(arguments); |
785 | 844 |
786 return Command.compilation('app_jit', tempDir, !useSdk, | 845 return Command.compilation('app_jit', tempDir, |
787 bootstrapDependencies(buildDir), exec, args, environmentOverrides); | 846 bootstrapDependencies(buildDir), exec, args, environmentOverrides, |
| 847 alwaysCompile: !useSdk); |
788 } | 848 } |
789 | 849 |
790 List<String> computeCompilerArguments( | 850 List<String> computeCompilerArguments( |
791 vmOptions, sharedOptions, originalArguments) { | 851 vmOptions, sharedOptions, originalArguments) { |
792 var args = <String>[]; | 852 var args = <String>[]; |
793 if (isChecked) { | 853 if (isChecked) { |
794 args.add('--enable_asserts'); | 854 args.add('--enable_asserts'); |
795 args.add('--enable_type_checks'); | 855 args.add('--enable_type_checks'); |
796 } | 856 } |
797 return args | 857 return args |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 RuntimeConfiguration runtimeConfiguration, | 937 RuntimeConfiguration runtimeConfiguration, |
878 String buildDir, | 938 String buildDir, |
879 TestInformation info, | 939 TestInformation info, |
880 List<String> vmOptions, | 940 List<String> vmOptions, |
881 List<String> sharedOptions, | 941 List<String> sharedOptions, |
882 List<String> originalArguments, | 942 List<String> originalArguments, |
883 CommandArtifact artifact) { | 943 CommandArtifact artifact) { |
884 return <String>[]; | 944 return <String>[]; |
885 } | 945 } |
886 } | 946 } |
OLD | NEW |