Merge pull request #317 from dart-lang/fix-devrun

Update devrun to use latest node.js
This commit is contained in:
John Messerly 2015-10-29 10:19:40 -07:00
commit d8c7cd7d67
2 changed files with 17 additions and 19 deletions

View file

@ -13,6 +13,7 @@ import 'package:logging/logging.dart' show Level;
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
const String _V8_BINARY_DEFAULT = 'node';
const bool _CLOSURE_DEFAULT = false;
/// Options used to set up Source URI resolution in the analysis context.
@ -87,7 +88,7 @@ class RunnerOptions {
/// executable.
final String v8Binary;
const RunnerOptions({this.v8Binary: 'iojs'});
const RunnerOptions({this.v8Binary: _V8_BINARY_DEFAULT});
}
/// General options used by the dev compiler and server.
@ -206,7 +207,7 @@ CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) {
var htmlReport = args['html-report'];
var v8Binary = args['v8-binary'];
if (v8Binary == null) v8Binary = 'iojs';
if (v8Binary == null) v8Binary = _V8_BINARY_DEFAULT;
var customUrlMappings = <String, String>{};
for (var mapping in args['url-mapping']) {
@ -321,12 +322,20 @@ final ArgParser argParser = new ArgParser()
help: 'Output compilation results to html', defaultsTo: false)
..addOption('v8-binary',
help: 'V8-based binary to run JavaScript output with (iojs, node, d8)',
defaultsTo: 'iojs')
defaultsTo: _V8_BINARY_DEFAULT)
..addOption('dump-info-file',
help: 'Dump info json file (requires dump-info)', defaultsTo: null);
// TODO: Switch over to the `pub_cache` package (or the Resource API)?
const _ENTRY_POINTS = const [
'dartdevc.dart',
'dev_compiler.dart',
'devrun.dart'
];
final _ENTRY_POINT_SNAPSHOTS = _ENTRY_POINTS.map((f) => "$f.snapshot");
/// Tries to find the `lib/runtime/` directory of the dev_compiler package. This
/// works when running devc from it's sources or from a snapshot that is
/// activated via `pub global activate`.
@ -346,16 +355,13 @@ String _computeRuntimeDir() {
if (!new File(lockfile).existsSync()) return null;
// If running from sources we found it!
if (file == 'dartdevc.dart' ||
file == 'dev_compiler.dart' ||
file == 'devrun.dart') {
if (_ENTRY_POINTS.contains(file)) {
return path.join(dir, 'lib', 'runtime');
}
// If running from a pub global snapshot, we need to read the lock file to
// find where the actual sources are located in the pub cache.
if (file == 'dartdevc.dart.snapshot' ||
file == 'dev_compiler.dart.snapshot') {
if (_ENTRY_POINT_SNAPSHOTS.contains(file)) {
// Note: this depends on implementation details of pub.
var yaml = loadYaml(new File(lockfile).readAsStringSync());
var info = yaml['packages']['dev_compiler'];

View file

@ -17,8 +17,7 @@ import 'runtime_utils.dart' show getRuntimeFileAlias;
_parseV8Version(String version) =>
new Version.parse(version.split('.').getRange(0, 3).join('.'));
/// io.js still has issues, like lexical this in arrow functions.
final _MIN_SUPPORTED_V8_VERSION = _parseV8Version("4.4.63");
final _MIN_SUPPORTED_V8_VERSION = _parseV8Version("4.5.103.30");
/// TODO(ochafik): Move to dart_library.js
const _GLOBALS = r'''
@ -52,15 +51,8 @@ abstract class V8Runner {
Future<Process> start(List<File> files, String startStatement) =>
Process.start(
_v8Binary,
[
"--harmony_arrow_functions",
"--harmony_classes",
"--harmony_computed_property_names",
"--harmony_generators",
"--harmony_object_literals",
"--harmony_rest_parameters",
"--harmony_spreadcalls",
_v8Binary, [
"--harmony",
"-e",
_GLOBALS + _getLoadStatements(files).join() + startStatement
],