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.

<!-- Links -->
[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>
This commit is contained in:
LinXunFeng 2024-12-03 03:35:27 +08:00 committed by GitHub
parent bc4fc5ffb9
commit 6b5cd01e39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 24 deletions

View File

@ -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}'
);
}

View File

@ -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}'
);
}

View File

@ -124,11 +124,9 @@ Future<void> 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}'
);
}
}

View File

@ -303,11 +303,9 @@ Future<void> _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}'
);
}

View File

@ -157,11 +157,9 @@ Future<void> 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}'
);
}
}

View File

@ -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.