From 6b5cd01e390c33f0b142aa5b810e54bd2bfda35f Mon Sep 17 00:00:00 2001 From: LinXunFeng Date: Tue, 3 Dec 2024 03:35:27 +0800 Subject: [PATCH] Fix output path for --appSizeBase (#158302) Fixes https://github.com/flutter/flutter/issues/158211 before ```shell A summary of your APK analysis can be found at: /Users/lxf/.flutter-devtools/apk-code-size-analysis_01.json To analyze your app size in Dart DevTools, run the following command: dart devtools --appSizeBase=apk-code-size-analysis_01.json ``` now ```shell A summary of your APK analysis can be found at: /Users/lxf/.flutter-devtools/apk-code-size-analysis_01.json To analyze your app size in Dart DevTools, run the following command: dart devtools --appSizeBase=/Users/lxf/.flutter-devtools/apk-code-size-analysis_01.json ``` ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md Co-authored-by: Kenzie Davisson <43759233+kenzieschmoll@users.noreply.github.com> --- packages/flutter_tools/lib/src/android/gradle.dart | 7 +------ packages/flutter_tools/lib/src/commands/build_ios.dart | 4 +--- packages/flutter_tools/lib/src/linux/build_linux.dart | 4 +--- packages/flutter_tools/lib/src/macos/build_macos.dart | 4 +--- .../flutter_tools/lib/src/windows/build_windows.dart | 4 +--- .../test/integration.shard/analyze_size_test.dart | 9 +++------ 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index eb647f27ac0..9dcb8f0df89 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -629,14 +629,9 @@ class AndroidGradleBuilder implements AndroidBuilder { 'A summary of your ${kind.toUpperCase()} analysis can be found at: ${outputFile.path}', ); - // DevTools expects a file path relative to the .flutter-devtools/ dir. - final String relativeAppSizePath = outputFile.path - .split('.flutter-devtools/') - .last - .trim(); _logger.printStatus( '\nTo analyze your app size in Dart DevTools, run the following command:\n' - 'dart devtools --appSizeBase=$relativeAppSizePath' + 'dart devtools --appSizeBase=${outputFile.path}' ); } diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart index 3401776c529..9b10fa9316b 100644 --- a/packages/flutter_tools/lib/src/commands/build_ios.dart +++ b/packages/flutter_tools/lib/src/commands/build_ios.dart @@ -773,11 +773,9 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { 'A summary of your iOS bundle analysis can be found at: ${outputFile.path}', ); - // DevTools expects a file path relative to the .flutter-devtools/ dir. - final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim(); globals.printStatus( '\nTo analyze your app size in Dart DevTools, run the following command:\n' - 'dart devtools --appSizeBase=$relativeAppSizePath' + 'dart devtools --appSizeBase=${outputFile.path}' ); } diff --git a/packages/flutter_tools/lib/src/linux/build_linux.dart b/packages/flutter_tools/lib/src/linux/build_linux.dart index 8f9f1141fb8..882586b217d 100644 --- a/packages/flutter_tools/lib/src/linux/build_linux.dart +++ b/packages/flutter_tools/lib/src/linux/build_linux.dart @@ -124,11 +124,9 @@ Future buildLinux( 'A summary of your Linux bundle analysis can be found at: ${outputFile.path}', ); - // DevTools expects a file path relative to the .flutter-devtools/ dir. - final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim(); logger.printStatus( '\nTo analyze your app size in Dart DevTools, run the following command:\n' - 'dart devtools --appSizeBase=$relativeAppSizePath' + 'dart devtools --appSizeBase=${outputFile.path}' ); } } diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index bbda3276f62..2e9ffbed470 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -303,11 +303,9 @@ Future _writeCodeSizeAnalysis(BuildInfo buildInfo, SizeAnalyzer? sizeAnaly 'A summary of your macOS bundle analysis can be found at: ${outputFile.path}', ); - // DevTools expects a file path relative to the .flutter-devtools/ dir. - final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim(); globals.printStatus( '\nTo analyze your app size in Dart DevTools, run the following command:\n' - 'dart devtools --appSizeBase=$relativeAppSizePath' + 'dart devtools --appSizeBase=${outputFile.path}' ); } diff --git a/packages/flutter_tools/lib/src/windows/build_windows.dart b/packages/flutter_tools/lib/src/windows/build_windows.dart index c614c64b4e9..e17a6faefba 100644 --- a/packages/flutter_tools/lib/src/windows/build_windows.dart +++ b/packages/flutter_tools/lib/src/windows/build_windows.dart @@ -157,11 +157,9 @@ Future buildWindows( 'A summary of your Windows bundle analysis can be found at: ${outputFile.path}', ); - // DevTools expects a file path relative to the .flutter-devtools/ dir. - final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim(); globals.printStatus( '\nTo analyze your app size in Dart DevTools, run the following command:\n' - 'dart devtools --appSizeBase=$relativeAppSizePath' + 'dart devtools --appSizeBase=${outputFile.path}' ); } } diff --git a/packages/flutter_tools/test/integration.shard/analyze_size_test.dart b/packages/flutter_tools/test/integration.shard/analyze_size_test.dart index f7a12ec4a84..951afa8729e 100644 --- a/packages/flutter_tools/test/integration.shard/analyze_size_test.dart +++ b/packages/flutter_tools/test/integration.shard/analyze_size_test.dart @@ -46,8 +46,7 @@ void main() { .split('\n') .firstWhere((String line) => line.contains(runDevToolsMessage)); final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim(); - final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim(); - expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue); + expect(commandArguments.contains('--appSizeBase=$outputFilePath'), isTrue); }); testWithoutContext('--analyze-size flag produces expected output on hello_world for iOS', () async { @@ -80,9 +79,8 @@ void main() { .split('\n') .firstWhere((String line) => line.contains(runDevToolsMessage)); final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim(); - final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim(); - expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue); + expect(commandArguments.contains('--appSizeBase=$outputFilePath'), isTrue); expect(codeSizeDir.existsSync(), true); tempDir.deleteSync(recursive: true); }, skip: !platform.isMacOS); // [intended] iOS can only be built on macos. @@ -132,9 +130,8 @@ void main() { .split('\n') .firstWhere((String line) => line.contains(runDevToolsMessage)); final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim(); - final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim(); - expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue); + expect(commandArguments.contains('--appSizeBase=$outputFilePath'), isTrue); expect(codeSizeDir.existsSync(), true); tempDir.deleteSync(recursive: true); }, skip: !platform.isMacOS); // [intended] this is a macos only test.