Unverified Commit 50fd10fc authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Consider the Windows app template stable (#66022)

Removes the template version from the Windows template; the API and
tooling boundary will now be considered stable, so there will no longer
be frequent breaking changes.

Also updates the link for adding desktop support to a project for all
three platforms to reflect the current location.

Fixes https://github.com/flutter/flutter/issues/52748
parent 8162bbd8
......@@ -26,7 +26,7 @@ Future<void> buildLinux(
}) async {
if (!linuxProject.cmakeFile.existsSync()) {
throwToolExit('No Linux desktop project configured. See '
'https://github.com/flutter/flutter/wiki/Desktop-shells#create '
'https://flutter.dev/desktop#add-desktop-support-to-an-existing-app '
'to learn about adding Linux support to a project.');
}
......
......@@ -31,7 +31,7 @@ Future<void> buildMacOS({
}) async {
if (!flutterProject.macos.xcodeWorkspace.existsSync()) {
throwToolExit('No macOS desktop project configured. '
'See https://flutter.dev/desktop#add-desktop-support-to-an-existing-flutter-project '
'See https://flutter.dev/desktop#add-desktop-support-to-an-existing-app '
'to learn about adding macOS support to a project.');
}
......
......@@ -31,25 +31,11 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
}) async {
if (!windowsProject.cmakeFile.existsSync()) {
throwToolExit(
'No Windows desktop project configured. '
'See https://github.com/flutter/flutter/wiki/Desktop-shells#create '
'No Windows desktop project configured. See '
'https://flutter.dev/desktop#add-desktop-support-to-an-existing-app '
'to learn about adding Windows support to a project.');
}
// Check for incompatibility between the Flutter tool version and the project
// template version, since the tempalte isn't stable yet.
final int templateCompareResult = _compareTemplateVersions(windowsProject);
if (templateCompareResult < 0) {
throwToolExit('The Windows runner was created with an earlier version of '
'the template, which is not yet stable.\n\n'
'Delete the windows/ directory and re-run \'flutter create .\', '
're-applying any previous changes.');
} else if (templateCompareResult > 0) {
throwToolExit('The Windows runner was created with a newer version of the '
'template, which is not yet stable.\n\n'
'Upgrade Flutter and try again.');
}
// Ensure that necessary emphemeral files are generated and up to date.
_writeGeneratedFlutterConfig(windowsProject, buildInfo, target);
createPluginSymlinks(windowsProject.parent);
......@@ -189,25 +175,3 @@ void _writeGeneratedFlutterConfig(
}
writeGeneratedCmakeConfig(Cache.flutterRoot, windowsProject, environment);
}
// Checks the template version of [project] against the current template
// version. Returns < 0 if the project is older than the current template, > 0
// if it's newer, and 0 if they match.
int _compareTemplateVersions(WindowsProject project) {
const String projectVersionBasename = '.template_version';
final int expectedVersion = int.parse(globals.fs.file(globals.fs.path.join(
globals.fs.path.absolute(Cache.flutterRoot),
'packages',
'flutter_tools',
'templates',
'app',
'windows.tmpl',
'flutter',
projectVersionBasename,
)).readAsStringSync());
final File projectVersionFile = project.managedDirectory.childFile(projectVersionBasename);
final int version = projectVersionFile.existsSync()
? int.tryParse(projectVersionFile.readAsStringSync())
: 0;
return version.compareTo(expectedVersion);
}
......@@ -79,7 +79,6 @@
"templates/app/linux.tmpl/my_application.cc.tmpl",
"templates/app/linux.tmpl/.gitignore",
"templates/app/linux.tmpl/CMakeLists.txt.tmpl",
"templates/app/linux.tmpl/flutter/.template_version",
"templates/app/linux.tmpl/flutter/CMakeLists.txt",
"templates/app/linux.tmpl/main.cc",
"templates/app/linux.tmpl/my_application.cc",
......@@ -121,7 +120,6 @@
"templates/app/web/manifest.json.tmpl",
"templates/app/windows.tmpl/.gitignore",
"templates/app/windows.tmpl/CMakeLists.txt.tmpl",
"templates/app/windows.tmpl/flutter/.template_version",
"templates/app/windows.tmpl/flutter/CMakeLists.txt",
"templates/app/windows.tmpl/runner/CMakeLists.txt",
"templates/app/windows.tmpl/runner/flutter_window.cpp",
......
......@@ -68,26 +68,6 @@ void main() {
void setUpMockProjectFilesForBuild({int templateVersion}) {
fileSystem.file(buildFilePath).createSync(recursive: true);
setUpMockCoreProjectFiles();
final String versionFileSubpath = fileSystem.path.join('flutter', '.template_version');
const int expectedTemplateVersion = 10; // Arbitrary value for tests.
final File sourceTemplateVersionfile = fileSystem.file(fileSystem.path.join(
fileSystem.path.absolute(Cache.flutterRoot),
'packages',
'flutter_tools',
'templates',
'app',
'windows.tmpl',
versionFileSubpath,
));
sourceTemplateVersionfile.createSync(recursive: true);
sourceTemplateVersionfile.writeAsStringSync(expectedTemplateVersion.toString());
final File projectTemplateVersionFile = fileSystem.file(
fileSystem.path.join('windows', versionFileSubpath));
templateVersion ??= expectedTemplateVersion;
projectTemplateVersionFile.createSync(recursive: true);
projectTemplateVersionFile.writeAsStringSync(templateVersion.toString());
}
// Returns the command matching the build_windows call to generate CMake
......@@ -184,38 +164,6 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows build fails with instructions when template is too old', () async {
final BuildWindowsCommand command = BuildWindowsCommand()
..visualStudioOverride = mockVisualStudio;
applyMocksToCommand(command);
setUpMockProjectFilesForBuild(templateVersion: 1);
expect(createTestCommandRunner(command).run(
const <String>['windows', '--no-pub']
), throwsToolExit(message: 'flutter create .'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => windowsPlatform,
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows build fails with instructions when template is too new', () async {
final BuildWindowsCommand command = BuildWindowsCommand()
..visualStudioOverride = mockVisualStudio;
applyMocksToCommand(command);
setUpMockProjectFilesForBuild(templateVersion: 999);
expect(createTestCommandRunner(command).run(
const <String>['windows', '--no-pub']
), throwsToolExit(message: 'Upgrade Flutter'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => windowsPlatform,
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows build does not spew stdout to status logger', () async {
final BuildWindowsCommand command = BuildWindowsCommand()
..visualStudioOverride = mockVisualStudio;
......
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