| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// V8 runner support used by dartdevrun. | 5 /// V8 runner support used by dartdevrun. |
| 6 library dev_compiler.src.runner.v8_utils; | 6 library dev_compiler.src.runner.v8_utils; |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'package:path/path.dart'; | 10 import 'package:path/path.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 throw new UnsupportedError("Unknown v8-based binary: $bin"); | 43 throw new UnsupportedError("Unknown v8-based binary: $bin"); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 List<String> get _v8VersionArgs; | 47 List<String> get _v8VersionArgs; |
| 48 List<String> _getLoadStatements(List<File> files); | 48 List<String> _getLoadStatements(List<File> files); |
| 49 | 49 |
| 50 String get _v8Binary => _options.runnerOptions.v8Binary; | 50 String get _v8Binary => _options.runnerOptions.v8Binary; |
| 51 | 51 |
| 52 Future<Process> start(List<File> files, String startStatement) => | 52 Future<Process> start(List<File> files, String startStatement) => |
| 53 Process.start(_v8Binary, | 53 Process.start( |
| 54 _v8Binary, |
| 54 [ | 55 [ |
| 55 "--harmony_arrow_functions", | 56 "--harmony_arrow_functions", |
| 56 "--harmony_classes", | 57 "--harmony_classes", |
| 57 "--harmony_computed_property_names", | 58 "--harmony_computed_property_names", |
| 58 "--harmony_modules", | 59 "--harmony_modules", |
| 59 "--harmony_object_literals", | 60 "--harmony_object_literals", |
| 60 "--harmony_rest_parameters", | 61 "--harmony_rest_parameters", |
| 61 "--harmony_spreadcalls", | 62 "--harmony_spreadcalls", |
| 62 "-e", _GLOBALS + _getLoadStatements(files).join() + startStatement | 63 "-e", |
| 64 _GLOBALS + _getLoadStatements(files).join() + startStatement |
| 63 ], | 65 ], |
| 64 workingDirectory: _options.codegenOptions.outputDir); | 66 workingDirectory: _options.codegenOptions.outputDir); |
| 65 | 67 |
| 66 /// Throws if the v8 version of this runner is not supported, or if the runner | 68 /// Throws if the v8 version of this runner is not supported, or if the runner |
| 67 /// is not in the path. | 69 /// is not in the path. |
| 68 void _checkVersion() { | 70 void _checkVersion() { |
| 69 ProcessResult result = Process.runSync(_v8Binary, _v8VersionArgs); | 71 ProcessResult result = Process.runSync(_v8Binary, _v8VersionArgs); |
| 70 if (result.exitCode != 0) { | 72 if (result.exitCode != 0) { |
| 71 throw new StateError("Failed to run $_v8Binary: ${result.stderr}"); | 73 throw new StateError("Failed to run $_v8Binary: ${result.stderr}"); |
| 72 } | 74 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 93 | 95 |
| 94 /// Runner for iojs (see https://iojs.org/download/next-nightly/) and node. | 96 /// Runner for iojs (see https://iojs.org/download/next-nightly/) and node. |
| 95 class _NodeRunner extends V8Runner { | 97 class _NodeRunner extends V8Runner { |
| 96 _NodeRunner(options) : super._(options); | 98 _NodeRunner(options) : super._(options); |
| 97 | 99 |
| 98 @override | 100 @override |
| 99 get _v8VersionArgs => ['-p', 'process.versions.v8']; | 101 get _v8VersionArgs => ['-p', 'process.versions.v8']; |
| 100 | 102 |
| 101 @override | 103 @override |
| 102 _getLoadStatements(List<File> files) => files.map((file) { | 104 _getLoadStatements(List<File> files) => files.map((file) { |
| 103 String alias = getRuntimeFileAlias(_options, file); | 105 String alias = getRuntimeFileAlias(_options, file); |
| 104 return (alias != null ? 'var $alias = ' : '') + 'require("${file.path}");'; | 106 return (alias != null ? 'var $alias = ' : '') + |
| 105 }); | 107 'require("${file.path}");'; |
| 108 }); |
| 106 } | 109 } |
| OLD | NEW |