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 'path.dart'; |
10 import 'runtime_configuration.dart'; | 10 import 'runtime_configuration.dart'; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 throw "Unknown compiler for: $runtimeType"; | 87 throw "Unknown compiler for: $runtimeType"; |
88 } | 88 } |
89 | 89 |
90 bool get hasCompiler => true; | 90 bool get hasCompiler => true; |
91 | 91 |
92 String get executableScriptSuffix => Platform.isWindows ? '.bat' : ''; | 92 String get executableScriptSuffix => Platform.isWindows ? '.bat' : ''; |
93 | 93 |
94 List<Uri> bootstrapDependencies() => const <Uri>[]; | 94 List<Uri> bootstrapDependencies() => const <Uri>[]; |
95 | 95 |
96 /// Creates a [Command] to compile [inputFile] to [outputFile]. | 96 /// Creates a [Command] to compile [inputFile] to [outputFile]. |
97 Command createCommand(String inputFile, String outputFile) { | 97 Command createCommand( |
| 98 String inputFile, String outputFile, List<String> sharedOptions) { |
98 // TODO(rnystrom): See if this method can be unified with | 99 // TODO(rnystrom): See if this method can be unified with |
99 // computeCompilationArtifact() and/or computeCompilerArguments() for the | 100 // computeCompilationArtifact() and/or computeCompilerArguments() for the |
100 // other compilers. | 101 // other compilers. |
101 throw new UnsupportedError("$this does not support createCommand()."); | 102 throw new UnsupportedError("$this does not support createCommand()."); |
102 } | 103 } |
103 | 104 |
104 CommandArtifact computeCompilationArtifact(String tempDir, | 105 CommandArtifact computeCompilationArtifact(String tempDir, |
105 List<String> arguments, Map<String, String> environmentOverrides) { | 106 List<String> arguments, Map<String, String> environmentOverrides) { |
106 return new CommandArtifact([], null, null); | 107 return new CommandArtifact([], null, null); |
107 } | 108 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 /// Configuration for dart2js compiler. | 359 /// Configuration for dart2js compiler. |
359 class DartdevcCompilerConfiguration extends CompilerConfiguration { | 360 class DartdevcCompilerConfiguration extends CompilerConfiguration { |
360 DartdevcCompilerConfiguration(Configuration configuration) | 361 DartdevcCompilerConfiguration(Configuration configuration) |
361 : super._subclass(configuration); | 362 : super._subclass(configuration); |
362 | 363 |
363 String computeCompilerPath() { | 364 String computeCompilerPath() { |
364 var dir = _useSdk ? "${_configuration.buildDirectory}/dart-sdk" : "sdk"; | 365 var dir = _useSdk ? "${_configuration.buildDirectory}/dart-sdk" : "sdk"; |
365 return "$dir/bin/dartdevc$executableScriptSuffix"; | 366 return "$dir/bin/dartdevc$executableScriptSuffix"; |
366 } | 367 } |
367 | 368 |
368 Command createCommand(String inputFile, String outputFile) { | 369 List<String> computeCompilerArguments( |
| 370 List<String> vmOptions, List<String> sharedOptions, List<String> args) { |
| 371 var result = sharedOptions.toList(); |
| 372 |
| 373 // The file being compiled is the last argument. |
| 374 result.add(args.last); |
| 375 |
| 376 return result; |
| 377 } |
| 378 |
| 379 Command createCommand( |
| 380 String inputFile, String outputFile, List<String> sharedOptions) { |
369 var moduleRoot = | 381 var moduleRoot = |
370 new Path(outputFile).directoryPath.directoryPath.toNativePath(); | 382 new Path(outputFile).directoryPath.directoryPath.toNativePath(); |
371 | 383 |
372 var args = [ | 384 var args = [ |
373 "--dart-sdk", | 385 "--dart-sdk", |
374 "${_configuration.buildDirectory}/dart-sdk", | 386 "${_configuration.buildDirectory}/dart-sdk", |
375 "--library-root", | 387 "--library-root", |
376 new Path(inputFile).directoryPath.toNativePath(), | 388 new Path(inputFile).directoryPath.toNativePath(), |
377 "--module-root", | 389 "--module-root", |
378 moduleRoot, | 390 moduleRoot, |
379 "--no-summarize", | 391 "--no-summarize", |
380 "--no-source-map", | 392 "--no-source-map", |
381 "-o", | 393 "-o", |
382 outputFile, | 394 outputFile, |
383 inputFile, | 395 inputFile, |
384 ]; | 396 ]; |
385 | 397 |
| 398 args.addAll(sharedOptions); |
| 399 |
386 // Link to the summaries for the available packages, so that they don't | 400 // Link to the summaries for the available packages, so that they don't |
387 // get recompiled into the test's own module. | 401 // get recompiled into the test's own module. |
388 for (var package in testPackages) { | 402 for (var package in testPackages) { |
389 args.add("-s"); | 403 args.add("-s"); |
390 | 404 |
391 // Since the summaries for the packages are not near the tests, we give | 405 // Since the summaries for the packages are not near the tests, we give |
392 // dartdevc explicit module paths for each one. When the test is run, we | 406 // dartdevc explicit module paths for each one. When the test is run, we |
393 // will tell require.js where to find each package's compiled JS. | 407 // will tell require.js where to find each package's compiled JS. |
394 var summary = _configuration.buildDirectory + | 408 var summary = _configuration.buildDirectory + |
395 "/gen/utils/dartdevc/pkg/$package.sum"; | 409 "/gen/utils/dartdevc/pkg/$package.sum"; |
396 args.add("$summary=$package"); | 410 args.add("$summary=$package"); |
397 } | 411 } |
398 | 412 |
399 return Command.compilation(Compiler.dartdevc.name, outputFile, | 413 return Command.compilation(Compiler.dartdevc.name, outputFile, |
400 bootstrapDependencies(), computeCompilerPath(), args, const {}); | 414 bootstrapDependencies(), computeCompilerPath(), args, const {}); |
401 } | 415 } |
402 | 416 |
403 CommandArtifact computeCompilationArtifact(String tempDir, | 417 CommandArtifact computeCompilationArtifact(String tempDir, |
404 List<String> arguments, Map<String, String> environmentOverrides) { | 418 List<String> arguments, Map<String, String> environmentOverrides) { |
405 // TODO(rnystrom): Are there other arguments here that we need to keep? | 419 // The list of arguments comes from a call to our own |
406 // What about arguments specified in the test itself? | 420 // computeCompilerArguments(). It contains the shared options followed by |
| 421 // the input file path. |
| 422 // TODO(rnystrom): Jamming these into a list in order to pipe them from |
| 423 // computeCompilerArguments() to here seems hacky. Is there a cleaner way? |
| 424 var sharedOptions = arguments.sublist(0, arguments.length - 1); |
407 var inputFile = arguments.last; | 425 var inputFile = arguments.last; |
408 var outputFile = "$tempDir/${inputFile.replaceAll('.dart', '.js')}"; | 426 var outputFile = "$tempDir/${inputFile.replaceAll('.dart', '.js')}"; |
409 | 427 |
410 return new CommandArtifact([createCommand(inputFile, outputFile)], | 428 return new CommandArtifact( |
411 outputFile, "application/javascript"); | 429 [createCommand(inputFile, outputFile, sharedOptions)], |
| 430 outputFile, |
| 431 "application/javascript"); |
412 } | 432 } |
413 } | 433 } |
414 | 434 |
415 class PrecompilerCompilerConfiguration extends CompilerConfiguration { | 435 class PrecompilerCompilerConfiguration extends CompilerConfiguration { |
416 final bool useDfe; | 436 final bool useDfe; |
417 | 437 |
418 bool get _isAndroid => _configuration.system == System.android; | 438 bool get _isAndroid => _configuration.system == System.android; |
419 bool get _isArm => _configuration.architecture == Architecture.arm; | 439 bool get _isArm => _configuration.architecture == Architecture.arm; |
420 bool get _isArm64 => _configuration.architecture == Architecture.arm64; | 440 bool get _isArm64 => _configuration.architecture == Architecture.arm64; |
421 | 441 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 List<String> computeRuntimeArguments( | 741 List<String> computeRuntimeArguments( |
722 RuntimeConfiguration runtimeConfiguration, | 742 RuntimeConfiguration runtimeConfiguration, |
723 TestInformation info, | 743 TestInformation info, |
724 List<String> vmOptions, | 744 List<String> vmOptions, |
725 List<String> sharedOptions, | 745 List<String> sharedOptions, |
726 List<String> originalArguments, | 746 List<String> originalArguments, |
727 CommandArtifact artifact) { | 747 CommandArtifact artifact) { |
728 return <String>[]; | 748 return <String>[]; |
729 } | 749 } |
730 } | 750 } |
OLD | NEW |