Unverified Commit 23120977 authored by Loïc Sharma's avatar Loïc Sharma Committed by GitHub

[Tool] [Windows] Output app path on build completion (#122928)

[Tool] [Windows] Output app path on build completion
parent bca0d2cd
......@@ -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) {
......@@ -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',
);
}
}
......
......@@ -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';
......@@ -92,6 +93,23 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
} finally {
status.stop();
}
final String? binaryName = getCmakeExecutableName(windowsProject);
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment