Skip to content

Commit 2312097

Browse files
authored
[Tool] [Windows] Output app path on build completion (flutter#122928)
[Tool] [Windows] Output app path on build completion
1 parent bca0d2c commit 2312097

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

dev/devicelab/lib/tasks/run_tests.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
177177
r'Building Windows application\.\.\.\s*\d+(\.\d+)?(ms|s)',
178178
multiLine: true,
179179
);
180+
static final RegExp _builtOutput = RegExp(
181+
r'Built build\\windows\\runner\\(Debug|Release)\\\w+\.exe( \(\d+(\.\d+)?MB\))?\.',
182+
);
180183

181184
@override
182185
void verifyBuildOutput(List<String> stdout) {
@@ -185,6 +188,25 @@ class WindowsRunOutputTest extends DesktopRunOutputTest {
185188
_buildOutput.hasMatch,
186189
'Building Windows application...',
187190
);
191+
192+
final String buildMode = release ? 'Release' : 'Debug';
193+
_findNextMatcherInList(
194+
stdout,
195+
(String line) {
196+
if (!_builtOutput.hasMatch(line) || !line.contains(buildMode)) {
197+
return false;
198+
}
199+
200+
// Size information is only included in release builds.
201+
final bool hasSize = line.contains('MB).');
202+
if (release != hasSize) {
203+
return false;
204+
}
205+
206+
return true;
207+
},
208+
'Built build\\windows\\runner\\$buildMode\\app.exe',
209+
);
188210
}
189211
}
190212

packages/flutter_tools/lib/src/windows/build_windows.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import '../base/common.dart';
88
import '../base/file_system.dart';
99
import '../base/logger.dart';
1010
import '../base/project_migrator.dart';
11+
import '../base/terminal.dart';
1112
import '../base/utils.dart';
1213
import '../build_info.dart';
1314
import '../cache.dart';
@@ -92,6 +93,23 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
9293
} finally {
9394
status.stop();
9495
}
96+
97+
final String? binaryName = getCmakeExecutableName(windowsProject);
98+
final File appFile = buildDirectory
99+
.childDirectory('runner')
100+
.childDirectory(sentenceCase(buildModeName))
101+
.childFile('$binaryName.exe');
102+
if (appFile.existsSync()) {
103+
final String appSize = (buildInfo.mode == BuildMode.debug)
104+
? '' // Don't display the size when building a debug variant.
105+
: ' (${getSizeAsMB(appFile.lengthSync())})';
106+
globals.logger.printStatus(
107+
'${globals.logger.terminal.successMark} '
108+
'Built ${globals.fs.path.relative(appFile.path)}$appSize.',
109+
color: TerminalColor.green,
110+
);
111+
}
112+
95113
if (buildInfo.codeSizeDirectory != null && sizeAnalyzer != null) {
96114
final String arch = getNameForTargetPlatform(TargetPlatform.windows_x64);
97115
final File codeSizeFile = globals.fs.directory(buildInfo.codeSizeDirectory)

0 commit comments

Comments
 (0)