Skip to content

Commit

Permalink
Write artifacts produced during frontend_server training into temp fo…
Browse files Browse the repository at this point in the history
…lder. (flutter#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 {}
  • Loading branch information
aam authored Feb 18, 2018
1 parent e5b72e5 commit 802eec2
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions frontend_server/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 802eec2

Please sign in to comment.