| 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 | 7 import 'dart:io' show |
| 8 Platform; | 8 Platform; |
| 9 | 9 |
| 10 import 'runtime_configuration.dart' show | 10 import 'runtime_configuration.dart' show |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 case 'dart2analyzer': | 70 case 'dart2analyzer': |
| 71 return new DartBasedAnalyzerCompilerConfiguration( | 71 return new DartBasedAnalyzerCompilerConfiguration( |
| 72 isDebug: isDebug, isChecked: isChecked, | 72 isDebug: isDebug, isChecked: isChecked, |
| 73 isHostChecked: isHostChecked, useSdk: useSdk); | 73 isHostChecked: isHostChecked, useSdk: useSdk); |
| 74 case 'dart2js': | 74 case 'dart2js': |
| 75 return new Dart2jsCompilerConfiguration( | 75 return new Dart2jsCompilerConfiguration( |
| 76 isDebug: isDebug, isChecked: isChecked, | 76 isDebug: isDebug, isChecked: isChecked, |
| 77 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk, | 77 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk, |
| 78 isCsp: isCsp, extraDart2jsOptions: | 78 isCsp: isCsp, extraDart2jsOptions: |
| 79 TestUtils.getExtraOptions(configuration, 'dart2js_options')); | 79 TestUtils.getExtraOptions(configuration, 'dart2js_options')); |
| 80 case 'dart2dart': | |
| 81 return new Dart2dartCompilerConfiguration( | |
| 82 isDebug: isDebug, isChecked: isChecked, | |
| 83 isHostChecked: isHostChecked, useSdk: useSdk); | |
| 84 case 'none': | 80 case 'none': |
| 85 return new NoneCompilerConfiguration( | 81 return new NoneCompilerConfiguration( |
| 86 isDebug: isDebug, isChecked: isChecked, | 82 isDebug: isDebug, isChecked: isChecked, |
| 87 isHostChecked: isHostChecked, useSdk: useSdk); | 83 isHostChecked: isHostChecked, useSdk: useSdk); |
| 88 default: | 84 default: |
| 89 throw "Unknown compiler '$compiler'"; | 85 throw "Unknown compiler '$compiler'"; |
| 90 } | 86 } |
| 91 } | 87 } |
| 92 | 88 |
| 93 CompilerConfiguration._subclass({ | 89 CompilerConfiguration._subclass({ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 List<String> sharedOptions, | 155 List<String> sharedOptions, |
| 160 List<String> originalArguments, | 156 List<String> originalArguments, |
| 161 CommandArtifact artifact) { | 157 CommandArtifact artifact) { |
| 162 return <String>[] | 158 return <String>[] |
| 163 ..addAll(vmOptions) | 159 ..addAll(vmOptions) |
| 164 ..addAll(sharedOptions) | 160 ..addAll(sharedOptions) |
| 165 ..addAll(originalArguments); | 161 ..addAll(originalArguments); |
| 166 } | 162 } |
| 167 } | 163 } |
| 168 | 164 |
| 169 /// Common configuration for dart2js-based tools, such as, dart2js and | 165 /// Common configuration for dart2js-based tools, such as, dart2js |
| 170 /// dart2dart. | |
| 171 class Dart2xCompilerConfiguration extends CompilerConfiguration { | 166 class Dart2xCompilerConfiguration extends CompilerConfiguration { |
| 172 final String moniker; | 167 final String moniker; |
| 173 static Map<String, List<Uri>> _bootstrapDependenciesCache = | 168 static Map<String, List<Uri>> _bootstrapDependenciesCache = |
| 174 new Map<String, List<Uri>>(); | 169 new Map<String, List<Uri>>(); |
| 175 | 170 |
| 176 Dart2xCompilerConfiguration( | 171 Dart2xCompilerConfiguration( |
| 177 this.moniker, | 172 this.moniker, |
| 178 {bool isDebug, | 173 {bool isDebug, |
| 179 bool isChecked, | 174 bool isChecked, |
| 180 bool isHostChecked, | 175 bool isHostChecked, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 CommandArtifact artifact) { | 278 CommandArtifact artifact) { |
| 284 Uri sdk = useSdk ? | 279 Uri sdk = useSdk ? |
| 285 nativeDirectoryToUri(buildDir).resolve('dart-sdk/') : | 280 nativeDirectoryToUri(buildDir).resolve('dart-sdk/') : |
| 286 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/'); | 281 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/'); |
| 287 Uri preambleDir = sdk.resolve('lib/_internal/compiler/js_lib/preambles/'); | 282 Uri preambleDir = sdk.resolve('lib/_internal/compiler/js_lib/preambles/'); |
| 288 return runtimeConfiguration.dart2jsPreambles(preambleDir) | 283 return runtimeConfiguration.dart2jsPreambles(preambleDir) |
| 289 ..add(artifact.filename); | 284 ..add(artifact.filename); |
| 290 } | 285 } |
| 291 } | 286 } |
| 292 | 287 |
| 293 /// Configuration for dart2dart compiler. | |
| 294 class Dart2dartCompilerConfiguration extends Dart2xCompilerConfiguration { | |
| 295 Dart2dartCompilerConfiguration({ | |
| 296 bool isDebug, | |
| 297 bool isChecked, | |
| 298 bool isHostChecked, | |
| 299 bool useSdk}) | |
| 300 : super( | |
| 301 'dart2dart', | |
| 302 isDebug: isDebug, isChecked: isChecked, | |
| 303 isHostChecked: isHostChecked, useSdk: useSdk); | |
| 304 | |
| 305 CommandArtifact computeCompilationArtifact( | |
| 306 String buildDir, | |
| 307 String tempDir, | |
| 308 CommandBuilder commandBuilder, | |
| 309 List arguments, | |
| 310 Map<String, String> environmentOverrides) { | |
| 311 String outputFileName = '$tempDir/out.dart'; | |
| 312 arguments = new List.from(arguments)..add('--output-type=dart'); | |
| 313 return new CommandArtifact( | |
| 314 <Command>[ | |
| 315 this.computeCompilationCommand( | |
| 316 outputFileName, | |
| 317 buildDir, | |
| 318 CommandBuilder.instance, | |
| 319 arguments, | |
| 320 environmentOverrides)], | |
| 321 outputFileName, | |
| 322 'application/dart'); | |
| 323 } | |
| 324 | |
| 325 List<String> computeRuntimeArguments( | |
| 326 RuntimeConfiguration runtimeConfiguration, | |
| 327 String buildDir, | |
| 328 TestInformation info, | |
| 329 List<String> vmOptions, | |
| 330 List<String> sharedOptions, | |
| 331 List<String> originalArguments, | |
| 332 CommandArtifact artifact) { | |
| 333 // TODO(antonm): support checked. | |
| 334 return <String>[] | |
| 335 ..addAll(vmOptions) | |
| 336 ..add('--ignore-unrecognized-flags') | |
| 337 ..add(artifact.filename); | |
| 338 } | |
| 339 } | |
| 340 | |
| 341 /// Common configuration for analyzer-based tools, such as, dartanalyzer. | 288 /// Common configuration for analyzer-based tools, such as, dartanalyzer. |
| 342 class AnalyzerCompilerConfiguration extends CompilerConfiguration { | 289 class AnalyzerCompilerConfiguration extends CompilerConfiguration { |
| 343 final String moniker; | 290 final String moniker; |
| 344 | 291 |
| 345 AnalyzerCompilerConfiguration( | 292 AnalyzerCompilerConfiguration( |
| 346 this.moniker, | 293 this.moniker, |
| 347 {bool isDebug, | 294 {bool isDebug, |
| 348 bool isChecked, | 295 bool isChecked, |
| 349 bool isHostChecked, | 296 bool isHostChecked, |
| 350 bool useSdk}) | 297 bool useSdk}) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // shipped SDK, that is the script is not installed in | 358 // shipped SDK, that is the script is not installed in |
| 412 // "$buildDir/dart-sdk/bin/" | 359 // "$buildDir/dart-sdk/bin/" |
| 413 return '$prefix/dartanalyzer_developer$suffix'; | 360 return '$prefix/dartanalyzer_developer$suffix'; |
| 414 } | 361 } |
| 415 if (useSdk) { | 362 if (useSdk) { |
| 416 prefix = '$buildDir/dart-sdk/bin'; | 363 prefix = '$buildDir/dart-sdk/bin'; |
| 417 } | 364 } |
| 418 return '$prefix/dartanalyzer$suffix'; | 365 return '$prefix/dartanalyzer$suffix'; |
| 419 } | 366 } |
| 420 } | 367 } |
| OLD | NEW |