Commit 9a67954b authored by Chinmay Garde's avatar Chinmay Garde

Avoid script snapshot creation if the --precompiled flag is set during builds

parent b53e7264
...@@ -127,8 +127,8 @@ class BuildCommand extends FlutterCommand { ...@@ -127,8 +127,8 @@ class BuildCommand extends FlutterCommand {
final String description = 'Create a Flutter app.'; final String description = 'Create a Flutter app.';
BuildCommand() { BuildCommand() {
argParser.addFlag('precompiled', negatable: false);
argParser.addOption('asset-base', defaultsTo: _kDefaultAssetBase); argParser.addOption('asset-base', defaultsTo: _kDefaultAssetBase);
argParser.addOption('compiler'); argParser.addOption('compiler');
argParser.addOption('main', defaultsTo: _kDefaultMainPath); argParser.addOption('main', defaultsTo: _kDefaultMainPath);
argParser.addOption('manifest'); argParser.addOption('manifest');
...@@ -153,7 +153,8 @@ class BuildCommand extends FlutterCommand { ...@@ -153,7 +153,8 @@ class BuildCommand extends FlutterCommand {
manifestPath: argResults['manifest'], manifestPath: argResults['manifest'],
outputPath: argResults['output-file'], outputPath: argResults['output-file'],
snapshotPath: argResults['snapshot'], snapshotPath: argResults['snapshot'],
privateKeyPath: argResults['private-key'] privateKeyPath: argResults['private-key'],
precompiledSnapshot: argResults['precompiled']
); );
} }
...@@ -163,7 +164,8 @@ class BuildCommand extends FlutterCommand { ...@@ -163,7 +164,8 @@ class BuildCommand extends FlutterCommand {
String manifestPath, String manifestPath,
String outputPath: _kDefaultOutputPath, String outputPath: _kDefaultOutputPath,
String snapshotPath: _kDefaultSnapshotPath, String snapshotPath: _kDefaultSnapshotPath,
String privateKeyPath: _kDefaultPrivateKeyPath String privateKeyPath: _kDefaultPrivateKeyPath,
bool precompiledSnapshot: false
}) async { }) async {
Map manifestDescriptor = _loadManifest(manifestPath); Map manifestDescriptor = _loadManifest(manifestPath);
...@@ -172,11 +174,15 @@ class BuildCommand extends FlutterCommand { ...@@ -172,11 +174,15 @@ class BuildCommand extends FlutterCommand {
Archive archive = new Archive(); Archive archive = new Archive();
if (!precompiledSnapshot) {
// In a precompiled snapshot, the instruction buffer contains script
// content equivalents
int result = await toolchain.compiler.compile(mainPath: mainPath, snapshotPath: snapshotPath); int result = await toolchain.compiler.compile(mainPath: mainPath, snapshotPath: snapshotPath);
if (result != 0) if (result != 0)
return result; return result;
archive.addFile(_createSnapshotFile(snapshotPath)); archive.addFile(_createSnapshotFile(snapshotPath));
}
for (_Asset asset in assets) for (_Asset asset in assets)
archive.addFile(_createFile(asset.key, asset.base)); archive.addFile(_createFile(asset.key, asset.base));
......
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