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 Directory, 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 |
11 import 'test_runner.dart' show Command, CommandBuilder, CompilationCommand; | 11 import 'test_runner.dart' show Command, CommandBuilder, CompilationCommand; |
12 | 12 |
13 import 'test_suite.dart' show TestInformation, TestUtils; | 13 import 'test_suite.dart' show TestInformation, TestUtils; |
14 | 14 |
15 /// Grouping of a command with its expected result. | 15 /// Grouping of a command with its expected result. |
16 class CommandArtifact { | 16 class CommandArtifact { |
17 final List<Command> commands; | 17 final List<Command> commands; |
(...skipping 22 matching lines...) Expand all Loading... |
40 // TODO(ahe): Remove this constructor and move the switch to | 40 // TODO(ahe): Remove this constructor and move the switch to |
41 // test_options.dart. We probably want to store an instance of | 41 // test_options.dart. We probably want to store an instance of |
42 // [CompilerConfiguration] in [configuration] there. | 42 // [CompilerConfiguration] in [configuration] there. |
43 factory CompilerConfiguration(Map configuration) { | 43 factory CompilerConfiguration(Map configuration) { |
44 String compiler = configuration['compiler']; | 44 String compiler = configuration['compiler']; |
45 | 45 |
46 // TODO(ahe): Move these booleans into a struction configuration object | 46 // TODO(ahe): Move these booleans into a struction configuration object |
47 // which can eventually completely replace the Map-based configuration | 47 // which can eventually completely replace the Map-based configuration |
48 // object. | 48 // object. |
49 bool isDebug = configuration['mode'] == 'debug'; | 49 bool isDebug = configuration['mode'] == 'debug'; |
50 bool isProduct = configuration['mode'] == 'product'; | |
51 bool isChecked = configuration['checked']; | 50 bool isChecked = configuration['checked']; |
52 bool isHostChecked = configuration['host_checked']; | 51 bool isHostChecked = configuration['host_checked']; |
53 bool useSdk = configuration['use_sdk']; | 52 bool useSdk = configuration['use_sdk']; |
54 bool isCsp = configuration['csp']; | 53 bool isCsp = configuration['csp']; |
55 bool useCps = configuration['cps_ir']; | 54 bool useCps = configuration['cps_ir']; |
56 | 55 |
57 switch (compiler) { | 56 switch (compiler) { |
58 case 'dart2analyzer': | 57 case 'dart2analyzer': |
59 return new AnalyzerCompilerConfiguration( | 58 return new AnalyzerCompilerConfiguration( |
60 isDebug: isDebug, | 59 isDebug: isDebug, |
(...skipping 10 matching lines...) Expand all Loading... |
71 isCsp: isCsp, | 70 isCsp: isCsp, |
72 extraDart2jsOptions: | 71 extraDart2jsOptions: |
73 TestUtils.getExtraOptions(configuration, 'dart2js_options')); | 72 TestUtils.getExtraOptions(configuration, 'dart2js_options')); |
74 case 'dart2app': | 73 case 'dart2app': |
75 return new Dart2AppSnapshotCompilerConfiguration( | 74 return new Dart2AppSnapshotCompilerConfiguration( |
76 isDebug: isDebug, isChecked: isChecked); | 75 isDebug: isDebug, isChecked: isChecked); |
77 case 'precompiler': | 76 case 'precompiler': |
78 return new PrecompilerCompilerConfiguration( | 77 return new PrecompilerCompilerConfiguration( |
79 isDebug: isDebug, | 78 isDebug: isDebug, |
80 isChecked: isChecked, | 79 isChecked: isChecked, |
81 isProduct: isProduct, | |
82 arch: configuration['arch']); | 80 arch: configuration['arch']); |
83 case 'none': | 81 case 'none': |
84 return new NoneCompilerConfiguration( | 82 return new NoneCompilerConfiguration( |
85 isDebug: isDebug, | 83 isDebug: isDebug, |
86 isChecked: isChecked, | 84 isChecked: isChecked, |
87 isHostChecked: isHostChecked, | 85 isHostChecked: isHostChecked, |
88 useSdk: useSdk); | 86 useSdk: useSdk); |
89 default: | 87 default: |
90 throw "Unknown compiler '$compiler'"; | 88 throw "Unknown compiler '$compiler'"; |
91 } | 89 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath()) | 292 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath()) |
295 .resolve('sdk/'); | 293 .resolve('sdk/'); |
296 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); | 294 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); |
297 return runtimeConfiguration.dart2jsPreambles(preambleDir) | 295 return runtimeConfiguration.dart2jsPreambles(preambleDir) |
298 ..add(artifact.filename); | 296 ..add(artifact.filename); |
299 } | 297 } |
300 } | 298 } |
301 | 299 |
302 class PrecompilerCompilerConfiguration extends CompilerConfiguration { | 300 class PrecompilerCompilerConfiguration extends CompilerConfiguration { |
303 final String arch; | 301 final String arch; |
304 final bool isProduct; | |
305 | 302 |
306 PrecompilerCompilerConfiguration( | 303 PrecompilerCompilerConfiguration({bool isDebug, bool isChecked, String arch}) |
307 {bool isDebug, bool isChecked, bool isProduct, String arch}) | |
308 : super._subclass(isDebug: isDebug, isChecked: isChecked), | 304 : super._subclass(isDebug: isDebug, isChecked: isChecked), |
309 isProduct = isProduct, | |
310 arch = arch; | 305 arch = arch; |
311 | 306 |
312 int computeTimeoutMultiplier() { | 307 int computeTimeoutMultiplier() { |
313 int multiplier = 2; | 308 int multiplier = 2; |
314 if (isDebug) multiplier *= 4; | 309 if (isDebug) multiplier *= 4; |
315 if (isChecked) multiplier *= 2; | 310 if (isChecked) multiplier *= 2; |
316 return multiplier; | 311 return multiplier; |
317 } | 312 } |
318 | 313 |
319 CommandArtifact computeCompilationArtifact( | 314 CommandArtifact computeCompilationArtifact( |
(...skipping 11 matching lines...) Expand all Loading... |
331 CommandBuilder.instance, arguments, environmentOverrides) | 326 CommandBuilder.instance, arguments, environmentOverrides) |
332 ], '$tempDir', 'application/dart-precompiled'); | 327 ], '$tempDir', 'application/dart-precompiled'); |
333 } | 328 } |
334 | 329 |
335 CompilationCommand computeCompilationCommand( | 330 CompilationCommand computeCompilationCommand( |
336 String tempDir, | 331 String tempDir, |
337 String buildDir, | 332 String buildDir, |
338 CommandBuilder commandBuilder, | 333 CommandBuilder commandBuilder, |
339 List arguments, | 334 List arguments, |
340 Map<String, String> environmentOverrides) { | 335 Map<String, String> environmentOverrides) { |
341 var sourceDir = Directory.current.path; | 336 var exec = "$buildDir/dart_bootstrap"; |
342 var exec = "$buildDir/gen_snapshot"; | |
343 var args = new List(); | 337 var args = new List(); |
344 | 338 args.add("--gen-precompiled-snapshot=$tempDir"); |
345 var precompiledVMIsolate = "$tempDir/precompiled.vmisolate"; | |
346 var precompiledIsolate = "$tempDir/precompiled.isolate"; | |
347 var precompiledInstructions = "$tempDir/precompiled.S"; | |
348 var dartProductEntries = "$sourceDir/runtime/bin/dart_product_entries.txt"; | |
349 var dartEntries = "$sourceDir/runtime/bin/dart_entries.txt"; | |
350 var vmServiceIoMain = "$sourceDir/runtime/bin/vmservice/vmservice_io.dart"; | |
351 | |
352 args.add("--embedder_entry_points_manifest=$dartProductEntries"); | |
353 if (!isProduct) { | |
354 args.add("--embedder_entry_points_manifest=$dartEntries"); | |
355 } | |
356 args.add("--vm_isolate_snapshot=$precompiledVMIsolate"); | |
357 args.add("--isolate_snapshot=$precompiledIsolate"); | |
358 args.add("--instructions_snapshot=$precompiledInstructions"); | |
359 args.add("--url_mapping=dart:vmservice_io,$vmServiceIoMain"); | |
360 args.addAll(arguments); | 339 args.addAll(arguments); |
361 | 340 |
362 return commandBuilder.getCompilationCommand('precompiler', tempDir, !useSdk, | 341 return commandBuilder.getCompilationCommand('precompiler', tempDir, !useSdk, |
363 bootstrapDependencies(buildDir), exec, args, environmentOverrides); | 342 bootstrapDependencies(buildDir), exec, args, environmentOverrides); |
364 } | 343 } |
365 | 344 |
366 CompilationCommand computeAssembleCommand( | 345 CompilationCommand computeAssembleCommand( |
367 String tempDir, | 346 String tempDir, |
368 String buildDir, | 347 String buildDir, |
369 CommandBuilder commandBuilder, | 348 CommandBuilder commandBuilder, |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 RuntimeConfiguration runtimeConfiguration, | 589 RuntimeConfiguration runtimeConfiguration, |
611 String buildDir, | 590 String buildDir, |
612 TestInformation info, | 591 TestInformation info, |
613 List<String> vmOptions, | 592 List<String> vmOptions, |
614 List<String> sharedOptions, | 593 List<String> sharedOptions, |
615 List<String> originalArguments, | 594 List<String> originalArguments, |
616 CommandArtifact artifact) { | 595 CommandArtifact artifact) { |
617 return <String>[]; | 596 return <String>[]; |
618 } | 597 } |
619 } | 598 } |
OLD | NEW |