mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This change removes uses of toString transformer from Flutter engine. The transformer is already wired up in Dart SDK: front-end server from Dart SDK supports --delete-tostring-package-uri option. After this change only the integration test is left in the Flutter engine to make sure dart:ui is properly transformed. dart-lang/sdk#46022
92 lines
2.8 KiB
Dart
92 lines
2.8 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.
|
|
|
|
// @dart=2.8
|
|
library flutter_frontend_server;
|
|
|
|
import 'dart:async';
|
|
import 'dart:io' hide FileSystemEntity;
|
|
|
|
import 'package:args/args.dart';
|
|
import 'package:frontend_server/frontend_server.dart' as frontend
|
|
show
|
|
FrontendCompiler,
|
|
CompilerInterface,
|
|
listenAndCompile,
|
|
argParser,
|
|
usage;
|
|
import 'package:path/path.dart' as path;
|
|
|
|
/// 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,
|
|
}) async {
|
|
ArgResults options;
|
|
try {
|
|
options = frontend.argParser.parse(args);
|
|
} catch (error) {
|
|
print('ERROR: $error\n');
|
|
print(frontend.usage);
|
|
return 1;
|
|
}
|
|
|
|
if (options['train'] as bool) {
|
|
if (!options.rest.isNotEmpty) {
|
|
throw Exception('Must specify input.dart');
|
|
}
|
|
|
|
final String input = options.rest[0];
|
|
final String sdkRoot = options['sdk-root'] as String;
|
|
final Directory temp =
|
|
Directory.systemTemp.createTempSync('train_frontend_server');
|
|
try {
|
|
for (int i = 0; i < 3; i++) {
|
|
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',
|
|
'--enable-asserts',
|
|
]);
|
|
compiler ??= frontend.FrontendCompiler(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 ??= frontend.FrontendCompiler(output,
|
|
useDebuggerModuleNames: options['debugger-module-names'] as bool,
|
|
emitDebugMetadata: options['experimental-emit-debug-metadata'] as bool,
|
|
unsafePackageSerialization:
|
|
options['unsafe-package-serialization'] as bool);
|
|
|
|
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;
|
|
}
|