9bc232be12
This CL creates the initial DDC-specific CFE entry point. It is currently mostly a matter of copying the DDC code for running the front-end into the front-end, although it also applies a workaround for making batch-mode faster. Local timings of running tools/test.py -mrelease -cdartdevk -rnone --strong --checked language_2 before and after change: * Before: [05:49 | 100% | + 5136 | - 0] * After: [00:20 | 100% | + 5136 | - 0] Change-Id: I799b54b406970c4aa8653b71aaffa2ba476ee9d9 Reviewed-on: https://dart-review.googlesource.com/24921 Reviewed-by: Kevin Millikin <kmillikin@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com>
63 lines
1.9 KiB
Dart
Executable File
63 lines
1.9 KiB
Dart
Executable File
#!/usr/bin/env dart
|
|
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
/// Experimental command line entry point for Dart Development Compiler.
|
|
/// Unlike `dartdevc` this version uses the shared front end and IR.
|
|
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:dev_compiler/src/kernel/command.dart';
|
|
import 'package:front_end/src/api_unstable/ddc.dart' as fe;
|
|
|
|
Future main(List<String> args) async {
|
|
if (args.isNotEmpty && args.last == "--batch") {
|
|
await runBatch(args.sublist(0, args.length - 1));
|
|
} else {
|
|
var result = await compile(args);
|
|
var succeeded = result.result;
|
|
exitCode = succeeded ? 0 : 1;
|
|
}
|
|
}
|
|
|
|
/// Runs dartdevk in batch mode for test.dart.
|
|
Future runBatch(List<String> batchArgs) async {
|
|
var tests = 0;
|
|
var failed = 0;
|
|
var watch = new Stopwatch()..start();
|
|
|
|
print('>>> BATCH START');
|
|
|
|
String line;
|
|
fe.InitializedCompilerState compilerState;
|
|
|
|
while ((line = stdin.readLineSync(encoding: UTF8)).isNotEmpty) {
|
|
tests++;
|
|
var args = batchArgs.toList()..addAll(line.split(new RegExp(r'\s+')));
|
|
|
|
String outcome;
|
|
try {
|
|
var result = await compile(args, compilerState: compilerState);
|
|
compilerState = result.compilerState;
|
|
var succeeded = result.result;
|
|
outcome = succeeded ? 'PASS' : 'FAIL';
|
|
} catch (e, s) {
|
|
outcome = 'CRASH';
|
|
print('Unhandled exception:');
|
|
print(e);
|
|
print(s);
|
|
}
|
|
|
|
// TODO(rnystrom): If kernel has any internal static state that needs to
|
|
// be cleared, do it here.
|
|
|
|
stderr.writeln('>>> EOF STDERR');
|
|
print('>>> TEST $outcome ${watch.elapsedMilliseconds}ms');
|
|
}
|
|
|
|
var time = watch.elapsedMilliseconds;
|
|
print('>>> BATCH END (${tests - failed})/$tests ${time}ms');
|
|
}
|