| 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 import 'runtime_configuration.dart' show DartPrecompiledAdbRuntimeConfiguration; | 10 import 'runtime_configuration.dart' show DartPrecompiledAdbRuntimeConfiguration; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 bool isHostChecked = configuration['host_checked']; | 62 bool isHostChecked = configuration['host_checked']; |
| 63 bool useSdk = configuration['use_sdk']; | 63 bool useSdk = configuration['use_sdk']; |
| 64 bool isCsp = configuration['csp']; | 64 bool isCsp = configuration['csp']; |
| 65 bool useCps = configuration['cps_ir']; | 65 bool useCps = configuration['cps_ir']; |
| 66 bool useBlobs = configuration['use_blobs']; | 66 bool useBlobs = configuration['use_blobs']; |
| 67 bool hotReload = configuration['hot_reload']; | 67 bool hotReload = configuration['hot_reload']; |
| 68 bool hotReloadRollback = configuration['hot_reload_rollback']; | 68 bool hotReloadRollback = configuration['hot_reload_rollback']; |
| 69 bool useFastStartup = configuration['fast_startup']; | 69 bool useFastStartup = configuration['fast_startup']; |
| 70 bool verifyKernel = configuration['verify-ir']; | 70 bool verifyKernel = configuration['verify-ir']; |
| 71 bool useStandaloneDartK = configuration['use-standalone-dartk']; | 71 bool useStandaloneDartK = configuration['use-standalone-dartk']; |
| 72 bool treeShake = !configuration['no-tree-shake']; |
| 72 | 73 |
| 73 switch (compiler) { | 74 switch (compiler) { |
| 74 case 'dart2analyzer': | 75 case 'dart2analyzer': |
| 75 return new AnalyzerCompilerConfiguration( | 76 return new AnalyzerCompilerConfiguration( |
| 76 isDebug: isDebug, | 77 isDebug: isDebug, |
| 77 isChecked: isChecked, | 78 isChecked: isChecked, |
| 78 isStrong: isStrong, | 79 isStrong: isStrong, |
| 79 isHostChecked: isHostChecked, | 80 isHostChecked: isHostChecked, |
| 80 useSdk: useSdk); | 81 useSdk: useSdk); |
| 81 case 'dart2js': | 82 case 'dart2js': |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 arch: configuration['arch'], | 100 arch: configuration['arch'], |
| 100 useBlobs: useBlobs, | 101 useBlobs: useBlobs, |
| 101 isAndroid: configuration['system'] == 'android'); | 102 isAndroid: configuration['system'] == 'android'); |
| 102 case 'dartk': | 103 case 'dartk': |
| 103 if (useStandaloneDartK) { | 104 if (useStandaloneDartK) { |
| 104 return ComposedCompilerConfiguration.createDartKConfiguration( | 105 return ComposedCompilerConfiguration.createDartKConfiguration( |
| 105 isChecked: isChecked, | 106 isChecked: isChecked, |
| 106 isHostChecked: isHostChecked, | 107 isHostChecked: isHostChecked, |
| 107 useSdk: useSdk, | 108 useSdk: useSdk, |
| 108 verify: verifyKernel, | 109 verify: verifyKernel, |
| 109 strong: isStrong); | 110 strong: isStrong, |
| 111 treeShake: treeShake); |
| 110 } | 112 } |
| 111 | 113 |
| 112 return new NoneCompilerConfiguration( | 114 return new NoneCompilerConfiguration( |
| 113 isDebug: isDebug, | 115 isDebug: isDebug, |
| 114 isChecked: isChecked, | 116 isChecked: isChecked, |
| 115 isHostChecked: isHostChecked, | 117 isHostChecked: isHostChecked, |
| 116 useSdk: useSdk, | 118 useSdk: useSdk, |
| 117 hotReload: hotReload, | 119 hotReload: hotReload, |
| 118 hotReloadRollback: hotReloadRollback, | 120 hotReloadRollback: hotReloadRollback, |
| 119 useDFEIsolate: true); | 121 useDFEIsolate: true); |
| 120 | 122 |
| 121 case 'dartkp': | 123 case 'dartkp': |
| 122 return ComposedCompilerConfiguration.createDartKPConfiguration( | 124 return ComposedCompilerConfiguration.createDartKPConfiguration( |
| 123 isChecked: isChecked, | 125 isChecked: isChecked, |
| 124 isHostChecked: isHostChecked, | 126 isHostChecked: isHostChecked, |
| 125 arch: configuration['arch'], | 127 arch: configuration['arch'], |
| 126 useBlobs: useBlobs, | 128 useBlobs: useBlobs, |
| 127 isAndroid: configuration['system'] == 'android', | 129 isAndroid: configuration['system'] == 'android', |
| 128 useSdk: useSdk, | 130 useSdk: useSdk, |
| 129 verify: verifyKernel, | 131 verify: verifyKernel, |
| 130 strong: isStrong); | 132 strong: isStrong, |
| 133 treeShake: treeShake); |
| 131 case 'none': | 134 case 'none': |
| 132 return new NoneCompilerConfiguration( | 135 return new NoneCompilerConfiguration( |
| 133 isDebug: isDebug, | 136 isDebug: isDebug, |
| 134 isChecked: isChecked, | 137 isChecked: isChecked, |
| 135 isHostChecked: isHostChecked, | 138 isHostChecked: isHostChecked, |
| 136 useSdk: useSdk, | 139 useSdk: useSdk, |
| 137 hotReload: hotReload, | 140 hotReload: hotReload, |
| 138 hotReloadRollback: hotReloadRollback); | 141 hotReloadRollback: hotReloadRollback); |
| 139 default: | 142 default: |
| 140 throw "Unknown compiler '$compiler'"; | 143 throw "Unknown compiler '$compiler'"; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 239 } |
| 237 return args | 240 return args |
| 238 ..addAll(vmOptions) | 241 ..addAll(vmOptions) |
| 239 ..addAll(sharedOptions) | 242 ..addAll(sharedOptions) |
| 240 ..addAll(originalArguments); | 243 ..addAll(originalArguments); |
| 241 } | 244 } |
| 242 } | 245 } |
| 243 | 246 |
| 244 /// The "dartk" compiler. | 247 /// The "dartk" compiler. |
| 245 class DartKCompilerConfiguration extends CompilerConfiguration { | 248 class DartKCompilerConfiguration extends CompilerConfiguration { |
| 246 final bool verify, strong; | 249 final bool verify, strong, treeShake; |
| 247 | 250 |
| 248 DartKCompilerConfiguration({bool isChecked, bool isHostChecked, bool useSdk, | 251 DartKCompilerConfiguration({bool isChecked, bool isHostChecked, bool useSdk, |
| 249 this.verify, this.strong}) | 252 this.verify, this.strong, this.treeShake}) |
| 250 : super._subclass(isChecked: isChecked, isHostChecked: isHostChecked, | 253 : super._subclass(isChecked: isChecked, isHostChecked: isHostChecked, |
| 251 useSdk: useSdk); | 254 useSdk: useSdk); |
| 252 | 255 |
| 253 @override | 256 @override |
| 254 String computeCompilerPath(String buildDir) { | 257 String computeCompilerPath(String buildDir) { |
| 255 return 'tools/dartk_wrappers/dartk$executableScriptSuffix'; | 258 return 'tools/dartk_wrappers/dartk$executableScriptSuffix'; |
| 256 } | 259 } |
| 257 | 260 |
| 258 CompilationCommand computeCompilationCommand( | 261 CompilationCommand computeCompilationCommand( |
| 259 String outputFileName, | 262 String outputFileName, |
| 260 String buildDir, | 263 String buildDir, |
| 261 CommandBuilder commandBuilder, | 264 CommandBuilder commandBuilder, |
| 262 List arguments, | 265 List arguments, |
| 263 Map<String, String> environmentOverrides) { | 266 Map<String, String> environmentOverrides) { |
| 264 Iterable<String> extraArguments = [ | 267 Iterable<String> extraArguments = [ |
| 265 '--sdk', | 268 '--sdk', |
| 266 '$buildDir/patched_sdk', | 269 '$buildDir/patched_sdk', |
| 267 '--link', | 270 '--link', |
| 268 '--target=vm', | 271 '--target=vm', |
| 272 treeShake ? '--tree-shake' : null, |
| 269 strong ? '--strong' : null, | 273 strong ? '--strong' : null, |
| 270 verify ? '--verify-ir' : null, | 274 verify ? '--verify-ir' : null, |
| 271 '--out', | 275 '--out', |
| 272 outputFileName | 276 outputFileName |
| 273 ].where((x) => x != null); | 277 ].where((x) => x != null); |
| 274 return commandBuilder.getKernelCompilationCommand( | 278 return commandBuilder.getKernelCompilationCommand( |
| 275 'dartk', | 279 'dartk', |
| 276 outputFileName, | 280 outputFileName, |
| 277 true, | 281 true, |
| 278 bootstrapDependencies(buildDir), | 282 bootstrapDependencies(buildDir), |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 CommandArtifact artifact) { | 419 CommandArtifact artifact) { |
| 416 CompilerConfiguration lastCompilerConfiguration = | 420 CompilerConfiguration lastCompilerConfiguration = |
| 417 pipelineCommands.last.compilerConfiguration; | 421 pipelineCommands.last.compilerConfiguration; |
| 418 return lastCompilerConfiguration.computeRuntimeArguments( | 422 return lastCompilerConfiguration.computeRuntimeArguments( |
| 419 runtimeConfiguration, buildDir, info, vmOptions, sharedOptions, | 423 runtimeConfiguration, buildDir, info, vmOptions, sharedOptions, |
| 420 originalArguments, artifact); | 424 originalArguments, artifact); |
| 421 } | 425 } |
| 422 | 426 |
| 423 static ComposedCompilerConfiguration createDartKPConfiguration( | 427 static ComposedCompilerConfiguration createDartKPConfiguration( |
| 424 {bool isChecked, bool isHostChecked, String arch, bool useBlobs, | 428 {bool isChecked, bool isHostChecked, String arch, bool useBlobs, |
| 425 bool isAndroid, bool useSdk, bool verify, bool strong}) { | 429 bool isAndroid, bool useSdk, bool verify, bool strong, bool treeShake}) { |
| 426 var nested = []; | 430 var nested = []; |
| 427 | 431 |
| 428 // Compile with dartk. | 432 // Compile with dartk. |
| 429 nested.add(new PipelineCommand.runWithGlobalArguments( | 433 nested.add(new PipelineCommand.runWithGlobalArguments( |
| 430 new DartKCompilerConfiguration(isChecked: isChecked, | 434 new DartKCompilerConfiguration(isChecked: isChecked, |
| 431 isHostChecked: isHostChecked, useSdk: useSdk, verify: verify, | 435 isHostChecked: isHostChecked, useSdk: useSdk, verify: verify, |
| 432 strong: strong))); | 436 strong: strong, treeShake: treeShake))); |
| 433 | 437 |
| 434 // Run the normal precompiler. | 438 // Run the normal precompiler. |
| 435 nested.add(new PipelineCommand.runWithPreviousKernelOutput( | 439 nested.add(new PipelineCommand.runWithPreviousKernelOutput( |
| 436 new PrecompilerCompilerConfiguration( | 440 new PrecompilerCompilerConfiguration( |
| 437 isChecked: isChecked, arch: arch, useBlobs: useBlobs, | 441 isChecked: isChecked, arch: arch, useBlobs: useBlobs, |
| 438 isAndroid: isAndroid))); | 442 isAndroid: isAndroid))); |
| 439 | 443 |
| 440 return new ComposedCompilerConfiguration(nested); | 444 return new ComposedCompilerConfiguration(nested); |
| 441 } | 445 } |
| 442 | 446 |
| 443 static ComposedCompilerConfiguration createDartKConfiguration( | 447 static ComposedCompilerConfiguration createDartKConfiguration( |
| 444 {bool isChecked, bool isHostChecked, bool useSdk, bool verify, | 448 {bool isChecked, bool isHostChecked, bool useSdk, bool verify, |
| 445 bool strong}) { | 449 bool strong, bool treeShake}) { |
| 446 var nested = []; | 450 var nested = []; |
| 447 | 451 |
| 448 // Compile with dartk. | 452 // Compile with dartk. |
| 449 nested.add(new PipelineCommand.runWithGlobalArguments( | 453 nested.add(new PipelineCommand.runWithGlobalArguments( |
| 450 new DartKCompilerConfiguration(isChecked: isChecked, | 454 new DartKCompilerConfiguration(isChecked: isChecked, |
| 451 isHostChecked: isHostChecked, useSdk: useSdk, | 455 isHostChecked: isHostChecked, useSdk: useSdk, |
| 452 verify: verify, strong: strong))); | 456 verify: verify, strong: strong, treeShake: treeShake))); |
| 453 | 457 |
| 454 return new ComposedCompilerConfiguration(nested); | 458 return new ComposedCompilerConfiguration(nested); |
| 455 } | 459 } |
| 456 } | 460 } |
| 457 | 461 |
| 458 /// Common configuration for dart2js-based tools, such as, dart2js | 462 /// Common configuration for dart2js-based tools, such as, dart2js |
| 459 class Dart2xCompilerConfiguration extends CompilerConfiguration { | 463 class Dart2xCompilerConfiguration extends CompilerConfiguration { |
| 460 final String moniker; | 464 final String moniker; |
| 461 static Map<String, List<Uri>> _bootstrapDependenciesCache = | 465 static Map<String, List<Uri>> _bootstrapDependenciesCache = |
| 462 new Map<String, List<Uri>>(); | 466 new Map<String, List<Uri>>(); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 RuntimeConfiguration runtimeConfiguration, | 918 RuntimeConfiguration runtimeConfiguration, |
| 915 String buildDir, | 919 String buildDir, |
| 916 TestInformation info, | 920 TestInformation info, |
| 917 List<String> vmOptions, | 921 List<String> vmOptions, |
| 918 List<String> sharedOptions, | 922 List<String> sharedOptions, |
| 919 List<String> originalArguments, | 923 List<String> originalArguments, |
| 920 CommandArtifact artifact) { | 924 CommandArtifact artifact) { |
| 921 return <String>[]; | 925 return <String>[]; |
| 922 } | 926 } |
| 923 } | 927 } |
| OLD | NEW |