Commit 93a2d07c authored by Petr Hosek's avatar Petr Hosek Committed by Adam Barth

Use prebuilt Dart snapshot when assembling bundle (#6660)

This is causing issues when integratting Flutter into GN as the
generated depfile refers to snapshot as the target instead of the
bundle. We instead use a separate GN action to generate the
snapshot use the Flutter compiler to only assemble the bundle.
parent 223f4161
...@@ -13,35 +13,26 @@ import '../lib/src/cache.dart'; ...@@ -13,35 +13,26 @@ import '../lib/src/cache.dart';
import '../lib/src/flx.dart'; import '../lib/src/flx.dart';
import '../lib/src/globals.dart'; import '../lib/src/globals.dart';
const String _kOptionSnapshotter = 'snapshotter-path';
const String _kOptionTarget = 'target';
const String _kOptionPackages = 'packages'; const String _kOptionPackages = 'packages';
const String _kOptionOutput = 'output-file'; const String _kOptionOutput = 'output-file';
const String _kOptionHeader = 'header'; const String _kOptionHeader = 'header';
const String _kOptionSnapshot = 'snapshot'; const String _kOptionSnapshot = 'snapshot';
const String _kOptionDepfile = 'depfile';
const String _kOptionWorking = 'working-dir'; const String _kOptionWorking = 'working-dir';
const List<String> _kOptions = const <String>[ const List<String> _kOptions = const <String>[
_kOptionSnapshotter,
_kOptionTarget,
_kOptionPackages, _kOptionPackages,
_kOptionOutput, _kOptionOutput,
_kOptionHeader, _kOptionHeader,
_kOptionSnapshot, _kOptionSnapshot,
_kOptionDepfile,
_kOptionWorking, _kOptionWorking,
]; ];
Future<Null> main(List<String> args) async { Future<Null> main(List<String> args) async {
context[Logger] = new StdoutLogger(); context[Logger] = new StdoutLogger();
final ArgParser parser = new ArgParser() final ArgParser parser = new ArgParser()
..addOption(_kOptionSnapshotter, help: 'The snapshotter executable')
..addOption(_kOptionTarget, help: 'The entry point into the app')
..addOption(_kOptionPackages, help: 'The .packages file') ..addOption(_kOptionPackages, help: 'The .packages file')
..addOption(_kOptionOutput, help: 'The generated flx file') ..addOption(_kOptionOutput, help: 'The generated flx file')
..addOption(_kOptionHeader, help: 'The header of the flx file') ..addOption(_kOptionHeader, help: 'The header of the flx file')
..addOption(_kOptionSnapshot, help: 'The generated snapshot file') ..addOption(_kOptionSnapshot, help: 'The generated snapshot file')
..addOption(_kOptionDepfile, help: 'The generated dependency file')
..addOption(_kOptionWorking, ..addOption(_kOptionWorking,
help: 'The directory where to put temporary files'); help: 'The directory where to put temporary files');
final ArgResults argResults = parser.parse(args); final ArgResults argResults = parser.parse(args);
...@@ -52,13 +43,11 @@ Future<Null> main(List<String> args) async { ...@@ -52,13 +43,11 @@ Future<Null> main(List<String> args) async {
Cache.flutterRoot = Platform.environment['FLUTTER_ROOT']; Cache.flutterRoot = Platform.environment['FLUTTER_ROOT'];
String outputPath = argResults[_kOptionOutput]; String outputPath = argResults[_kOptionOutput];
final int buildResult = await build( final int buildResult = await build(
snapshotterPath: argResults[_kOptionSnapshotter],
mainPath: argResults[_kOptionTarget],
outputPath: outputPath, outputPath: outputPath,
snapshotPath: argResults[_kOptionSnapshot], snapshotPath: argResults[_kOptionSnapshot],
depfilePath: argResults[_kOptionDepfile],
workingDirPath: argResults[_kOptionWorking], workingDirPath: argResults[_kOptionWorking],
packagesPath: argResults[_kOptionPackages], packagesPath: argResults[_kOptionPackages],
precompiledSnapshot: true,
includeRobotoFonts: true, includeRobotoFonts: true,
); );
if (buildResult != 0) { if (buildResult != 0) {
......
...@@ -90,7 +90,6 @@ Future<int> build({ ...@@ -90,7 +90,6 @@ Future<int> build({
depfilePath ??= defaultDepfilePath; depfilePath ??= defaultDepfilePath;
workingDirPath ??= getAssetBuildDirectory(); workingDirPath ??= getAssetBuildDirectory();
packagesPath ??= path.absolute(PackageMap.globalPackagesPath); packagesPath ??= path.absolute(PackageMap.globalPackagesPath);
File snapshotFile;
if (!precompiledSnapshot) { if (!precompiledSnapshot) {
ensureDirectoryExists(snapshotPath); ensureDirectoryExists(snapshotPath);
...@@ -108,10 +107,10 @@ Future<int> build({ ...@@ -108,10 +107,10 @@ Future<int> build({
printError('Failed to run the Flutter compiler. Exit code: $result'); printError('Failed to run the Flutter compiler. Exit code: $result');
return result; return result;
} }
snapshotFile = new File(snapshotPath);
} }
File snapshotFile = new File(snapshotPath);
return assemble( return assemble(
manifestPath: manifestPath, manifestPath: manifestPath,
snapshotFile: snapshotFile, snapshotFile: snapshotFile,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment