diff --git a/frontend_server/lib/server.dart b/frontend_server/lib/server.dart index 7ba922f494af8..c2492750b6005 100644 --- a/frontend_server/lib/server.dart +++ b/frontend_server/lib/server.dart @@ -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 starter( if (options['train']) { final String sdkRoot = options['sdk-root']; - options = _argParser.parse(['--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(['--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(