Alexander Aprelev 034a630220
Roll dart to aece1c1e92. (#12997)
* Roll dart to aece1c1e92.

Changes since last roll:
```
aece1c1e92 Update compile_flutter.sh after vm -> frontend_server rename
9293e26fc9 [gardening] Fix flutter hhh patch.
13fbf569f6 [flutter] split frontend_server from vm package
a389015083 Rewrite MethodInvocation to FunctionExpressionInvocation when the target is not a method.
ae251757a9 [vm,aot,bytecode] Performance fixes
01ebf92dde [VM] Consume extension member/is late flag setting when reading kernel file.
8e05cd278c [vm, bytecode] Emit bytecode without ASTs by default.
4539536b34 [eventhandler] generalize socket initialization
7115687beb NNBD i13n: Add a description for discarding just the condition
2bcaf02582 (origin/base) Update dartdoc to 0.28.7.
a0e8c7712d [dart2js] New RTI: Prevent elision of precomputed1 and remove unneeded read.
c38e19cbbe [vm/compiler] bit utilities
f918214f36 Add a unit test reproducing issue #38352.
ad47b1ca64 Remove summary1, part 2.
0881a4a691 Reland "Deprecate TypeParameterTypeImpl.getTypes()"
d93a6b596b Prepare to publish analyzer version 0.38.5
d5feab0c53 [vm] Create builds for LeakSanitizer, MemorySanitizer and ThreadSanitizer.
8c5236f55e [vm/ffi] Fix host-target word mismatch breaking AOT callbacks in ARM_X64.
5f7b837195 Remove unused FunctionElementImpl_forLUB.
2c75771611 Write and read the static type of IntegerLiteral.
b00453c68a Create synthetic FunctionType in quick fixes.
897e197dd4 Flow analysis: Update AssignedVariablesVisitor to track functions/methods.
55466fd3cc Flow analysis: Remove AssignedVariables.capturedAnywhere.
0a5cf36f14 Make exitFunctionBody safer.
```

* Update license hash
2019-10-08 08:07:39 -07:00

151 lines
4.2 KiB
Dart

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library flutter_frontend_server;
import 'dart:async';
import 'dart:io' hide FileSystemEntity;
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
import 'package:vm/incremental_compiler.dart';
import 'package:frontend_server/frontend_server.dart' as frontend
show
FrontendCompiler,
CompilerInterface,
listenAndCompile,
argParser,
usage,
ProgramTransformer;
/// Wrapper around [FrontendCompiler] that adds [widgetCreatorTracker] kernel
/// transformation to the compilation.
class _FlutterFrontendCompiler implements frontend.CompilerInterface {
final frontend.CompilerInterface _compiler;
_FlutterFrontendCompiler(StringSink output,
{bool unsafePackageSerialization,
frontend.ProgramTransformer transformer})
: _compiler = frontend.FrontendCompiler(output,
transformer: transformer,
unsafePackageSerialization: unsafePackageSerialization);
@override
Future<bool> compile(String filename, ArgResults options,
{IncrementalCompiler generator}) async {
return _compiler.compile(filename, options, generator: generator);
}
@override
Future<Null> recompileDelta({String entryPoint}) async {
return _compiler.recompileDelta(entryPoint: entryPoint);
}
@override
void acceptLastDelta() {
_compiler.acceptLastDelta();
}
@override
Future<void> rejectLastDelta() async {
return _compiler.rejectLastDelta();
}
@override
void invalidate(Uri uri) {
_compiler.invalidate(uri);
}
@override
Future<Null> compileExpression(
String expression,
List<String> definitions,
List<String> typeDefinitions,
String libraryUri,
String klass,
bool isStatic) {
return _compiler.compileExpression(
expression, definitions, typeDefinitions, libraryUri, klass, isStatic);
}
@override
void reportError(String msg) {
_compiler.reportError(msg);
}
@override
void resetIncrementalCompiler() {
_compiler.resetIncrementalCompiler();
}
}
/// Entry point for this module, that creates `_FrontendCompiler` instance and
/// processes user input.
/// `compiler` is an optional parameter so it can be replaced with mocked
/// version for testing.
Future<int> starter(
List<String> args, {
frontend.CompilerInterface compiler,
Stream<List<int>> input,
StringSink output,
frontend.ProgramTransformer transformer,
}) async {
ArgResults options;
try {
options = frontend.argParser.parse(args);
} catch (error) {
print('ERROR: $error\n');
print(frontend.usage);
return 1;
}
if (options['train']) {
if (!options.rest.isNotEmpty) {
throw Exception('Must specify input.dart');
}
final String input = options.rest[0];
final String sdkRoot = options['sdk-root'];
final Directory temp =
Directory.systemTemp.createTempSync('train_frontend_server');
try {
final String outputTrainingDill = path.join(temp.path, 'app.dill');
options = frontend.argParser.parse(<String>[
'--incremental',
'--sdk-root=$sdkRoot',
'--output-dill=$outputTrainingDill',
'--target=flutter',
'--track-widget-creation',
]);
compiler ??= _FlutterFrontendCompiler(output);
await compiler.compile(input, options);
compiler.acceptLastDelta();
await compiler.recompileDelta();
compiler.acceptLastDelta();
compiler.resetIncrementalCompiler();
await compiler.recompileDelta();
compiler.acceptLastDelta();
await compiler.recompileDelta();
compiler.acceptLastDelta();
return 0;
} finally {
temp.deleteSync(recursive: true);
}
}
compiler ??= _FlutterFrontendCompiler(output,
transformer: transformer,
unsafePackageSerialization: options['unsafe-package-serialization']);
if (options.rest.isNotEmpty) {
return await compiler.compile(options.rest[0], options) ? 0 : 254;
}
final Completer<int> completer = Completer<int>();
frontend.listenAndCompile(compiler, input ?? stdin, options, completer);
return completer.future;
}