Unverified Commit c15ff682 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

[macOS] Refactor macOS build/codesize analysis (#137164)

Extracts out _shouldWriteCodeSizeAnalysis and _writeCodeSizeAnalysis from the main buildMacOS function.

No tets changes sine this is a simple restructuring for readability and does not change any tool logic.
parent 8f6c1e35
......@@ -140,7 +140,20 @@ Future<void> buildMacOS({
if (result != 0) {
throwToolExit('Build process failed');
}
if (buildInfo.codeSizeDirectory != null && sizeAnalyzer != null) {
await _writeCodeSizeAnalysis(buildInfo, sizeAnalyzer);
globals.flutterUsage.sendTiming('build', 'xcode-macos', Duration(milliseconds: sw.elapsedMilliseconds));
}
/// Performs a size analysis of the AOT snapshot and writes to an analysis file, if configured.
///
/// Size analysis will be run for release builds where the --analyze-size
/// option has been specified. By default, size analysis JSON output is written
/// to ~/.flutter-devtools/macos-code-size-analysis_NN.json.
Future<void> _writeCodeSizeAnalysis(BuildInfo buildInfo, SizeAnalyzer? sizeAnalyzer) async {
// Bail out if the size analysis option was not specified.
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');
......@@ -180,6 +193,4 @@ Future<void> buildMacOS({
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
'dart devtools --appSizeBase=$relativeAppSizePath'
);
}
globals.flutterUsage.sendTiming('build', 'xcode-macos', Duration(milliseconds: sw.elapsedMilliseconds));
}
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