Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions dev/devicelab/lib/tasks/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
r'Building Windows application\.\.\.\s*\d+(\.\d+)?(ms|s)',
multiLine: true,
);
static final RegExp _builtOutput = RegExp(
r'Built build\\windows\\runner\\(Debug|Release)\\\w+\.exe( \(\d+(\.\d+)?MB\))?\.',
);

@override
void verifyBuildOutput(List<String> stdout) {
Expand All @@ -185,6 +188,25 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
_buildOutput.hasMatch,
'Building Windows application...',
);

final String buildMode = release ? 'Release' : 'Debug';
_findNextMatcherInList(
stdout,
(String line) {
if (!_builtOutput.hasMatch(line) || !line.contains(buildMode)) {
return false;
}

// Size information is only included in release builds.
final bool hasSize = line.contains('MB).');
if (release != hasSize) {
return false;
}

return true;
},
'Built build\\windows\\runner\\$buildMode\\app.exe',
);
}
}

Expand Down
18 changes: 18 additions & 0 deletions packages/flutter_tools/lib/src/windows/build_windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/project_migrator.dart';
import '../base/terminal.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../cache.dart';
Expand Down Expand Up @@ -92,6 +93,23 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
} finally {
status.stop();
}

final String? binaryName = getCmakeExecutableName(windowsProject);
Copy link
Member Author

@loic-sharma loic-sharma Mar 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reland's fix. The original change used the app's name according to the pubspec.yaml file and assumed that matched CMake's app name. However, these files can get out of sync.

final File appFile = buildDirectory
.childDirectory('runner')
.childDirectory(sentenceCase(buildModeName))
.childFile('$binaryName.exe');
if (appFile.existsSync()) {
final String appSize = (buildInfo.mode == BuildMode.debug)
? '' // Don't display the size when building a debug variant.
: ' (${getSizeAsMB(appFile.lengthSync())})';
globals.logger.printStatus(
'${globals.logger.terminal.successMark} '
'Built ${globals.fs.path.relative(appFile.path)}$appSize.',
color: TerminalColor.green,
);
}

if (buildInfo.codeSizeDirectory != null && sizeAnalyzer != null) {
final String arch = getNameForTargetPlatform(TargetPlatform.windows_x64);
final File codeSizeFile = globals.fs.directory(buildInfo.codeSizeDirectory)
Expand Down