Unverified Commit c799c2fd authored by Stanislav Baranov's avatar Stanislav Baranov Committed by GitHub

Use "product" mode VM snapshot when running dynamic "release" mode flutter...

Use "product" mode VM snapshot when running dynamic "release" mode flutter with cached engine. (#22043)

Dynamic "release" mode requires "product" (not "release") mode VM, so we must point it to the correct cached snapshot.

Generation and caching of this snapshot happens the following corresponding change: https://chromium-review.googlesource.com/c/chromium/tools/build/+/1232134
parent 76468dd5
......@@ -32,7 +32,7 @@ enum Artifact {
engineDartBinary,
}
String _artifactToFileName(Artifact artifact, [TargetPlatform platform]) {
String _artifactToFileName(Artifact artifact, [TargetPlatform platform, BuildMode mode]) {
switch (artifact) {
case Artifact.dartIoEntriesTxt:
return 'dart_io_entries.txt';
......@@ -54,8 +54,20 @@ String _artifactToFileName(Artifact artifact, [TargetPlatform platform]) {
case Artifact.flutterFramework:
return 'Flutter.framework';
case Artifact.vmSnapshotData:
// Flutter debug and dynamic profile modes for all target platforms use Dart
// RELEASE VM snapshot that comes from host debug build and has the metadata
// related to development tools.
if (mode == BuildMode.dynamicRelease) {
return 'product_vm_isolate_snapshot.bin';
}
// Flutter dynamic release mode for all target platforms uses Dart PRODUCT
// VM snapshot from host dynamic release build that strips out the metadata
// related to development tools.
return 'vm_isolate_snapshot.bin';
case Artifact.isolateSnapshotData:
if (mode == BuildMode.dynamicRelease) {
return 'product_isolate_snapshot.bin';
}
return 'isolate_snapshot.bin';
case Artifact.platformKernelDill:
return 'platform_strong.dill';
......@@ -119,7 +131,7 @@ class CachedArtifacts extends Artifacts {
case TargetPlatform.windows_x64:
case TargetPlatform.fuchsia:
case TargetPlatform.tester:
return _getHostArtifactPath(artifact, platform);
return _getHostArtifactPath(artifact, platform, mode);
}
assert(false, 'Invalid platform $platform.');
return null;
......@@ -173,7 +185,7 @@ class CachedArtifacts extends Artifacts {
return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk');
}
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform) {
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
switch (artifact) {
case Artifact.genSnapshot:
// For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for
......@@ -185,7 +197,7 @@ class CachedArtifacts extends Artifacts {
case Artifact.frontendServerSnapshotForEngineDartSdk:
final String engineArtifactsPath = cache.getArtifactDirectory('engine').path;
final String platformDirName = getNameForTargetPlatform(platform);
return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform));
return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
case Artifact.engineDartSdkPath:
return dartSdkPath;
case Artifact.engineDartBinary:
......
......@@ -111,6 +111,7 @@ Future<void> build({
throwToolExit('Error building assets', exitCode: 1);
await assemble(
buildMode: buildMode,
assetBundle: assets,
kernelContent: kernelContent,
privateKeyPath: privateKeyPath,
......@@ -145,6 +146,7 @@ Future<AssetBundle> buildAssets({
}
Future<void> assemble({
BuildMode buildMode,
AssetBundle assetBundle,
DevFSContent kernelContent,
File dylibFile,
......@@ -168,8 +170,8 @@ Future<void> assemble({
assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr));
} else {
final String platformKernelDill = artifacts.getArtifactPath(Artifact.platformKernelDill);
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData);
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode);
assetEntries[_kKernelKey] = kernelContent;
assetEntries[_kPlatformKernelKey] = DevFSFileContent(fs.file(platformKernelDill));
assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData));
......
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