Write artifacts produced during frontend_server training into temp folder. (flutter/engine#4687)

* Write artifacts produced during frontend_server training into temp folder.

* Write artifacts produced during frontend_server training into temp folder.

* Fix File/String mixup

* Remove temp directory. Use full prefix for package

* Delete in finally {}
This commit is contained in:
Alexander Aprelev
2018-02-18 14:48:55 -08:00
committed by GitHub
parent b2b7309505
commit 9742ed5cb6

View File

@@ -22,6 +22,7 @@ import 'package:kernel/binary/limited_ast_to_binary.dart';
import 'package:kernel/kernel.dart' show Program, loadProgramFromBytes;
import 'package:kernel/target/flutter.dart';
import 'package:kernel/target/targets.dart';
import 'package:path/path.dart' as path;
import 'package:usage/uuid/uuid.dart';
import 'package:vm/incremental_compiler.dart' show IncrementalCompiler;
import 'package:vm/kernel_front_end.dart' show compileToKernel;
@@ -337,18 +338,30 @@ Future<int> starter(
if (options['train']) {
final String sdkRoot = options['sdk-root'];
options = _argParser.parse(<String>['--incremental', '--sdk-root=$sdkRoot']);
compiler ??= new _FrontendCompiler(output, printerFactory: binaryPrinterFactory);
await compiler.compile(Platform.script.toFilePath(), options, generator: generator);
compiler.acceptLastDelta();
await compiler.recompileDelta();
compiler.acceptLastDelta();
compiler.resetIncrementalCompiler();
await compiler.recompileDelta();
compiler.acceptLastDelta();
await compiler.recompileDelta();
compiler.acceptLastDelta();
return 0;
final Directory temp = Directory.systemTemp.createTempSync('train_frontend_server');
try {
final String outputTrainingDill = path.join(temp.path, 'app.dill');
options =
_argParser.parse(<String>['--incremental', '--sdk-root=$sdkRoot',
'--output-dill=$outputTrainingDill'
]);
compiler ??=
new _FrontendCompiler(output, printerFactory: binaryPrinterFactory);
await compiler.compile(
Platform.script.toFilePath(), options, generator: generator);
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 ??= new _FrontendCompiler(