1ef4399df0
This uses optional new/const and `=` in named argument defaults. All changes are automated, except for: - utils/dartdevc/BUILD.gn: run DDC build scripts with --preview-dart-2 - pkg/dev_compiler/tool/patch_sdk.dart: add a TODO that Analyzer doesn't supporting implicit const in libraries.dart - pkg/dev_compiler/tool/input_sdk/libraries.dart: was not formatted due to the aforementioned Analyzer bug - tools/bots/test_matrix.json: run DDC sourcemap suite in Dart 2 mode - pkg/pkg.status: skip pkg/dev_compiler if running in Dart 1 mode Change-Id: I9b80ccba0c2cc7b66efc662a0b16562e3660aee3 Reviewed-on: https://dart-review.googlesource.com/60402 Commit-Queue: Jenny Messerly <jmesserly@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
74 lines
2.6 KiB
Dart
Executable File
74 lines
2.6 KiB
Dart
Executable File
#!/usr/bin/env dart
|
|
// Copyright (c) 2016, 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.
|
|
|
|
/// Command line entry point for Dart Development Compiler (dartdevc), used to
|
|
/// compile a collection of dart libraries into a single JS module
|
|
|
|
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'package:analyzer/file_system/physical_file_system.dart';
|
|
import 'package:analyzer/src/command_line/arguments.dart';
|
|
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
|
|
import 'package:bazel_worker/bazel_worker.dart';
|
|
import 'package:dev_compiler/src/analyzer/command.dart';
|
|
|
|
Future main(List<String> args) async {
|
|
// Always returns a new modifiable list.
|
|
args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args);
|
|
|
|
if (args.contains('--persistent_worker')) {
|
|
await _CompilerWorker(args..remove('--persistent_worker')).run();
|
|
} else if (args.isNotEmpty && args.last == "--batch") {
|
|
await runBatch(args.sublist(0, args.length - 1));
|
|
} else {
|
|
exitCode = compile(args);
|
|
}
|
|
}
|
|
|
|
/// Runs the compiler worker loop.
|
|
class _CompilerWorker extends AsyncWorkerLoop {
|
|
/// The original args supplied to the executable.
|
|
final List<String> _startupArgs;
|
|
|
|
_CompilerWorker(this._startupArgs) : super();
|
|
|
|
/// Performs each individual work request.
|
|
Future<WorkResponse> performRequest(WorkRequest request) async {
|
|
var args = _startupArgs.toList()..addAll(request.arguments);
|
|
|
|
var output = StringBuffer();
|
|
var exitCode = compile(args, printFn: output.writeln);
|
|
AnalysisEngine.instance.clearCaches();
|
|
return WorkResponse()
|
|
..exitCode = exitCode
|
|
..output = output.toString();
|
|
}
|
|
}
|
|
|
|
runBatch(List<String> batchArgs) async {
|
|
int totalTests = 0;
|
|
int testsFailed = 0;
|
|
var watch = Stopwatch()..start();
|
|
print('>>> BATCH START');
|
|
String line;
|
|
while ((line = stdin.readLineSync(encoding: utf8)).isNotEmpty) {
|
|
totalTests++;
|
|
var args = batchArgs.toList()..addAll(line.split(RegExp(r'\s+')));
|
|
|
|
// We don't try/catch here, since `compile` should handle that.
|
|
var compileExitCode = compile(args);
|
|
AnalysisEngine.instance.clearCaches();
|
|
stderr.writeln('>>> EOF STDERR');
|
|
var outcome = compileExitCode == 0
|
|
? 'PASS'
|
|
: compileExitCode == 70 ? 'CRASH' : 'FAIL';
|
|
print('>>> TEST $outcome ${watch.elapsedMilliseconds}ms');
|
|
}
|
|
int time = watch.elapsedMilliseconds;
|
|
print('>>> BATCH END '
|
|
'(${totalTests - testsFailed})/$totalTests ${time}ms');
|
|
}
|