[flutter_tools] Fix analyze size on arm64 (#141317)

Fixes https://github.com/flutter/flutter/issues/140659
This commit is contained in:
Christopher Fujino
2024-01-16 16:15:28 -08:00
committed by GitHub
parent 0c66636a1f
commit 4cd0a3252d
3 changed files with 82 additions and 24 deletions

View File

@@ -455,22 +455,22 @@ abstract class MacOSBundleFlutterAssets extends Target {
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>

View File

@@ -181,11 +181,25 @@ Future<void> _writeCodeSizeAnalysis(BuildInfo buildInfo, SizeAnalyzer? sizeAnaly
if (buildInfo.codeSizeDirectory == null || sizeAnalyzer == null) {
return;
}
final String arch = DarwinArch.x86_64.name;
final File aotSnapshot = globals.fs.directory(buildInfo.codeSizeDirectory)
.childFile('snapshot.$arch.json');
final File precompilerTrace = globals.fs.directory(buildInfo.codeSizeDirectory)
.childFile('trace.$arch.json');
final File? aotSnapshot = DarwinArch.values.map<File?>((DarwinArch arch) {
return globals.fs.directory(buildInfo.codeSizeDirectory).childFile('snapshot.${arch.name}.json');
// Pick the first if there are multiple for simplicity
}).firstWhere(
(File? file) => file!.existsSync(),
orElse: () => null,
);
if (aotSnapshot == null) {
throw StateError('No code size snapshot file (snapshot.<ARCH>.json) found in ${buildInfo.codeSizeDirectory}');
}
final File? precompilerTrace = DarwinArch.values.map<File?>((DarwinArch arch) {
return globals.fs.directory(buildInfo.codeSizeDirectory).childFile('trace.${arch.name}.json');
}).firstWhere(
(File? file) => file!.existsSync(),
orElse: () => null,
);
if (precompilerTrace == null) {
throw StateError('No precompiler trace file (trace.<ARCH>.json) found in ${buildInfo.codeSizeDirectory}');
}
// This analysis is only supported for release builds.
// Attempt to guess the correct .app by picking the first one.