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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user