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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 case 'dart2analyzer': | 67 case 'dart2analyzer': |
68 return new AnalyzerCompilerConfiguration( | 68 return new AnalyzerCompilerConfiguration( |
69 isDebug: isDebug, isChecked: isChecked, | 69 isDebug: isDebug, isChecked: isChecked, |
70 isHostChecked: isHostChecked, useSdk: useSdk); | 70 isHostChecked: isHostChecked, useSdk: useSdk); |
71 case 'dart2js': | 71 case 'dart2js': |
72 return new Dart2jsCompilerConfiguration( | 72 return new Dart2jsCompilerConfiguration( |
73 isDebug: isDebug, isChecked: isChecked, | 73 isDebug: isDebug, isChecked: isChecked, |
74 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk, | 74 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk, |
75 isCsp: isCsp, extraDart2jsOptions: | 75 isCsp: isCsp, extraDart2jsOptions: |
76 TestUtils.getExtraOptions(configuration, 'dart2js_options')); | 76 TestUtils.getExtraOptions(configuration, 'dart2js_options')); |
| 77 case 'precompiler': |
| 78 return new PrecompilerCompilerConfiguration( |
| 79 isDebug: isDebug, isChecked: isChecked); |
77 case 'none': | 80 case 'none': |
78 return new NoneCompilerConfiguration( | 81 return new NoneCompilerConfiguration( |
79 isDebug: isDebug, isChecked: isChecked, | 82 isDebug: isDebug, isChecked: isChecked, |
80 isHostChecked: isHostChecked, useSdk: useSdk, useNoopt: useNoopt); | 83 isHostChecked: isHostChecked, useSdk: useSdk, useNoopt: useNoopt); |
81 default: | 84 default: |
82 throw "Unknown compiler '$compiler'"; | 85 throw "Unknown compiler '$compiler'"; |
83 } | 86 } |
84 } | 87 } |
85 | 88 |
86 CompilerConfiguration._subclass({ | 89 CompilerConfiguration._subclass({ |
(...skipping 25 matching lines...) Expand all Loading... |
112 | 115 |
113 CommandArtifact computeCompilationArtifact( | 116 CommandArtifact computeCompilationArtifact( |
114 String buildDir, | 117 String buildDir, |
115 String tempDir, | 118 String tempDir, |
116 CommandBuilder commandBuilder, | 119 CommandBuilder commandBuilder, |
117 List arguments, | 120 List arguments, |
118 Map<String, String> environmentOverrides) { | 121 Map<String, String> environmentOverrides) { |
119 return new CommandArtifact([], null, null); | 122 return new CommandArtifact([], null, null); |
120 } | 123 } |
121 | 124 |
| 125 List<String> computeCompilerArguments(vmOptions, sharedOptions, args) { |
| 126 return new List<String>() |
| 127 ..addAll(sharedOptions) |
| 128 ..addAll(args); |
| 129 } |
| 130 |
122 List<String> computeRuntimeArguments( | 131 List<String> computeRuntimeArguments( |
123 RuntimeConfiguration runtimeConfiguration, | 132 RuntimeConfiguration runtimeConfiguration, |
124 String buildDir, | 133 String buildDir, |
125 TestInformation info, | 134 TestInformation info, |
126 List<String> vmOptions, | 135 List<String> vmOptions, |
127 List<String> sharedOptions, | 136 List<String> sharedOptions, |
128 List<String> originalArguments, | 137 List<String> originalArguments, |
129 CommandArtifact artifact) { | 138 CommandArtifact artifact) { |
130 return <String>[artifact.filename]; | 139 return <String>[artifact.filename]; |
131 } | 140 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 Uri sdk = useSdk ? | 296 Uri sdk = useSdk ? |
288 nativeDirectoryToUri(buildDir).resolve('dart-sdk/') : | 297 nativeDirectoryToUri(buildDir).resolve('dart-sdk/') : |
289 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/'); | 298 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/'); |
290 Uri preambleDir = sdk.resolve( | 299 Uri preambleDir = sdk.resolve( |
291 'lib/_internal/js_runtime/lib/preambles/'); | 300 'lib/_internal/js_runtime/lib/preambles/'); |
292 return runtimeConfiguration.dart2jsPreambles(preambleDir) | 301 return runtimeConfiguration.dart2jsPreambles(preambleDir) |
293 ..add(artifact.filename); | 302 ..add(artifact.filename); |
294 } | 303 } |
295 } | 304 } |
296 | 305 |
| 306 |
| 307 class PrecompilerCompilerConfiguration extends CompilerConfiguration { |
| 308 PrecompilerCompilerConfiguration({ |
| 309 bool isDebug, |
| 310 bool isChecked}) |
| 311 : super._subclass(isDebug: isDebug, isChecked: isChecked); |
| 312 |
| 313 int computeTimeoutMultiplier() { |
| 314 int multiplier = 2; |
| 315 if (isDebug) multiplier *= 4; |
| 316 if (isChecked) multiplier *= 2; |
| 317 return multiplier; |
| 318 } |
| 319 |
| 320 CommandArtifact computeCompilationArtifact( |
| 321 String buildDir, |
| 322 String tempDir, |
| 323 CommandBuilder commandBuilder, |
| 324 List arguments, |
| 325 Map<String, String> environmentOverrides) { |
| 326 return new CommandArtifact( |
| 327 <Command>[ |
| 328 this.computeCompilationCommand( |
| 329 tempDir, |
| 330 buildDir, |
| 331 CommandBuilder.instance, |
| 332 arguments, |
| 333 environmentOverrides)], |
| 334 '$tempDir', |
| 335 'application/dart-precompiled'); |
| 336 } |
| 337 |
| 338 CompilationCommand computeCompilationCommand( |
| 339 String tempDir, |
| 340 String buildDir, |
| 341 CommandBuilder commandBuilder, |
| 342 List arguments, |
| 343 Map<String, String> environmentOverrides) { |
| 344 var exec = "$buildDir/dart"; |
| 345 var args = new List(); |
| 346 args.add("tools/precompilation/precompiler.dart"); |
| 347 args.add("$buildDir/dart_no_snapshot"); |
| 348 args.add("--gen-precompiled-snapshot=$tempDir"); |
| 349 args.addAll(arguments); |
| 350 |
| 351 return commandBuilder.getCompilationCommand( |
| 352 'precompiler.dart', tempDir, !useSdk, |
| 353 bootstrapDependencies(buildDir), |
| 354 exec, args, environmentOverrides); |
| 355 } |
| 356 |
| 357 List<String> computeCompilerArguments(vmOptions, |
| 358 sharedOptions, |
| 359 originalArguments) { |
| 360 List<String> args = []; |
| 361 if (isChecked) { |
| 362 args.add('--enable_asserts'); |
| 363 args.add('--enable_type_checks'); |
| 364 } |
| 365 return args |
| 366 ..addAll(vmOptions) |
| 367 ..addAll(sharedOptions) |
| 368 ..addAll(originalArguments); |
| 369 } |
| 370 |
| 371 List<String> computeRuntimeArguments( |
| 372 RuntimeConfiguration runtimeConfiguration, |
| 373 String buildDir, |
| 374 TestInformation info, |
| 375 List<String> vmOptions, |
| 376 List<String> sharedOptions, |
| 377 List<String> originalArguments, |
| 378 CommandArtifact artifact) { |
| 379 List<String> args = []; |
| 380 if (isChecked) { |
| 381 args.add('--enable_asserts'); |
| 382 args.add('--enable_type_checks'); |
| 383 } |
| 384 return args |
| 385 ..addAll(vmOptions) |
| 386 ..addAll(sharedOptions) |
| 387 ..addAll(originalArguments); |
| 388 } |
| 389 } |
| 390 |
| 391 |
297 class AnalyzerCompilerConfiguration extends CompilerConfiguration { | 392 class AnalyzerCompilerConfiguration extends CompilerConfiguration { |
298 AnalyzerCompilerConfiguration( | 393 AnalyzerCompilerConfiguration( |
299 {bool isDebug, | 394 {bool isDebug, |
300 bool isChecked, | 395 bool isChecked, |
301 bool isHostChecked, | 396 bool isHostChecked, |
302 bool useSdk}) | 397 bool useSdk}) |
303 : super._subclass( | 398 : super._subclass( |
304 isDebug: isDebug, isChecked: isChecked, | 399 isDebug: isDebug, isChecked: isChecked, |
305 isHostChecked: isHostChecked, useSdk: useSdk); | 400 isHostChecked: isHostChecked, useSdk: useSdk); |
306 | 401 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 RuntimeConfiguration runtimeConfiguration, | 445 RuntimeConfiguration runtimeConfiguration, |
351 String buildDir, | 446 String buildDir, |
352 TestInformation info, | 447 TestInformation info, |
353 List<String> vmOptions, | 448 List<String> vmOptions, |
354 List<String> sharedOptions, | 449 List<String> sharedOptions, |
355 List<String> originalArguments, | 450 List<String> originalArguments, |
356 CommandArtifact artifact) { | 451 CommandArtifact artifact) { |
357 return <String>[]; | 452 return <String>[]; |
358 } | 453 } |
359 } | 454 } |
OLD | NEW |