Skip to content

Commit 80d6c10

Browse files
authored
[Tool] [Windows] Output app path on build completion (flutter#122858)
[Tool] [Windows] Output app path on build completion
1 parent 328f088 commit 80d6c10

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-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: 17 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,22 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
9293
} finally {
9394
status.stop();
9495
}
96+
97+
final File appFile = buildDirectory
98+
.childDirectory('runner')
99+
.childDirectory(sentenceCase(buildModeName))
100+
.childFile('${windowsProject.parent.manifest.appName}.exe');
101+
if (appFile.existsSync()) {
102+
final String appSize = (buildInfo.mode == BuildMode.debug)
103+
? '' // Don't display the size when building a debug variant.
104+
: ' (${getSizeAsMB(appFile.lengthSync())})';
105+
globals.logger.printStatus(
106+
'${globals.logger.terminal.successMark} '
107+
'Built ${globals.fs.path.relative(appFile.path)}$appSize.',
108+
color: TerminalColor.green,
109+
);
110+
}
111+
95112
if (buildInfo.codeSizeDirectory != null && sizeAnalyzer != null) {
96113
final String arch = getNameForTargetPlatform(TargetPlatform.windows_x64);
97114
final File codeSizeFile = globals.fs.directory(buildInfo.codeSizeDirectory)

0 commit comments

Comments
 (0)